jackpal / gateway

A golang library for discovering the address of a LAN gateway.
BSD 3-Clause "New" or "Revised" License
227 stars 69 forks source link

gateway

A simple library for discovering the IP address of the default gateway.

Example:

package main

import (
    "fmt"

    "github.com/jackpal/gateway"
)

func main() {
    gateway, err := gateway.DiscoverGateway()
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println("Gateway:", gateway.String())
   }
}

Provides implementations for:

Other platforms use an implementation that always returns an error.

Pull requests for other OSs happily considered!

Versions

v1.0.15

Update dependencies to latest versions. This was done to squelch a github security alert caused by depending upon an old version of x/net. This is the first time I've updated module versions, the tests pass, so hopefully everything's good.

v1.0.14

v1.0.13

v1.0.12

v1.0.11

v1.0.10

v1.0.9

v1.0.8