Skip to content

Commit 8d92cac

Browse files
authored
Merge pull request #306 from bjdgyc/dev
Dev
2 parents 2949ea2 + eb7401f commit 8d92cac

File tree

8 files changed

+377
-180
lines changed

8 files changed

+377
-180
lines changed

build_web.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3+
rm -rf web/ui server/ui
4+
35
docker run -it --rm -v $PWD/web:/app -w /app node:16-alpine \
46
sh -c "yarn install --registry=https://registry.npmmirror.com && yarn run build"
57

6-
rm -rf server/ui
8+
79
cp -r web/ui server/ui
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
4+
<head>
5+
<meta charset=UTF-8">
6+
<title id="pageTitle">客户端下载</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<style type="text/css">
9+
body {
10+
background-color: #fff;
11+
background-image: linear-gradient(0deg, transparent 24%, rgba(207, 207, 207, 0.2) 25%, rgba(207, 207, 207, 0.2) 26%, transparent 27%, transparent 74%, rgba(207, 207, 207, 0.2) 75%, rgba(207, 207, 207, 0.2) 76%, transparent 77%, transparent),
12+
linear-gradient(90deg, transparent 24%, rgba(207, 207, 207, 0.2) 25%, rgba(207, 207, 207, 0.2) 26%, transparent 27%, transparent 74%, rgba(207, 207, 207, 0.2) 75%, rgba(207, 207, 207, 0.2) 76%, transparent 77%, transparent);
13+
background-size: 50px 50px;
14+
margin: 0;
15+
padding: 0;
16+
display: flex;
17+
justify-content: center;
18+
align-items: center;
19+
height: 100vh;
20+
}
21+
22+
#box {
23+
background-color: #ffffff;
24+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
25+
position: relative;
26+
padding: 20px;
27+
border-radius: 8px;
28+
max-width: 550px;
29+
width: 100%;
30+
box-sizing: border-box;
31+
}
32+
33+
h2 {
34+
color: #333;
35+
font-weight: 600;
36+
font-size: 28px;
37+
margin: 0 0 20px 0;
38+
}
39+
40+
p {
41+
color: #666;
42+
font-size: 16px;
43+
line-height: 1.6;
44+
margin-top: 20px;
45+
}
46+
47+
.button {
48+
background-color: #ddd;
49+
text-decoration: none;
50+
line-height: 44px;
51+
padding: 9px 42px;
52+
font-weight: 500;
53+
color: #fff;
54+
font-size: 16px;
55+
-webkit-transition: background-color 0.25s ease-out 0s;
56+
-moz-transition: background-color 0.25s ease-out 0s;
57+
transition: background-color 0.25s ease-out 0s;
58+
-moz-border-radius: 4px;
59+
-webkit-border-radius: 4px;
60+
border-radius: 4px;
61+
}
62+
63+
.button:hover {
64+
background-color: #CCC;
65+
color: #444;
66+
}
67+
68+
.button:active {
69+
background-color: #666;
70+
color: #eee;
71+
}
72+
73+
.blue {
74+
background-color: #007BFF;
75+
}
76+
77+
.deep-blue {
78+
background-color: #0056B3;
79+
}
80+
81+
.green {
82+
background-color: #28A745;
83+
}
84+
85+
.grey {
86+
background-color: #6C757D;
87+
}
88+
89+
.black {
90+
background-color: #343A40;
91+
}
92+
93+
.light-blue {
94+
background-color: #17A2B8;
95+
}
96+
97+
.dark-grey {
98+
background-color: #495057;
99+
}
100+
101+
@media (max-width: 768px) {
102+
h2 {
103+
font-size: 24px;
104+
}
105+
106+
p {
107+
font-size: 14px;
108+
}
109+
110+
.button {
111+
padding: 7px 35px;
112+
}
113+
}
114+
</style>
115+
</head>
116+
117+
<body>
118+
<div id="app">
119+
<div id="box">
120+
<h2 id="title">请选择对应平台下载</h2>
121+
<p id="windowsTab">Windows 系统</p>
122+
<a id="linkWindowsX86_64" class="button blue" href="#">Win X86_64</a>
123+
<a id="linkWindowsARM64" class="button deep-blue" href="#">Win ARM64</a>
124+
125+
<p id="mobileTab">移动端</p>
126+
<a id="linkAndroid" class="button green" href="#">Android</a>
127+
<a id="linkIphone" class="button grey" href="#" target="_blank">iPhone</a>
128+
129+
<p id="macOSTab">MacOS 系统</p>
130+
<a id="linkMacos" class="button black" href="#">Mac Intel</a>
131+
<a id="linkMacosARM64" class="button blue" href="#">Mac ARM64</a>
132+
133+
<p id="totpTab">TOTP 移动客户端</p>
134+
<a id="linkTotpAndroid" class="button light-blue" href="#">Android</a>
135+
<a id="linkTotpIphone" class="button dark-grey" href="#" target="_blank">iPhone</a>
136+
</div>
137+
</div>
138+
<script>
139+
const data = {
140+
links: {
141+
windowsX86_64: '/files/anyconnect-win-4.10.05111.msi',
142+
windowsARM64: '/files/anyconnect-win-4.10.05111.msi',
143+
android: '/files/CiscoSecureClientAnyConnect_v5.0.00247.apk',
144+
iphone: 'https://apps.apple.com/cn/app/cisco-anyconnect/id1135064690',
145+
macosIntel: '/files/anyconnect-macos-4.10.05111.dmg',
146+
macosARM64: '/files/anyconnect-macos-4.10.05111.dmg',
147+
totpAndroid: '/files/Authenticator_v5.10_apkpure.com.apk',
148+
totpIphone: 'https://apps.apple.com/cn/app/google-authenticator/id388497605',
149+
}
150+
};
151+
152+
window.onload = function () {
153+
document.getElementById('linkWindowsX86_64').href = data.links.windowsX86_64;
154+
document.getElementById('linkWindowsARM64').href = data.links.windowsARM64;
155+
document.getElementById('linkAndroid').href = data.links.android;
156+
document.getElementById('linkIphone').href = data.links.iphone;
157+
document.getElementById('linkMacos').href = data.links.macosIntel;
158+
document.getElementById('linkMacosARM64').href = data.links.macosARM64;
159+
document.getElementById('linkTotpAndroid').href = data.links.totpAndroid;
160+
document.getElementById('linkTotpIphone').href = data.links.totpIphone;
161+
};
162+
</script>
163+
</body>
164+
165+
</html>

server/dbdata/db.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dbdata
22

33
import (
4+
"net/http"
45
"time"
56

67
"github.com/bjdgyc/anylink/base"
@@ -121,6 +122,7 @@ func addInitData() error {
121122
other := &SettingOther{
122123
LinkAddr: "vpn.xx.com",
123124
Banner: "您已接入公司网络,请按照公司规定使用。\n请勿进行非工作下载及视频行为!",
125+
Homecode: http.StatusOK,
124126
Homeindex: "AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。",
125127
AccountMail: accountMail,
126128
}

server/dbdata/setting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type SettingAuditLog struct {
2929
type SettingOther struct {
3030
LinkAddr string `json:"link_addr"`
3131
Banner string `json:"banner"`
32+
Homecode int `json:"homecode"`
3233
Homeindex string `json:"homeindex"`
3334
AccountMail string `json:"account_mail"`
3435
}

server/handler/link_home.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ func LinkHome(w http.ResponseWriter, r *http.Request) {
2727
if err := dbdata.SettingGet(index); err != nil {
2828
return
2929
}
30-
w.WriteHeader(http.StatusOK)
31-
if index.Homeindex == "" {
32-
index.Homeindex = "AnyLink 是一个企业级远程办公 SSL VPN 软件,可以支持多人同时在线使用。"
30+
31+
if index.Homecode > 0 {
32+
w.WriteHeader(index.Homecode)
33+
} else {
34+
w.WriteHeader(http.StatusOK)
3335
}
36+
37+
// if index.Homeindex == "" {
38+
// index.Homeindex = "AnyLink 是一个企业级远程办公 SSL VPN 软件,可以支持多人同时在线使用。"
39+
// }
3440
fmt.Fprintln(w, index.Homeindex)
3541
}
3642

server/handler/link_tun.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ func checkTun() {
5151
// 添加注释
5252
natRule := []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-m", "comment",
5353
"--comment", "AnyLink", "-j", "MASQUERADE"}
54+
if base.InContainer {
55+
natRule = []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-j", "MASQUERADE"}
56+
}
5457
err = ipt.InsertUnique("nat", "POSTROUTING", 1, natRule...)
5558
if err != nil {
5659
base.Error(err)
5760
}
5861

5962
// 添加注释
6063
forwardRule := []string{"-m", "comment", "--comment", "AnyLink", "-j", "ACCEPT"}
64+
if base.InContainer {
65+
forwardRule = []string{"-j", "ACCEPT"}
66+
}
6167
err = ipt.InsertUnique("filter", "FORWARD", 1, forwardRule...)
6268
if err != nil {
6369
base.Error(err)

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.11.3
1+
0.11.4

0 commit comments

Comments
 (0)