diff --git a/octopus-outside/main.go b/octopus-outside/main.go index 01a4aac..e6658f9 100644 --- a/octopus-outside/main.go +++ b/octopus-outside/main.go @@ -180,7 +180,12 @@ func getSubnetIPInfo(ip net.IP, verbose bool) (gw net.IP, cidr uint64, linkname if verbose { fmt.Printf(" routing table %s\n", route.String()) } - if route.Dst.Contains(ip) { + + if route.Dst == nil { + if verbose { + fmt.Printf(" - default gateway : no one!\n") + } + } else if route.Dst.Contains(ip) { if verbose { fmt.Printf(" - matched routing role : %s\n", route.String()) } @@ -191,13 +196,21 @@ func getSubnetIPInfo(ip net.IP, verbose bool) (gw net.IP, cidr uint64, linkname } } + if matchedRoute == nil { + if verbose { + fmt.Println(" - cannot getting routing rule") + fmt.Println(" abandon this interface ") + } + continue + } if cidrData, err := getCidr(*matchedRoute.Dst); err == nil { cidr = cidrData if verbose { fmt.Printf(" interface have a subnet routing rule. gateway: %s", matchedRoute) fmt.Println(" ok! matched ") } - gw, cidr, linkname = matchedRoute.Gw, cidrData, attrs.Name + gw, cidr, linkname = matchedRoute.Src, cidrData, attrs.Name + break } else if verbose { fmt.Printf(" - cannot getting netmask : %s", err) fmt.Println(" abandon this interface ") @@ -508,8 +521,8 @@ func main() { option = append(option, fmt.Sprintf("--setenv=GATEWAY_ADDR=%s", gw.String())) option = append(option, fmt.Sprintf("--machine=%s", nodeName)) option = append(option, fmt.Sprintf("--directory=%s", filepath.Join(nodePath, "merge"))) - # option = append(option, "--keep-unit", "--register=yes", "--settings=override", "--private-users=1354956800:65536", "--private-users-chown") - option = append(option, "--keep-unit", "--register=yes", "--settings=override") +// option = append(option, "--keep-unit", "--register=yes", "--settings=override", "--private-users=1354956800:65536", "--private-users-chown") + option = append(option, "--keep-unit", "--register=yes", "--settings=override") for _, mountPoint := range config.MoundPoint { if mountOption, err := mountPoint.Option(nodePath); err != nil {