This commit is contained in:
crusader 2018-10-23 02:45:28 +09:00
parent 58b2bb2fa3
commit c308511750
4 changed files with 22 additions and 16 deletions

11
nic/nic.go Normal file
View File

@ -0,0 +1,11 @@
package nic
import (
"net"
oung "git.loafle.net/overflow/util-go/net/gateway"
)
func DiscoverGateway() (net.IP, string, error) {
return oung.DiscoverGateway()
}

View File

@ -7,13 +7,8 @@ import (
omm "git.loafle.net/overflow/model/meta" omm "git.loafle.net/overflow/model/meta"
omn "git.loafle.net/overflow/model/net" omn "git.loafle.net/overflow/model/net"
oun "git.loafle.net/overflow/util-go/net" oun "git.loafle.net/overflow/util-go/net"
oung "git.loafle.net/overflow/util-go/net/gateway"
) )
func DiscoverGateway() (net.IP, string, error) {
return oung.DiscoverGateway()
}
func DiscoverInterfaces() ([]*omn.Interface, error) { func DiscoverInterfaces() ([]*omn.Interface, error) {
gwIP, gwIface, err := DiscoverGateway() gwIP, gwIface, err := DiscoverGateway()
if nil != err { if nil != err {
@ -32,6 +27,10 @@ func DiscoverInterfaces() ([]*omn.Interface, error) {
continue continue
} }
if isDockerInterface(&netIface) {
continue
}
iface := &omn.Interface{} iface := &omn.Interface{}
ifaces = append(ifaces, iface) ifaces = append(ifaces, iface)

View File

@ -7,13 +7,8 @@ import (
omm "git.loafle.net/overflow/model/meta" omm "git.loafle.net/overflow/model/meta"
omn "git.loafle.net/overflow/model/net" omn "git.loafle.net/overflow/model/net"
oun "git.loafle.net/overflow/util-go/net" oun "git.loafle.net/overflow/util-go/net"
oung "git.loafle.net/overflow/util-go/net/gateway"
) )
func DiscoverGateway() (net.IP, string, error) {
return oung.DiscoverGateway()
}
func DiscoverInterfaces() ([]*omn.Interface, error) { func DiscoverInterfaces() ([]*omn.Interface, error) {
gwIP, gwIface, err := DiscoverGateway() gwIP, gwIface, err := DiscoverGateway()
if nil != err { if nil != err {

View File

@ -3,20 +3,15 @@ package nic
import ( import (
"log" "log"
"net" "net"
"strconv"
"strings" "strings"
omm "git.loafle.net/overflow/model/meta" omm "git.loafle.net/overflow/model/meta"
omn "git.loafle.net/overflow/model/net" omn "git.loafle.net/overflow/model/net"
oun "git.loafle.net/overflow/util-go/net" oun "git.loafle.net/overflow/util-go/net"
oung "git.loafle.net/overflow/util-go/net/gateway"
"github.com/google/gopacket/pcap" "github.com/google/gopacket/pcap"
) )
func DiscoverGateway() (net.IP, string, error) {
return oung.DiscoverGateway()
}
func DiscoverInterfaces() ([]*omn.Interface, error) { func DiscoverInterfaces() ([]*omn.Interface, error) {
gwIP, gwIface, err := DiscoverGateway() gwIP, gwIface, err := DiscoverGateway()
if nil != err { if nil != err {
@ -35,6 +30,10 @@ func DiscoverInterfaces() ([]*omn.Interface, error) {
continue continue
} }
if isDockerInterface(&netIface) {
continue
}
iface := &omn.Interface{} iface := &omn.Interface{}
ifaces = append(ifaces, iface) ifaces = append(ifaces, iface)
@ -42,6 +41,8 @@ func DiscoverInterfaces() ([]*omn.Interface, error) {
iface.Mac = netIface.HardwareAddr.String() iface.Mac = netIface.HardwareAddr.String()
iface.Addresses = make([]*omn.InterfaceAddress, 0) iface.Addresses = make([]*omn.InterfaceAddress, 0)
log.Print(strconv.ParseInt(string(netIface.HardwareAddr), 10, 64))
netAddrs, err := netIface.Addrs() netAddrs, err := netIface.Addrs()
if nil != err { if nil != err {
continue continue