diff --git a/server/server.go b/server/server.go index f8d09de..7225d08 100644 --- a/server/server.go +++ b/server/server.go @@ -103,7 +103,7 @@ func Serve() error { mPort = p baseURI = fmt.Sprintf("http://%v%v", ip, p) ttsEndpoint = fmt.Sprintf("%v/%v/polly/", baseURI, mPath) - go StartUPNP(mPort) // create upnp server now that we know port + go StartUPNP(mPort, ip) // create upnp server now that we know port coms.Msg(fmt.Sprintf("Instructions/Options: visit %v in a browser.", baseURI)) if err := http.ListenAndServe(p, sMux); err != nil { return errors.New("Cannot create webserver. " + err.Error()) diff --git a/server/upnp.go b/server/upnp.go index 83e79bc..63e7872 100644 --- a/server/upnp.go +++ b/server/upnp.go @@ -46,24 +46,22 @@ func init() { } //StartUPNP - Start the UPNP server -func StartUPNP(ttsPort string) { +func StartUPNP(ttsPort string, ip string) { go func() { defer func() { sig <- 1 }() - cast(ttsPort) + cast(ttsPort, ip) }() } -func cast(ttsPort string) error { +func cast(ttsPort string, ip string) error { s, err := gossdp.NewSsdp(nil) if err != nil { return err } defer s.Stop() go s.Start() - // store ip for future checks - ip = getOutboundIP().String() // create server defaults serverDef := defs(ip, ttsPort) s.AdvertiseServer(serverDef) // library re-adverts correctly