Explorar el Código

configurable bind address + default port 8889

- Add host field to Config (default 0.0.0.0)
- Change default port from 8080 to 8889
- Listen on host:port instead of :port

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
master
Jan Svabenik hace 1 mes
padre
commit
3f1e245774
Se han modificado 2 ficheros con 7 adiciones y 4 borrados
  1. +2
    -1
      config.yaml.example
  2. +5
    -3
      internal/server/server.go

+ 2
- 1
config.yaml.example Ver fichero

@@ -1,4 +1,5 @@
port: 8080
host: "0.0.0.0" # bind address; use 127.0.0.1 to restrict to localhost
port: 8889


# Optional: full path to winamp.exe — only needed if you want roadamp to # Optional: full path to winamp.exe — only needed if you want roadamp to
# launch Winamp for you. Leave empty (or omit) if you start Winamp yourself. # launch Winamp for you. Leave empty (or omit) if you start Winamp yourself.


+ 5
- 3
internal/server/server.go Ver fichero

@@ -28,6 +28,7 @@ import (
// ── Config ──────────────────────────────────────────────────────────────────── // ── Config ────────────────────────────────────────────────────────────────────


type Config struct { type Config struct {
Host string `yaml:"host"`
Port int `yaml:"port"` Port int `yaml:"port"`
WinampPath string `yaml:"winamp_path"` WinampPath string `yaml:"winamp_path"`
KillListFile string `yaml:"killist_file"` KillListFile string `yaml:"killist_file"`
@@ -36,7 +37,8 @@ type Config struct {


func loadConfig(path string) (Config, error) { func loadConfig(path string) (Config, error) {
cfg := Config{ cfg := Config{
Port: 8080,
Host: "0.0.0.0",
Port: 8889,
KillListFile: "killist.dat", KillListFile: "killist.dat",
ResumeFile: "resume.dat", ResumeFile: "resume.dat",
} }
@@ -83,8 +85,8 @@ func (s *Server) Run() error {
go s.restoreResume() go s.restoreResume()
go s.killChecker() go s.killChecker()


addr := fmt.Sprintf(":%d", s.cfg.Port)
log.Printf("roadamp listening on http://localhost%s", addr)
addr := fmt.Sprintf("%s:%d", s.cfg.Host, s.cfg.Port)
log.Printf("roadamp listening on http://%s", addr)
return http.ListenAndServe(addr, s.mux) return http.ListenAndServe(addr, s.mux)
} }




Cargando…
Cancelar
Guardar