diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-11 23:44:53 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-11 23:47:53 -0400 |
| commit | 3156765985f2e7ad7b533c893de9d5ce56aab0ee (patch) | |
| tree | c7f2e08892ce675ee5f0ec30e57043ea1e1ef5df /cmd/web/util.go | |
| parent | 705fc2f44be5528b07897cd2f020f429024cddf0 (diff) | |
| download | steam-export-3156765985f2e7ad7b533c893de9d5ce56aab0ee.tar.gz steam-export-3156765985f2e7ad7b533c893de9d5ce56aab0ee.tar.xz | |
Add a Windows specific function to scrape the route table for the IP address from the default route.
Diffstat (limited to 'cmd/web/util.go')
| -rw-r--r-- | cmd/web/util.go | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/cmd/web/util.go b/cmd/web/util.go index 454912f..294079c 100644 --- a/cmd/web/util.go +++ b/cmd/web/util.go @@ -57,39 +57,6 @@ func getShareLink() string { return fmt.Sprintf("http://%s:%s/", GetHostIP(), getPort()) } -// GetHostIP attempts to guess the IP address of the current machine and -// returns that. Simply bails at the first non sane looking IP and returns it. -// Not ideal but it should work well enough most of the time -func GetHostIP() string { - iFaces, err := net.Interfaces() - if err != nil { - return "127.0.0.1" - } - - // RFC 3927 - _, ipv4LinkLocal, _ := net.ParseCIDR("169.254.0.0/16") - - for _, iFace := range iFaces { - addrs, err := iFace.Addrs() - if err != nil { - continue - } - - for _, a := range addrs { - n, ok := a.(*net.IPNet) - if !ok { - continue - } - - if n.IP.To4() != nil && !n.IP.IsLoopback() && !ipv4LinkLocal.Contains(n.IP.To4()) { - return n.IP.String() - } - } - } - - return "127.0.0.1" -} - func getPort() string { s := strings.Split(Listen, ":") |
