From b059c555cf9a314e94f2a0df7b342052ef832bca Mon Sep 17 00:00:00 2001 From: bjdgyc Date: Mon, 18 Mar 2024 13:28:57 +0800 Subject: [PATCH 1/6] fix --- build.sh | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/build.sh b/build.sh index 13aab76..5ac0f01 100644 --- a/build.sh +++ b/build.sh @@ -17,8 +17,11 @@ cpath=$(pwd) ver=$(cat version) echo $ver +#前端编译 仅需要执行一次 +#bash ./build_web.sh + echo "copy二进制文件" -cd $cpath/server + # -tags osusergo,netgo,sqlite_omit_load_extension flags="-trimpath" ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.buildDate=$(date --iso-8601=seconds)" @@ -32,42 +35,37 @@ apk add gcc g++ musl musl-dev tzdata export GOPROXY=https://goproxy.cn go mod tidy echo "build:" +rm anylink export CGO_ENABLED=1 -go build -v -o anylink_amd64 $flags -ldflags "$ldflags" -./anylink_amd64 -v +go build -v -o anylink $flags -ldflags "$ldflags" +./anylink -v EOF ) #使用 musl-dev 编译 -docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/amd64 \ +docker run -q --rm -v $PWD/server:/app -v $gopath:/go -w /app --platform=linux/amd64 \ golang:1.20-alpine3.19 sh -c "$dockercmd" -exit 0 - #arm64编译 -docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/arm64 \ - golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags" -./anylink_arm64 -v +#docker run -q --rm -v $PWD/server:/app -v $gopath:/go -w /app --platform=linux/arm64 \ +# golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags" +#exit 0 -exit 0 - -cd $cpath +#cd $cpath echo "整理部署文件" -deploy="anylink-deploy" -rm -rf $deploy ${deploy}.tar.gz -mkdir $deploy -mkdir $deploy/log +rm -rf anylink-deploy anylink-deploy.tar.gz +mkdir anylink-deploy +mkdir anylink-deploy/log -cp -r server/anylink $deploy -cp -r server/bridge-init.sh $deploy -cp -r server/conf $deploy +cp -r server/anylink anylink-deploy +cp -r server/conf anylink-deploy -cp -r systemd $deploy -cp -r LICENSE $deploy -cp -r home $deploy +cp -r index_template anylink-deploy +cp -r deploy anylink-deploy +cp -r LICENSE anylink-deploy -tar zcvf ${deploy}.tar.gz $deploy +tar zcvf anylink-deploy.tar.gz anylink-deploy #注意使用root权限运行 #cd anylink-deploy From 09160a68917237ee3bc7713b81d40d5bb010a903 Mon Sep 17 00:00:00 2001 From: bjdgyc Date: Mon, 18 Mar 2024 17:26:09 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=85=B3=E9=97=AD=20idle?= =?UTF-8?q?=5Ftimeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/base/config.go | 2 +- server/conf/server-sample.toml | 4 ++-- server/handler/link_dtls.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/base/config.go b/server/base/config.go index 4623cdb..7f111f2 100644 --- a/server/base/config.go +++ b/server/base/config.go @@ -59,7 +59,7 @@ var configs = []config{ {Typ: cfgInt, Name: "mobile_keepalive", Usage: "移动端keepalive接检测时间(秒)", ValInt: 40}, {Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 60}, {Typ: cfgInt, Name: "mtu", Usage: "最大传输单元MTU", ValInt: 1460}, - {Typ: cfgInt, Name: "idle_timeout", Usage: "空闲链接超时时间(秒)-超时后断开链接,0关闭此功能", ValInt: 1800}, + {Typ: cfgInt, Name: "idle_timeout", Usage: "空闲链接超时时间(秒)-超时后断开链接,0关闭此功能", ValInt: 0}, {Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)-用于断线重连,0永不过期", ValInt: 3600}, // {Typ: cfgInt, Name: "auth_timeout", Usage: "auth_timeout", ValInt: 0}, {Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),-1关闭", ValInt: 600}, diff --git a/server/conf/server-sample.toml b/server/conf/server-sample.toml index 726ba39..2950341 100644 --- a/server/conf/server-sample.toml +++ b/server/conf/server-sample.toml @@ -82,10 +82,10 @@ default_domain = "example.com" #default_domain = "example.com abc.example.com" #空闲链接超时时间(秒)-超时后断开链接,0关闭此功能 -idle_timeout = 1800 +idle_timeout = 0 #session过期时间,用于断线重连,0永不过期 session_timeout = 3600 -auth_timeout = 0 +#auth_timeout = 0 audit_interval = 600 show_sql = false diff --git a/server/handler/link_dtls.go b/server/handler/link_dtls.go index c87a8f0..308462d 100644 --- a/server/handler/link_dtls.go +++ b/server/handler/link_dtls.go @@ -62,7 +62,7 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) { base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr, conn.RemoteAddr()) return case 0x03: // DPD-REQ - base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n]) + base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n], string(pl.Data[1:n])) pl.PType = 0x04 // 从零开始 可以直接赋值 pl.Data = pl.Data[:n] From fc3b39e09f93c408553d6a046f8842f8449914c3 Mon Sep 17 00:00:00 2001 From: bjdgyc Date: Mon, 18 Mar 2024 17:54:45 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=85=B3=E9=97=AD=20idle?= =?UTF-8?q?=5Ftimeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/link_dtls.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handler/link_dtls.go b/server/handler/link_dtls.go index 308462d..c87a8f0 100644 --- a/server/handler/link_dtls.go +++ b/server/handler/link_dtls.go @@ -62,7 +62,7 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) { base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr, conn.RemoteAddr()) return case 0x03: // DPD-REQ - base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n], string(pl.Data[1:n])) + base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n]) pl.PType = 0x04 // 从零开始 可以直接赋值 pl.Data = pl.Data[:n] From ce89ea680b99801157bccefa823735352ef16917 Mon Sep 17 00:00:00 2001 From: bjdgyc Date: Tue, 19 Mar 2024 11:22:20 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++- build.sh | 59 +++------------------------------- server/base/config.go | 2 +- server/conf/server-sample.toml | 2 +- server/handler/link_auth.go | 5 +-- server/handler/link_cstp.go | 8 ++--- server/handler/link_dtls.go | 17 ++++++---- server/handler/link_tunnel.go | 2 +- 8 files changed, 31 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 4364dc3..428681a 100644 --- a/README.md +++ b/README.md @@ -108,10 +108,11 @@ sudo ./anylink - [x] 兼容 AnyConnect - [x] 兼容 OpenConnect - [x] 基于 tun 设备的 nat 访问模式 -- [x] 基于 tap 设备的桥接访问模式 +- [x] 基于 tun 设备的桥接访问模式 - [x] 基于 macvtap 设备的桥接访问模式 - [x] 支持 [proxy protocol v1&v2](http://www.haproxy.org/download/2.2/doc/proxy-protocol.txt) 协议 - [x] 用户组支持 +- [x] 用户组策略支持 - [x] 多用户支持 - [x] 用户策略支持 - [x] TOTP 令牌支持 @@ -119,10 +120,15 @@ sudo ./anylink - [x] 流量速率限制 - [x] 后台管理界面 - [x] 访问权限管理 +- [x] 用户活动审计功能 - [x] IP 访问审计功能 - [x] 域名动态拆分隧道(域名路由功能) - [x] radius认证支持 - [x] LDAP认证支持 +- [x] 空闲链接超时自动断开 +- [x] 流量压缩功能 +- [x] 出口 IP 自动放行 +- [x] 支持多服务的配置区分 - [ ] 基于 ipvtap 设备的桥接访问模式 ## Config diff --git a/build.sh b/build.sh index 5ac0f01..91e451e 100644 --- a/build.sh +++ b/build.sh @@ -1,16 +1,5 @@ #!/bin/bash -#github action release.sh - -set -x -function RETVAL() { - rt=$1 - if [ $rt != 0 ]; then - echo $rt - exit 1 - fi -} - #当前目录 cpath=$(pwd) @@ -18,55 +7,15 @@ ver=$(cat version) echo $ver #前端编译 仅需要执行一次 -#bash ./build_web.sh +bash ./build_web.sh -echo "copy二进制文件" +cd $cpath/server -# -tags osusergo,netgo,sqlite_omit_load_extension -flags="-trimpath" -ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.buildDate=$(date --iso-8601=seconds)" -#github action -gopath=/go +go build -v -o anylink -dockercmd=$( - cat < Date: Tue, 19 Mar 2024 11:23:03 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_test.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 build_test.sh diff --git a/build_test.sh b/build_test.sh new file mode 100644 index 0000000..5ac0f01 --- /dev/null +++ b/build_test.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +#github action release.sh + +set -x +function RETVAL() { + rt=$1 + if [ $rt != 0 ]; then + echo $rt + exit 1 + fi +} + +#当前目录 +cpath=$(pwd) + +ver=$(cat version) +echo $ver + +#前端编译 仅需要执行一次 +#bash ./build_web.sh + +echo "copy二进制文件" + +# -tags osusergo,netgo,sqlite_omit_load_extension +flags="-trimpath" +ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.buildDate=$(date --iso-8601=seconds)" +#github action +gopath=/go + +dockercmd=$( + cat < Date: Tue, 19 Mar 2024 16:28:38 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20xt=5Fcomment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/link_tun.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/handler/link_tun.go b/server/handler/link_tun.go index b01074d..a2f3eeb 100644 --- a/server/handler/link_tun.go +++ b/server/handler/link_tun.go @@ -46,6 +46,7 @@ func checkTun() { // 修复 rockyos nat 不生效 base.CheckModOrLoad("iptable_filter") base.CheckModOrLoad("iptable_nat") + // base.CheckModOrLoad("xt_comment") // 添加注释 natRule := []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-m", "comment",