Skip to content

Commit fa5ced4

Browse files
authored
Merge pull request #308 from bjdgyc/dev
Dev
2 parents 8d92cac + bac4974 commit fa5ced4

File tree

13 files changed

+79
-25
lines changed

13 files changed

+79
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.idea/
33
anylink-deploy
44
anylink-deploy.tar.gz
5+
anylink-deploy-*
56
anylink
67
anylink.db
78

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ AnyLink 基于 [ietf-openconnect](https://tools.ietf.org/html/draft-mavrogiannop
2626
AnyLink 使用 TLS/DTLS 进行数据加密,因此需要 RSA 或 ECC 证书,可以通过 Let's Encrypt 和 TrustAsia 申请免费的 SSL 证书。
2727

2828
AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18.04、Ubuntu 20.04 测试通过,如需要安装在其他系统,需要服务端支持 tun/tap
29-
功能、ip 设置命令。
29+
功能、ip 设置命令、iptables命令
3030

3131
## Screenshot
3232

@@ -74,18 +74,22 @@ AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18.04、Ubuntu 20.04 测试
7474
7575
### 自行编译安装
7676

77-
> 需要提前安装好 golang >= 1.20 和 nodejs = 16.x 和 yarn >= v1.22.x
77+
> 需要提前安装好 docker
7878
7979
```shell
8080
git clone https://github.com/bjdgyc/anylink.git
8181

82-
# 编译参考软件版本
82+
# docker编译 参考软件版本(不需要安装)
8383
# go 1.20.12
8484
# node v16.20.2
8585
# yarn 1.22.19
8686

8787

8888
cd anylink
89+
90+
# 编译前端
91+
bash build_web.sh
92+
# 编译 anylink-deploy 发布文件
8993
bash build.sh
9094

9195
# 注意使用root权限运行

build.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@ ver=$(cat version)
77
echo $ver
88

99
#前端编译 仅需要执行一次
10-
bash ./build_web.sh
10+
#bash ./build_web.sh
1111

12-
cd $cpath/server
12+
bash build_docker.sh
1313

14-
go build -v -o anylink
14+
deploy="anylink-deploy-$ver"
15+
docker container rm $deploy
16+
docker container create --name $deploy bjdgyc/anylink:$ver
17+
rm -rf anylink-deploy anylink-deploy.tar.gz
18+
docker cp -a $deploy:/app ./anylink-deploy
19+
tar zcf ${deploy}.tar.gz anylink-deploy
1520

16-
./anylink -v
1721

22+
./anylink-deploy/anylink -v
1823

19-
echo "anylink 编译完成,目录: $cpath/server/anylink"
24+
25+
echo "anylink 编译完成,目录: anylink-deploy"
26+
ls -lh anylink-deploy
2027

2128

build_docker.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ echo $ver
1111
#bash ./build_web.sh
1212

1313
# docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 本地不生成镜像
14-
docker build -t bjdgyc/anylink:latest --no-cache --progress=plain --platform linux/amd64 \
15-
--build-arg CN="yes" --build-arg appVer=$ver --build-arg commitId=$(git rev-parse HEAD) -f docker/Dockerfile .
14+
docker build -t bjdgyc/anylink:latest --no-cache --progress=plain \
15+
--build-arg CN="yes" --build-arg appVer=$ver --build-arg commitId=$(git rev-parse HEAD) \
16+
-f docker/Dockerfile .
1617

1718
echo "docker tag latest $ver"
1819
docker tag bjdgyc/anylink:latest bjdgyc/anylink:$ver

doc/question.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
> 请使用手机安装 freeotp ,然后扫描otp二维码,生成的数字即是动态码
1212
13+
### 用户策略问题
14+
15+
> 只要有用户策略,组策略就不生效,相当于覆盖了组策略的配置
16+
1317
### 远程桌面连接
1418

1519
> 本软件已经支持远程桌面里面连接anyconnect。

server/admin/api_user.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/bjdgyc/anylink/dbdata"
1818
"github.com/bjdgyc/anylink/sessdata"
1919
"github.com/skip2/go-qrcode"
20+
mail "github.com/xhit/go-simple-mail/v2"
2021
)
2122

2223
func UserList(w http.ResponseWriter, r *http.Request) {
@@ -272,5 +273,13 @@ func userAccountMail(user *dbdata.User) error {
272273
return err
273274
}
274275
// fmt.Println(w.String())
275-
return SendMail(base.Cfg.Issuer+"平台通知", user.Email, w.String())
276+
imgData, _ := userOtpQr(user.Id, false)
277+
attach := &mail.File{
278+
MimeType: "image/png",
279+
Name: "userOtpQr.png",
280+
Data: []byte(imgData),
281+
Inline: true,
282+
}
283+
284+
return SendMail(base.Cfg.Issuer, user.Email, w.String(), attach)
276285
}

server/admin/common.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func GetJwtData(jwtToken string) (map[string]interface{}, error) {
4343
return claims, nil
4444
}
4545

46-
func SendMail(subject, to, htmlBody string) error {
46+
func SendMail(subject, to, htmlBody string, attach *mail.File) error {
4747

4848
dataSmtp := &dbdata.SettingSmtp{}
4949
err := dbdata.SettingGet(dataSmtp)
@@ -102,6 +102,10 @@ func SendMail(subject, to, htmlBody string) error {
102102
AddTo(to).
103103
SetSubject(subject)
104104

105+
if attach != nil {
106+
email.Attach(attach)
107+
}
108+
105109
email.SetBody(mail.TextHTML, htmlBody)
106110

107111
// Call Send and pass the client

server/base/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ var configs = []config{
5555
{Typ: cfgInt, Name: "max_client", Usage: "最大用户连接", ValInt: 200},
5656
{Typ: cfgInt, Name: "max_user_client", Usage: "最大单用户连接", ValInt: 3},
5757
{Typ: cfgInt, Name: "cstp_keepalive", Usage: "keepalive时间(秒)", ValInt: 3},
58-
{Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 10},
58+
{Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 20},
5959
{Typ: cfgInt, Name: "mobile_keepalive", Usage: "移动端keepalive接检测时间(秒)", ValInt: 4},
60-
{Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 15},
60+
{Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 60},
6161
{Typ: cfgInt, Name: "mtu", Usage: "最大传输单元MTU", ValInt: 1460},
6262
{Typ: cfgInt, Name: "idle_timeout", Usage: "空闲链接超时时间(秒)-超时后断开链接,0关闭此功能", ValInt: 0},
6363
{Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)-用于断线重连,0永不过期", ValInt: 3600},

server/conf/server-sample.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ cert_key = "./conf/vpn_cert.key"
1212
files_path = "./conf/files"
1313
profile = "./conf/profile.xml"
1414
#profile name(用于区分不同服务端的配置)
15-
#客户端存放位置 C:\ProgramData\Cisco\Cisco Secure Client\VPN\Profile
15+
#客户端存放位置
16+
#Windows 10
17+
#%ProgramData%Cisco\Cisco AnyConnect Secure Mobility Client\Profile
18+
#Mac Os X
19+
#/opt/cisco/anyconnect/profile
20+
#Linux
21+
#/opt/cisco/anyconnect/profile
1622
profile_name = "anylink"
17-
#日志目录,为空写入标准输出
23+
#日志目录,默认为空写入标准输出
1824
#log_path = "./log"
1925
log_path = ""
2026
log_level = "debug"
@@ -66,9 +72,9 @@ default_group = "one"
6672

6773
#客户端失效检测时间(秒) dpd > keepalive
6874
cstp_keepalive = 3
69-
cstp_dpd = 10
75+
cstp_dpd = 20
7076
mobile_keepalive = 4
71-
mobile_dpd = 15
77+
mobile_dpd = 60
7278

7379
# 根据实际情况修改
7480
#cstp_keepalive = 20

server/conf/server.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ db_source = "./conf/anylink.db"
1010
cert_file = "./conf/vpn_cert.pem"
1111
cert_key = "./conf/vpn_cert.key"
1212
files_path = "./conf/files"
13+
14+
#日志目录,默认为空写入标准输出
15+
#log_path = "./log"
1316
log_level = "debug"
1417

1518
#系统名称

0 commit comments

Comments
 (0)