README.md 2 KB
Newer Older
1 2 3
Go Netroute
===

Will Scott's avatar
Will Scott committed
4 5 6
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://github.com/libp2p/libp2p)
[![Build Status](https://travis-ci.com/libp2p/go-netroute.svg?branch=master)](https://travis-ci.com/libp2p/go-netroute)
Will Scott's avatar
Will Scott committed
7

Will Scott's avatar
Will Scott committed
8
A cross-platform implementation of the [`gopacket/routing.Router`](https://godoc.org/github.com/google/gopacket/routing#Router) interface.
9

Will Scott's avatar
Will Scott committed
10
This library is derived from `gopacket` for linux, `x/net/route` for mac, and `iphlpapi.dll` for windows.
11

Will Scott's avatar
Will Scott committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Documentation](#documentation)
- [Contribute](#contribute)
- [License](#license)

## Install

```
go get github.com/libp2p/go-netroute
```

## Usage

To be used for querying the local OS routing table.
29

30
```go
31
import (
Will Scott's avatar
Will Scott committed
32
    netroute "github.com/libp2p/go-netroute"
33 34 35 36 37 38 39 40 41 42 43
)

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)
}
```
Will Scott's avatar
Will Scott committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

## Documentation

See the [gopacket](https://github.com/google/gopacket/blob/master/routing/) interface for thoughts on design,
and [godoc](https://godoc.org/github.com/libp2p/go-netroute) for API documentation.

## Contribute

Contributions welcome. Please check out [the issues](https://github.com/libp2p/go-netroute/issues).

Check out our [contributing document](https://github.com/libp2p/community/blob/master/contributing.md) 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](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## License

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