diff --git a/he-ipv6-tunnel.sh b/he-ipv6-tunnel.sh index e3a6877..23ddee6 100755 --- a/he-ipv6-tunnel.sh +++ b/he-ipv6-tunnel.sh @@ -28,10 +28,15 @@ # ifconfig sit1 inet6 add 2001:470:1f10:2a::2/64 # route -A inet6 add ::/0 dev sit1 +if [ "$1" = "down" ]; then + ip tunnel del he-ipv6 + rmmod sit + exit +fi + modprobe ipv6 ip tunnel add he-ipv6 mode sit remote 184.105.253.14 local 74.87.91.117 ttl 255 ip link set he-ipv6 up ip addr add 2001:470:1f10:2a::2/64 dev he-ipv6 ip route add ::/0 dev he-ipv6 ip -f inet6 addr - diff --git a/net.go b/net.go index 9c124bc..65e9222 100644 --- a/net.go +++ b/net.go @@ -27,6 +27,7 @@ func watchNetworkInterfaces() { log.Println("something on i =", i) } } + log.Println("forever loop") } }() } @@ -51,6 +52,7 @@ func inotifyNetworkInterfaceChanges() error { // Do something on network interface creation } case err := <-watcher.Errors: + log.Println("inotifyNetworkInterfaceChanges() event err =", err) return err } } @@ -60,6 +62,16 @@ func IsIPv6(address string) bool { return strings.Count(address, ":") >= 2 } +func IsReal(ip *net.IP) bool { + if (ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast()) { + log.Println("\t\tIP is Real = false") + return false + } else { + log.Println("\t\tIP is Real = true") + return true + } +} + func scanInterfaces() { ifaces, _ := net.Interfaces() spew.Dump(ifaces) @@ -84,14 +96,14 @@ func scanInterfaces() { } else { log.Println("\t\tIP is IPv4") } + if (IsReal(&ip)) { + log.Println("\t\tIP is Real = true") + } else { + log.Println("\t\tIP is Real = false") + } log.Println("\t\tIP is IsPrivate() =", ip.IsPrivate()) log.Println("\t\tIP is IsLoopback() =", ip.IsLoopback()) log.Println("\t\tIP is IsLinkLocalUnicast() =", ip.IsLinkLocalUnicast()) - if (ip.IsPrivate() || ip.IsLoopback() || ip.IsLinkLocalUnicast()) { - log.Println("\t\tIP is Real = false") - } else { - log.Println("\t\tIP is Real = true") - } // log.Println("\t\tIP is () =", ip.()) default: log.Println("\t\taddr.(type) = NO IDEA WHAT TO DO HERE v =", v)