Skip to content

Commit

Permalink
Change http port
Browse files Browse the repository at this point in the history
  • Loading branch information
ChienNM3 committed Jan 24, 2024
1 parent 9cb4881 commit 937659b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"embed"
"errors"
"fmt"
"log"
"log/slog"
"net/http"
Expand All @@ -18,6 +19,10 @@ import (
"TorPlayer2/torrent"
)

const (
openPort = 19576
)

//go:embed static
var fs embed.FS

Expand Down Expand Up @@ -53,12 +58,12 @@ func main() {
httpHandler.Register(r)

httpServer := &http.Server{
Addr: ":8080",
Addr: fmt.Sprintf(":%d", openPort),
Handler: r,
}
closeFns = append(closeFns, closeFn{"http server", httpServer.Close})
go func() {
slog.Info("Starting server on port 8080\n")
slog.With("port", openPort).Info("Starting server")
if err := httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatalf("Failed to start server: %v", err)
}
Expand All @@ -72,15 +77,14 @@ func main() {
}
}

systray.Run(setupOnReady("http://localhost:8080"), onExit)

systray.Run(setupOnReady(fmt.Sprintf("http://localhost:%d", openPort)), onExit)
}

func setupOnReady(serverAddr string) func() {
return func() {
systray.SetIcon(appIcon)
systray.SetTitle("TorPlayer2")
systray.SetTooltip("TorPlayer2")
systray.SetTitle("TorPlayer")
systray.SetTooltip("TorPlayer")
mOpenBrowser := systray.AddMenuItem("Open Torplay web", "Open Torplay in browser")
systray.AddSeparator()
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
Expand Down

0 comments on commit 937659b

Please sign in to comment.