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

Will not working on windows of non-Englisht language #19

Closed chengxuncc closed 5 years ago

chengxuncc commented 5 years ago

In gateway_common.go:

func parseWindowsRoutePrint(output []byte) (net.IP, error) {
    lines := strings.Split(string(output), "\n")
    for idx, line := range lines {
        if strings.HasPrefix(line, "Active Routes:") {
            if len(lines) <= idx+2 {
                return nil, errNoGateway
            }
...

If default language is non-English, "Active Routes" will be translated.

puyangsky commented 5 years ago

same problem

ndeloof commented 5 years ago

Here is the typical output of the route command on Windows 10 configured with French locale:

IPv4 Table de routage
===========================================================================
Itinéraires actifs :
Destination réseau    Masque réseau  Adr. passerelle   Adr. interface Métrique
          0.0.0.0          0.0.0.0      192.168.8.1    192.168.8.101     35
===========================================================================