From a72fc63c06e56c27c64ca474294bb3b8d40daffc Mon Sep 17 00:00:00 2001 From: bjd Date: Mon, 11 Jan 2021 18:45:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dui=E8=B7=AF=E5=BE=84404?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++------ admin/api_base.go | 2 +- admin/server.go | 11 +++++------ base/cfg_server.go | 1 + 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 2636e1a..ea47119 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ AnyLink 服务端仅在CentOS7测试通过,如需要安装在其他系统, ## Installation -> 升级 go version = 1.16 +> 升级 go version = 1.15 ```shell git clone https://github.com/bjdgyc/anylink.git @@ -101,13 +101,12 @@ iptables -t nat -A POSTROUTING -s 192.168.10.0/255.255.255.0 -o eth0 -j MASQUERA 1. 创建桥接网卡 ``` -注意 server.toml 的ip参数,需要与 bridge.sh 的配置参数一致 +注意 server.toml 的ip参数,需要与 bridge-init.sh 的配置参数一致 ``` -2. 修改 bridge.sh 内的参数 +2. 修改 bridge-init.sh 内的参数 ``` -# file: ./bridge.sh eth="eth0" eth_ip="192.168.1.4" eth_netmask="255.255.255.0" @@ -115,10 +114,10 @@ eth_broadcast="192.168.1.255" eth_gateway="192.168.1.1" ``` -3. 执行 bridge.sh 文件 +3. 执行 bridge-init.sh 文件 ``` -sh bridge.sh +sh bridge-init.sh ``` ## Soft diff --git a/admin/api_base.go b/admin/api_base.go index 38a41a0..ab7bb46 100644 --- a/admin/api_base.go +++ b/admin/api_base.go @@ -56,7 +56,7 @@ func authMiddleware(next http.Handler) http.Handler { route := mux.CurrentRoute(r) name := route.GetName() // fmt.Println("bb", r.URL.Path, name) - if name == "login" || name == "static" { + if utils.InArrStr([]string{"login", "index", "static"}, name) { // 不进行鉴权 next.ServeHTTP(w, r) return diff --git a/admin/server.go b/admin/server.go index 2b2ad62..b3d6f4f 100644 --- a/admin/server.go +++ b/admin/server.go @@ -15,13 +15,12 @@ func StartAdmin() { r := mux.NewRouter() r.Use(authMiddleware) - r.Handle("/", http.RedirectHandler("/ui/", http.StatusFound)). - Name("static") - r.PathPrefix("/ui/").Handler(http.FileServer( - http.Dir(base.Cfg.UiPath), - )).Name("static") - + r.Handle("/", http.RedirectHandler("/ui/", http.StatusFound)).Name("index") + r.PathPrefix("/ui/").Handler( + http.StripPrefix("/ui/", http.FileServer(http.Dir(base.Cfg.UiPath))), + ).Name("static") r.HandleFunc("/base/login", Login).Name("login") + r.HandleFunc("/set/home", SetHome) r.HandleFunc("/set/system", SetSystem) r.HandleFunc("/set/soft", SetSoft) diff --git a/base/cfg_server.go b/base/cfg_server.go index 63cd41b..bda9397 100644 --- a/base/cfg_server.go +++ b/base/cfg_server.go @@ -83,6 +83,7 @@ func initServerCfg() { Cfg.DbFile = getAbsPath(base, Cfg.DbFile) Cfg.CertFile = getAbsPath(base, Cfg.CertFile) Cfg.CertKey = getAbsPath(base, Cfg.CertKey) + Cfg.UiPath = getAbsPath(base, Cfg.UiPath) Cfg.DownFilesPath = getAbsPath(base, Cfg.DownFilesPath) if len(Cfg.JwtSecret) < 20 {