support bind address, fix https://github.com/marcopeocchi/yt-dlp-web-ui/issues/108 (#109)
This commit is contained in:
@@ -167,6 +167,8 @@ Usage yt-dlp-webui:
|
|||||||
yt-dlp executable path (default "yt-dlp")
|
yt-dlp executable path (default "yt-dlp")
|
||||||
-out string
|
-out string
|
||||||
Where files will be saved (default ".")
|
Where files will be saved (default ".")
|
||||||
|
-host string
|
||||||
|
Host where server will listen at (default "0.0.0.0")
|
||||||
-port int
|
-port int
|
||||||
Port where server will listen at (default 3033)
|
Port where server will listen at (default 3033)
|
||||||
-qs int
|
-qs int
|
||||||
|
|||||||
5
main.go
5
main.go
@@ -14,6 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
host string
|
||||||
port int
|
port int
|
||||||
queueSize int
|
queueSize int
|
||||||
configFile string
|
configFile string
|
||||||
@@ -36,6 +37,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
flag.StringVar(&host, "host", "0.0.0.0", "Host where server will listen at")
|
||||||
flag.IntVar(&port, "port", 3033, "Port where server will listen at")
|
flag.IntVar(&port, "port", 3033, "Port where server will listen at")
|
||||||
flag.IntVar(&queueSize, "qs", runtime.NumCPU(), "Download queue size")
|
flag.IntVar(&queueSize, "qs", runtime.NumCPU(), "Download queue size")
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ func main() {
|
|||||||
|
|
||||||
c := config.Instance()
|
c := config.Instance()
|
||||||
|
|
||||||
|
c.Host = host
|
||||||
c.Port = port
|
c.Port = port
|
||||||
c.QueueSize = queueSize
|
c.QueueSize = queueSize
|
||||||
c.DownloadPath = downloadPath
|
c.DownloadPath = downloadPath
|
||||||
@@ -76,5 +79,5 @@ func main() {
|
|||||||
log.Println(cli.BgRed, "config", cli.Reset, "no config file found")
|
log.Println(cli.BgRed, "config", cli.Reset, "no config file found")
|
||||||
}
|
}
|
||||||
|
|
||||||
server.RunBlocking(port, frontend, localDatabasePath)
|
server.RunBlocking(host, port, frontend, localDatabasePath)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Host string `yaml:"host"`
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
DownloadPath string `yaml:"downloadPath"`
|
DownloadPath string `yaml:"downloadPath"`
|
||||||
DownloaderPath string `yaml:"downloaderPath"`
|
DownloaderPath string `yaml:"downloaderPath"`
|
||||||
|
|||||||
@@ -28,13 +28,14 @@ import (
|
|||||||
|
|
||||||
type serverConfig struct {
|
type serverConfig struct {
|
||||||
frontend fs.FS
|
frontend fs.FS
|
||||||
|
host string
|
||||||
port int
|
port int
|
||||||
mdb *internal.MemoryDB
|
mdb *internal.MemoryDB
|
||||||
db *sql.DB
|
db *sql.DB
|
||||||
mq *internal.MessageQueue
|
mq *internal.MessageQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunBlocking(port int, frontend fs.FS, dbPath string) {
|
func RunBlocking(host string, port int, frontend fs.FS, dbPath string) {
|
||||||
var mdb internal.MemoryDB
|
var mdb internal.MemoryDB
|
||||||
mdb.Restore()
|
mdb.Restore()
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ func RunBlocking(port int, frontend fs.FS, dbPath string) {
|
|||||||
|
|
||||||
srv := newServer(serverConfig{
|
srv := newServer(serverConfig{
|
||||||
frontend: frontend,
|
frontend: frontend,
|
||||||
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
mdb: &mdb,
|
mdb: &mdb,
|
||||||
mq: mq,
|
mq: mq,
|
||||||
@@ -99,7 +101,7 @@ func newServer(c serverConfig) *http.Server {
|
|||||||
r.Route("/api/v1", rest.ApplyRouter(c.db, c.mdb, c.mq))
|
r.Route("/api/v1", rest.ApplyRouter(c.db, c.mdb, c.mq))
|
||||||
|
|
||||||
return &http.Server{
|
return &http.Server{
|
||||||
Addr: fmt.Sprintf(":%d", c.port),
|
Addr: fmt.Sprintf("%s:%d", c.host, c.port),
|
||||||
Handler: r,
|
Handler: r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user