mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-11 01:48:02 +08:00
升级go version 1.16,ui文件嵌入go二进制内
This commit is contained in:
@@ -2,6 +2,7 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -14,6 +15,17 @@ import (
|
||||
)
|
||||
|
||||
func LinkAuth(w http.ResponseWriter, r *http.Request) {
|
||||
// 判断anyconnect客户端
|
||||
userAgent := strings.ToLower(r.UserAgent())
|
||||
x_Aggregate_Auth := r.Header.Get("X-Aggregate-Auth")
|
||||
x_Transcend_Version := r.Header.Get("X-Transcend-Version")
|
||||
if !(strings.Contains(userAgent, "anyconnect") &&
|
||||
x_Aggregate_Auth == "1" && x_Transcend_Version == "1") {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
fmt.Fprintf(w, "error request")
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
@@ -20,7 +20,7 @@ func LinkCstp(conn net.Conn, cSess *sessdata.ConnSession) {
|
||||
err error
|
||||
n int
|
||||
dataLen uint16
|
||||
dead = time.Duration(cSess.CstpDpd*2) * time.Second
|
||||
dead = time.Duration(cSess.CstpDpd+5) * time.Second
|
||||
)
|
||||
|
||||
go cstpWrite(conn, cSess)
|
||||
|
@@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/bjdgyc/anylink/base"
|
||||
"github.com/bjdgyc/anylink/dbdata"
|
||||
"github.com/bjdgyc/anylink/sessdata"
|
||||
)
|
||||
|
||||
@@ -51,7 +50,7 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
||||
masterSecret := r.Header.Get("X-DTLS-Master-Secret")
|
||||
localIp := r.Header.Get("X-Cstp-Local-Address-Ip4")
|
||||
mobile := r.Header.Get("X-Cstp-License")
|
||||
platform := r.Header.Get("X-AnyConnect-Identifier-Platform")
|
||||
|
||||
cSess.SetMtu(cstpMtu)
|
||||
cSess.MasterSecret = masterSecret
|
||||
cSess.RemoteAddr = r.RemoteAddr
|
||||
@@ -67,12 +66,6 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
cSess.CstpDpd = cstpDpd
|
||||
|
||||
// iPhone手机需要最少一个dns
|
||||
if platform == "apple-ios" && len(cSess.Group.ClientDns) == 0 {
|
||||
dnsVal := dbdata.ValData{Val: "114.114.114.114"}
|
||||
cSess.Group.ClientDns = append(cSess.Group.ClientDns, dnsVal)
|
||||
}
|
||||
|
||||
base.Debug(cSess.IpAddr, cSess.MacHw, sess.Username, mobile)
|
||||
|
||||
// 返回客户端数据
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/bjdgyc/anylink/base"
|
||||
@@ -18,6 +19,7 @@ func startTls() {
|
||||
certFile := base.Cfg.CertFile
|
||||
keyFile := base.Cfg.CertKey
|
||||
|
||||
logger := log.New(os.Stdout, "[SERVER]", log.Lshortfile|log.Ldate)
|
||||
// 设置tls信息
|
||||
tlsConfig := &tls.Config{
|
||||
NextProtos: []string{"http/1.1"},
|
||||
@@ -27,6 +29,7 @@ func startTls() {
|
||||
Addr: addr,
|
||||
Handler: initRoute(),
|
||||
TLSConfig: tlsConfig,
|
||||
ErrorLog: logger,
|
||||
}
|
||||
|
||||
var ln net.Listener
|
||||
@@ -50,13 +53,13 @@ func startTls() {
|
||||
|
||||
func initRoute() http.Handler {
|
||||
r := mux.NewRouter()
|
||||
// r.HandleFunc("/", checkLinkClient(LinkHome)).Methods(http.MethodGet)
|
||||
r.HandleFunc("/", checkLinkClient(LinkAuth)).Methods(http.MethodPost)
|
||||
r.HandleFunc("/", LinkHome).Methods(http.MethodGet)
|
||||
r.HandleFunc("/", LinkAuth).Methods(http.MethodPost)
|
||||
r.HandleFunc("/CSCOSSLC/tunnel", LinkTunnel).Methods(http.MethodConnect)
|
||||
r.HandleFunc("/otp_qr", LinkOtpQr).Methods(http.MethodGet)
|
||||
r.PathPrefix("/files/").Handler(
|
||||
http.StripPrefix("/files/",
|
||||
http.FileServer(http.Dir(base.Cfg.FilesPath)),
|
||||
r.PathPrefix("/down_files/").Handler(
|
||||
http.StripPrefix("/down_files/",
|
||||
http.FileServer(http.Dir(base.Cfg.DownFilesPath)),
|
||||
),
|
||||
)
|
||||
r.NotFoundHandler = http.HandlerFunc(notFound)
|
||||
|
Reference in New Issue
Block a user