From 632080c1d69e7ed5439ff3d5152b49c414029463 Mon Sep 17 00:00:00 2001 From: bjdgy Date: Fri, 15 Mar 2024 22:33:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20profile=20name(=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E5=8C=BA=E5=88=86=E4=B8=8D=E5=90=8C=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- server/base/cfg.go | 1 + server/base/config.go | 1 + server/conf/server-sample.toml | 2 ++ server/handler/link_auth.go | 5 +++-- server/handler/server.go | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8c663a1..1df61f7 100644 --- a/README.md +++ b/README.md @@ -420,7 +420,8 @@ ipv4_end = "10.1.2.200" - [AnyConnect Secure Client](https://www.cisco.com/) (可通过群文件下载: Windows/macOS/Linux/Android/iOS) - [OpenConnect](https://gitlab.com/openconnect/openconnect) (Windows/macOS/Linux) -- [AnyLink Secure Client](https://github.com/tlslink/anylink-client) (Windows/macOS/Linux) +- [三方 AnyLink Secure Client](https://github.com/tlslink/anylink-client) (Windows/macOS/Linux) +- [三方客户端下载地址](https://cisco.yangpin.link) (Windows/macOS/Linux/Android/iOS) ## Contribution diff --git a/server/base/cfg.go b/server/base/cfg.go index e211d0a..53d9a85 100644 --- a/server/base/cfg.go +++ b/server/base/cfg.go @@ -33,6 +33,7 @@ type ServerConfig struct { // LinkAddr string `json:"link_addr"` Conf string `json:"conf"` Profile string `json:"profile"` + ProfileName string `json:"profile_name"` ServerAddr string `json:"server_addr"` ServerDTLSAddr string `json:"server_dtls_addr"` ServerDTLS bool `json:"server_dtls"` diff --git a/server/base/config.go b/server/base/config.go index be82533..4623cdb 100644 --- a/server/base/config.go +++ b/server/base/config.go @@ -22,6 +22,7 @@ type config struct { var configs = []config{ {Typ: cfgStr, Name: "conf", Usage: "config file", ValStr: "./conf/server.toml", Short: "c"}, {Typ: cfgStr, Name: "profile", Usage: "profile.xml file", ValStr: "./conf/profile.xml"}, + {Typ: cfgStr, Name: "profile_name", Usage: "profile name(用于区分不同网站的配置)", ValStr: "anylink"}, {Typ: cfgStr, Name: "server_addr", Usage: "TCP服务监听地址(任意端口)", ValStr: ":443"}, {Typ: cfgBool, Name: "server_dtls", Usage: "开启DTLS", ValBool: false}, {Typ: cfgStr, Name: "server_dtls_addr", Usage: "DTLS监听地址(任意端口)", ValStr: ":443"}, diff --git a/server/conf/server-sample.toml b/server/conf/server-sample.toml index 6b09098..41b3cd0 100644 --- a/server/conf/server-sample.toml +++ b/server/conf/server-sample.toml @@ -11,6 +11,8 @@ cert_file = "./conf/vpn_cert.pem" cert_key = "./conf/vpn_cert.key" files_path = "./conf/files" profile = "./conf/profile.xml" +#profile name(用于区分不同网站的配置) +profile_name = "anylink" #日志目录,为空写入标准输出 #log_path = "./log" log_path = "" diff --git a/server/handler/link_auth.go b/server/handler/link_auth.go index 15db11b..6cd5dc0 100644 --- a/server/handler/link_auth.go +++ b/server/handler/link_auth.go @@ -137,7 +137,7 @@ func LinkAuth(w http.ResponseWriter, r *http.Request) { other := &dbdata.SettingOther{} _ = dbdata.SettingGet(other) rd := RequestData{SessionId: sess.Sid, SessionToken: sess.Sid + "@" + sess.Token, - Banner: other.Banner, ProfileHash: profileHash} + Banner: other.Banner, ProfileName: base.Cfg.ProfileName, ProfileHash: profileHash} w.WriteHeader(http.StatusOK) tplRequest(tpl_complete, w, rd) base.Debug("login", cr.Auth.Username, userAgent) @@ -175,6 +175,7 @@ type RequestData struct { SessionId string SessionToken string Banner string + ProfileName string ProfileHash string } @@ -227,7 +228,7 @@ var auth_complete = ` - /profile.xml + /profile_{{.ProfileName}}.xml {{.ProfileHash}} diff --git a/server/handler/server.go b/server/handler/server.go index 8137c3a..a378951 100644 --- a/server/handler/server.go +++ b/server/handler/server.go @@ -98,7 +98,7 @@ func initRoute() http.Handler { r.HandleFunc("/", LinkAuth).Methods(http.MethodPost) r.HandleFunc("/CSCOSSLC/tunnel", LinkTunnel).Methods(http.MethodConnect) r.HandleFunc("/otp_qr", LinkOtpQr).Methods(http.MethodGet) - r.HandleFunc("/profile.xml", func(w http.ResponseWriter, r *http.Request) { + r.HandleFunc(fmt.Sprintf("/profile_%s.xml", base.Cfg.ProfileName), func(w http.ResponseWriter, r *http.Request) { b, _ := os.ReadFile(base.Cfg.Profile) w.Write(b) }).Methods(http.MethodGet)