GithubHelp home page GithubHelp logo

yutarohayakawa / go-ra Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 2.0 206 KB

A pure Go IPv6 Router Advertisement library and stand-alone daemon

License: Apache License 2.0

Go 99.12% Makefile 0.64% Dockerfile 0.24%
golang ipv6 linux neighbor-discovery router-discovery

go-ra's Introduction

go-ra

Go Reference

Provides the ra package that implements a router-side functionality of IPv6 Neighbor Discovery mechanism (RFC4861 and related RFCs). It also provides a stand-alone daemon gorad and CLI tool gora to interact with it. While the existing mdlayher/ndp package provides a low-level protocol functionalities (packet encoding, raw-socket wrapper, etc), go-ra implements an unsolicited and solicited advertisement machinery and declarative configuration interface on top of it.

Features

  • Basic RA mechanism defined in RFC4861
  • Router MAC address discovery with Source Link Layer Address option
  • MTU discovery with MTU option
  • Prefix discovery with Prefix Information option
  • DNS configuration discovery with RDNSS/DNSSL option
  • Route advertisement with Route Information option
  • NAT64 prefix discovery with PREF64 option

Installation

  • Library: Use Go Modules as usual
  • Stand-alone Binary: Visit release page and install pre-build binaries
  • Container Image: Visit registry page and pull images

Basic Usage

As a library

// Build a configuration
config := ra.Config{
	  Interfaces: []*ra.InterfaceConfig{
		    {
			      Name: "eth0",
			      // Send unsolicited RA once a second
			      RAIntervalMilliseconds: 1000, // 1sec
		    },	
	  },
}

// Create an RA daemon
daemon, _ := ra.NewDaemon(&config)

// Run it
ctx, cancel := context.WithCancel(context.Background())
go daemon.Run(ctx)

// Get a running status
status := daemon.Status()
for _, iface := range status.Interfaces {
    fmt.Printf("%s: %s (%s)\n", iface.Name, iface.State, iface.Message)
}

// Change configuration and reload
config.Interfaces[0].RAIntervalMilliseconds = 2000 // 2sec
err := daemon.Reload(ctx, &config)
if err != nil {
    panic(err)
}

// Stop it
cancel()

As a stand-alone daemon

Create a configuration file. This configuration will be translated into the Config object and passed to the daemon. Please see the godoc for more details.

interfaces:
- name: eth0
  raIntervalMilliseconds: 1000 # 1sec

Start daemon. You need a root privilege to run it.

$ sudo gorad -f config.yaml

Get status.

$ gora status
Name         Age    TxUnsolicited    TxSolicited    State      Message
eth0         22s    21               1              Running

Modify and reload configuration

$ gora reload -f config.yaml

Motivation

Our original motivation for this project was use it with gobgp library to do BGP Unnumbered (see our integration test) which for us, makes sense to reinvent the RA daemon to not introduce an external non-go dependency.

go-ra's People

Contributors

yutarohayakawa avatar renovate[bot] avatar enigamict avatar y-kzm avatar

Stargazers

 avatar Shivaram Mysore avatar abbas ali chezgi avatar Antoine avatar Chris Hills avatar Michael Kashin avatar  avatar Hiroaki Nakamura avatar Yoshiaki Ueda (bootjp) avatar Kotaro Inoue avatar

Watchers

 avatar

Forkers

enigamict y-kzm

go-ra's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
Dockerfile
github-actions
.github/workflows/check-codegen.yaml
  • actions/checkout v4
  • actions/setup-go v5
.github/workflows/golangci-lint.yaml
  • actions/checkout v4
  • actions/setup-go v5
  • golangci/golangci-lint-action v6
.github/workflows/release.yaml
  • actions/checkout v4
  • actions/setup-go v5
  • docker/login-action v3
  • goreleaser/goreleaser-action v6
.github/workflows/tests.yaml
  • actions/checkout v4
  • actions/setup-go v5
  • actions/upload-artifact v4
gomod
go.mod
  • go 1.22.0
  • go 1.22.4
  • github.com/creasty/defaults v1.7.0
  • github.com/globusdigital/deep-copy v0.5.5-0.20240510190924-e112476c0181@e112476c0181
  • github.com/go-playground/validator/v10 v10.22.0
  • github.com/lorenzosaino/go-sysctl v0.3.1
  • github.com/mdlayher/ndp v1.1.0
  • github.com/osrg/gobgp/v3 v3.28.0
  • github.com/sethvargo/go-retry v0.2.4
  • github.com/stretchr/testify v1.9.0
  • github.com/vishvananda/netlink v1.2.1-beta.2
  • golang.org/x/net v0.26.0
  • golang.org/x/sys v0.21.0
  • golang.org/x/tools v0.22.0
  • gopkg.in/yaml.v3 v3.0.1
  • k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0@fe8a2dddb1d0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.