From 514409abdab8c00e8d965e669ae165e1301e1f77 Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Tue, 15 May 2018 03:07:05 +0900 Subject: [PATCH] =?UTF-8?q?nil=20=E3=85=82=E3=85=93=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- octopus-outside/main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/octopus-outside/main.go b/octopus-outside/main.go index 3e87989..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 ")