diff --git a/netcard.go b/netcard.go index 918cfcf..f9949ae 100644 --- a/netcard.go +++ b/netcard.go @@ -20,7 +20,9 @@ import ( ) type NetTunnel struct { - ifce *water.Interface + ifce *water.Interface + ifmac []byte + shutdown *perfectshutdown.PerfectShutdown writer chan []byte reader chan []byte @@ -78,6 +80,17 @@ func NewNetTunnel() *NetTunnel { log.Panic(err) } + ifas, err := net.Interfaces() + if err != nil { + log.Panic(err) + } + + for _, ifa := range ifas { + if ifa.Name == nt.ifce.Name() { + nt.ifmac = ifa.HardwareAddr[0:6] + } + } + go func() { for rbuf := range nt.reader { @@ -134,6 +147,7 @@ func NewNetTunnel() *NetTunnel { for wbuf := range nt.writer { var frame ethernet.Frame = wbuf log.Printf("ifce write %d", len(frame)) + copy(frame[0:6], nt.ifmac) _, err := nt.ifce.Write(frame) if err != nil { log.Println(err)