diff --git a/cmd/main.go b/cmd/main.go index 993f11a..93747c3 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,6 +7,7 @@ import ( "StoreBackEnd/pkg/protocol/repository" "StoreBackEnd/pkg/protocol/rules/readers" "StoreBackEnd/pkg/protocol/rules/writers" + "StoreBackEnd/pkg/utils" "time" ) @@ -15,7 +16,7 @@ const ( ) func main() { - //utils.NetworkLister() // TODO REMOVE + utils.NetworkLister() // TODO REMOVE println("StoreBackEnd started !") // Loading App config diff --git a/pkg/network/ClientMulticast.go b/pkg/network/ClientMulticast.go index 4ff5c0f..1bda350 100644 --- a/pkg/network/ClientMulticast.go +++ b/pkg/network/ClientMulticast.go @@ -81,18 +81,39 @@ func (client ClientMulticast) ResolveAddr() (*net.UDPAddr, bool) { } // ResolveInterfaceAddr Resolves the network interface address. -func ResolveInterfaceAddr(inter string) (*net.UDPAddr, bool) { // TODO Work in progress ! do not touch - i, err := net.InterfaceByName(inter) - if err != nil { - println(err.Error()) - return nil, true - } - addrs, _ := i.Addrs() - println("INFO ABOUT THE SELECTED INTERFACE (TEMPORAIRE)") - for a, v := range addrs { - println(a, v.(*net.IPNet).String()) - } +func ResolveInterfaceAddr(inter string) (*net.UDPAddr, bool) { + //i, err := net.InterfaceByName(inter) + //addrs, err := i.Addrs() + //println(addrs[0]) + //addr, err := net.ResolveUDPAddr("udp", addrs[0].String()) + //if err != nil { + // println(err.Error()) + // return nil, true + //} return nil, false + //var ipv4Addr net.IP + //ief, err := net.InterfaceByName(inter) + //if err != nil { + // println(err.Error()) + // return nil, true + //} + //addrs, err := ief.Addrs() + //if err != nil { + // println(err.Error()) + // return nil, true + //} + //for _, addr := range addrs { + // if ipv4Addr = addr.(*net.IPNet).IP; ipv4Addr != nil { + // break + // } + //} + //println(ipv4Addr.String()) + //addr, err := net.ResolveUDPAddr("udp", ipv4Addr.String()) + //if err != nil { + // println(err.Error()) + // return nil, true + //} + //return addr, false } // DialUdp Ouvre une connection UDP