Musique - mDNS resolution integration

This commit is contained in:
Robert Bendun 2023-01-02 06:34:54 +01:00
parent 95a28723fd
commit 37bc4e87b3
2 changed files with 10 additions and 6 deletions

View File

@ -224,7 +224,7 @@ func myAddressInTheSameNetwork(remote string) (string, error) {
for _, addr := range addrs { for _, addr := range addrs {
ip, ipNet, err := net.ParseCIDR(addr.String()) ip, ipNet, err := net.ParseCIDR(addr.String())
if err == nil && ipNet.Contains(remoteIP) { if err == nil && ipNet.Contains(remoteIP) {
return ip.String(), nil return fmt.Sprintf("%s:%d", ip, port), nil
} }
} }

View File

@ -32,6 +32,12 @@ func ServerInit(inputNick string, inputPort int) {
log.Fatalln(err) log.Fatalln(err)
} }
_, err = registerDNS()
if err != nil {
log.Fatalln("Failed to register DNS:", err)
}
// defer server.Shutdown()
if err := registerRemotes(initialWaitingTime); err != nil { if err := registerRemotes(initialWaitingTime); err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
@ -55,12 +61,10 @@ func ServerBeginProtocol() {
//export Discover //export Discover
func Discover() { func Discover() {
if len(remotes) == 0 { if err := registerRemotes(userRequestedWatingingTime); err != nil {
if err := registerRemotes(userRequestedWatingingTime); err != nil { log.Println("discover:", err)
log.Println("discover:", err)
}
} }
synchronizeHostsWithRemotes() // synchronizeHostsWithRemotes()
} }
//export ListKnownRemotes //export ListKnownRemotes