jackpal / gateway

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

Panics on Windows when there is no default gateway #5

Closed calmh closed 8 years ago

calmh commented 8 years ago

It tries to index into rows of output from "route print" that don't necessarily exist:

panic: runtime error: index out of range
goroutine 38788 [running]:
panic(0xb76840, 0xc082002020)
    c:/go/src/runtime/panic.go:481 +0x3f4
github.com/syncthing/syncthing/vendor/github.com/jackpal/gateway.DiscoverGateway(0x0, 0x0, 0x0, 0x0, 0x0)
    c:/jenkins/workspace/syncthing-release-windows/src/github.com/syncthing/syncthing/vendor/github.com/jackpal/gateway/gateway_windows.go:37 +0x4e6
github.com/syncthing/syncthing/lib/pmp.Discover(0x1a3185c5000, 0x2540be400, 0x0, 0x0, 0x0)
    c:/jenkins/workspace/syncthing-release-windows/src/github.com/syncthing/syncthing/lib/pmp/pmp.go:25 +0x48
github.com/syncthing/syncthing/lib/nat.discoverAll.func1(0x1a3185c5000, 0x2540be400, 0xc082218cc0, 0x30e3218, 0xc082e7a740, 0xdd8aa0)
    c:/jenkins/workspace/syncthing-release-windows/src/github.com/syncthing/syncthing/lib/nat/registry.go:32 +0x4c
created by github.com/syncthing/syncthing/lib/nat.discoverAll
    c:/jenkins/workspace/syncthing-release-windows/src/github.com/syncthing/syncthing/lib/nat/registry.go:36 +0x1bb

(https://github.com/syncthing/syncthing/issues/3142)