File: README.md

package info (click to toggle)
golang-github-jackpal-gateway 1.0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: sh: 38; makefile: 2
file content (93 lines) | stat: -rw-r--r-- 2,249 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# gateway

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

Example:

```go
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:

+ Darwin (macOS)
+ Dragonfly
+ FreeBSD
+ Linux
+ NetBSD
+ OpenBSD
+ Solaris and illumos
+ Windows

Other platforms use an implementation that always returns an error.

Pull requests for other OSs happily considered!

## Versions

### v1.0.16

Update x/net dependency. This was done to squelch a github security
alert caused by depending upon an old version of x/net.

### 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

+ [Fix panic when interface not set in Solaris `netstat -rn` output.](https://github.com/jackpal/gateway/pull/42)

### v1.0.13

+ Add tools/check-cross-compile.sh to check that the code compiles for various OSs.
+ Fix compilation errors exposed by tools/check-cross-compile.sh.

### v1.0.12

+ If there are multiple default gateways, Windows now returns the gateway with the lowest metric.
+ Fix solaris build break. (In theory, IDK how to test this easily.)
+ Upgrade to golang 1.21
+ Upgrade golang.org/x/net version, makes dependabot happy. Probably was not any actual security
  issue because gateway doesn't use any of the APIs of golang.org/x/net that had security issues.

### v1.0.11

+ Implement DiscoverInterface for BSD-like OSes.

### v1.0.10

+ Fix non-BSD-based builds.
  

### v1.0.9

+ Add go.mod and go.sum files.
+ Use "golang.org/x/net/route" to implement all BSD variants.
  + As a side effect this adds support for Dragonfly and NetBSD. 
+ Add example to README.
+ Remove broken continuous integration.

### v1.0.8

+ Add support for OpenBSD
+ Linux parser now supports gateways with an IP address of 0.0.0.0
+ Fall back to `netstat` on darwin systems if `route` fails.
+ Simplify Linux /proc/net/route parsers.