netroute

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2020 License: BSD-3-Clause Imports: 9 Imported by: 108

README

Go Netroute

Build Status

A cross-platform implementation of the gopacket/routing.Router interface.

This library is derived from gopacket for linux, x/net/route for mac, and iphlpapi.dll for windows.

Table of Contents

Install

go get github.com/libp2p/go-netroute

Usage

To be used for querying the local OS routing table.

import (
    netroute "github.com/libp2p/go-netroute"
)

func main() {
    r, err := netroute.New()
    if err != nil {
        panic(err)
    }
    iface, gw, src, err := r.Route(net.IPv4(127, 0, 0, 1))
    fmt.Printf("%v, %v, %v, %v\n", iface, gw, src, err)
}

Documentation

See the gopacket interface for thoughts on design, and godoc for API documentation.

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

BSD © Will Scott, and the Gopacket authors (i.e. Google)

Documentation

Overview

Originally found in https://github.com/google/gopacket/blob/master/routing/routing.go

  • Route selection modified to choose most selective route to break ties when route priority is insufficient.

This is a BSD import for the routing structure initially found in https://github.com/google/gopacket/blob/master/routing/routing.go RIB parsing follows the BSD route format described in https://github.com/freebsd/freebsd/blob/master/sys/net/route.h

Index

Constants

View Source
const (
	RTF_UP        = 0x1
	RTF_GATEWAY   = 0x2
	RTF_HOST      = 0x4
	RTF_REJECT    = 0x8
	RTF_DYNAMIC   = 0x10
	RTF_MODIFIED  = 0x20
	RTF_STATIC    = 0x800
	RTF_BLACKHOLE = 0x1000
	RTF_LOCAL     = 0x200000
	RTF_BROADCAST = 0x400000
	RTF_MULTICAST = 0x800000
)

selected BSD Route flags.

Variables

This section is empty.

Functions

func New

func New() (routing.Router, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL