From 03f5a547648cb6551340d7028288155103288a35 Mon Sep 17 00:00:00 2001 From: Peven Date: Wed, 17 Mar 2021 18:08:22 +0800 Subject: [PATCH 1/2] allow to set address in configuration file --- bootstrap/cmd.go | 3 ++- conf/config.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bootstrap/cmd.go b/bootstrap/cmd.go index 65550120..6cc3cec0 100644 --- a/bootstrap/cmd.go +++ b/bootstrap/cmd.go @@ -3,6 +3,7 @@ package bootstrap import ( "flag" "fmt" + "github.com/Xhofe/alist/conf" serv "github.com/Xhofe/alist/server" "github.com/gin-gonic/gin" @@ -71,7 +72,7 @@ func start() { // start http server func server() { - baseServer := "0.0.0.0:" + conf.Conf.Server.Port + baseServer := conf.Conf.Server.Address + ":" + conf.Conf.Server.Port r := gin.Default() serv.InitRouter(r) log.Infof("Starting server @ %s", baseServer) diff --git a/conf/config.go b/conf/config.go index 0d10d5bf..7d330b22 100644 --- a/conf/config.go +++ b/conf/config.go @@ -31,6 +31,7 @@ type Config struct { } `yaml:"preview" json:"preview"` } `yaml:"info"` Server struct { + Address string `yaml:"address"` Port string `yaml:"port"` //端口 Search bool `yaml:"search"` //允许搜索 Static string `yaml:"static"` From 9561f0c9513311bccf68c4aaa8e717a1a46ef8ab Mon Sep 17 00:00:00 2001 From: Peven Date: Wed, 17 Mar 2021 18:25:20 +0800 Subject: [PATCH 2/2] update conf.yml.example --- conf.yml.example | 1 + 1 file changed, 1 insertion(+) diff --git a/conf.yml.example b/conf.yml.example index f14df09b..eb1e5643 100644 --- a/conf.yml.example +++ b/conf.yml.example @@ -10,6 +10,7 @@ info: preview: text: [txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp] #要预览的文本文件的后缀,可以自行添加 server: + address: "0.0.0.0" port: "5244" search: true static: dist