Skip to content

Commit

Permalink
Sync http and upnp server ip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustinmj committed Sep 21, 2017
1 parent e866e02 commit 820408c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
8 changes: 3 additions & 5 deletions server/upnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 820408c

Please sign in to comment.