From a987a7eb64a8854d6b54f85f9361fede0cdd94f5 Mon Sep 17 00:00:00 2001 From: EndMove Date: Tue, 8 Mar 2022 19:41:54 +0100 Subject: [PATCH] =?UTF-8?q?Tentative=20d'impl=C3=A9mentation=20syst=C3=A8m?= =?UTF-8?q?e=20d'interface=20->=20toujours=20en=20=C3=A9chec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main.go | 3 ++- pkg/network/ClientMulticast.go | 43 +++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) 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