Skip to content

Commit 00c5425

Browse files
authored
Merge pull request #336 from bjdgyc/dev
权限 添加拖拽功能
2 parents a548777 + b45d5e4 commit 00c5425

File tree

20 files changed

+168
-54
lines changed

20 files changed

+168
-54
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ ipv4_end = "10.1.2.200"
453453
- [三方文档-男孩的天职](https://note.youdao.com/s/X4AxyWfL)
454454
- [三方文档-issues](https://github.com/bjdgyc/anylink/issues)
455455
- [三方文档-思有云](https://www.ioiox.com/archives/128.html)
456-
- [三方文档-杨杨得亿](https://yangpin.link/archives/1633.html) [Windows电脑连接步骤-杨杨得亿](https://yangpin.link/archives/1697.html)
456+
- [三方文档-杨杨得亿](https://yangpin.link/archives/1897.html) [Windows电脑连接步骤-杨杨得亿](https://yangpin.link/archives/1697.html)
457457

458458
## Support Client
459459

build_docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ echo "docker tag latest $ver"
1919
docker tag bjdgyc/anylink:latest bjdgyc/anylink:$ver
2020

2121

22+
# docker tag bjdgyc/anylink:$ver registry.cn-hangzhou.aliyuncs.com/bjdgyc/anylink:test-$ver
23+
# docker push registry.cn-hangzhou.aliyuncs.com/bjdgyc/anylink:test-$ver

build_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ go build -v -o anylink $flags -ldflags "$ldflags"
4242
EOF
4343
)
4444

45+
# golang:1.20-alpine3.19
4546
#使用 musl-dev 编译
4647
docker run -q --rm -v $PWD/server:/app -v $gopath:/go -w /app --platform=linux/amd64 \
47-
golang:1.20-alpine3.19 sh -c "$dockercmd"
48+
golang:1.22-alpine3.19 sh -c "$dockercmd"
4849

4950
#arm64编译
5051
#docker run -q --rm -v $PWD/server:/app -v $gopath:/go -w /app --platform=linux/arm64 \

doc/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
| 杨杨得亿 | |
5050
| Thanataos | |
5151
| 憨大叔 | |
52+
| 明月 | |
53+
| Amis | |
5254

5355

5456

docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
# 需要先编译出ui文件后 再执行docker编译
1414

1515
# server
16-
FROM golang:1.20-alpine3.19 as builder_golang
16+
# golang:1.20-alpine3.19
17+
FROM golang:1.22-alpine3.19 as builder_golang
1718

1819
ARG CN="no"
1920
ARG appVer="appVer"

docker/init_release.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ if [[ $CN == "yes" ]]; then
99
export GOPROXY=https://goproxy.cn
1010
fi
1111

12+
13+
# docker 启动使用 4.19 以上内核
14+
apk add --no-cache ca-certificates bash iproute2 tzdata iptables
15+
1216
# alpine:3.19 兼容老版 iptables
13-
apk add --no-cache iptables iptables-legacy
17+
apk add --no-cache iptables-legacy
1418
rm /sbin/iptables
1519
ln -s /sbin/iptables-legacy /sbin/iptables
1620

17-
apk add --no-cache ca-certificates bash iproute2 tzdata
21+
1822
chmod +x /app/docker_entrypoint.sh
1923
mkdir /app/log
2024

server/admin/api_user.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ type userAccountMailData struct {
220220
Username string
221221
Nickname string
222222
PinCode string
223+
LimitTime string
223224
OtpImg string
224225
OtpImgBase64 string
225226
DisableOtp bool
@@ -276,6 +277,13 @@ func userAccountMail(user *dbdata.User) error {
276277
OtpImgBase64: "data:image/png;base64," + otpData,
277278
DisableOtp: user.DisableOtp,
278279
}
280+
281+
if user.LimitTime == nil {
282+
data.LimitTime = "无限制"
283+
} else {
284+
data.LimitTime = user.LimitTime.Local().Format("2006-01-02")
285+
}
286+
279287
w := bytes.NewBufferString("")
280288
t, _ := template.New("auth_complete").Parse(htmlBody)
281289
err = t.Execute(w, data)

server/dbdata/db.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func addInitData() error {
147147
Name: "all",
148148
AllowLan: true,
149149
ClientDns: []ValData{{Val: "114.114.114.114"}},
150-
RouteInclude: []ValData{{Val: All}},
150+
RouteInclude: []ValData{{Val: ALL}},
151151
Status: 1,
152152
}
153153
err = SetGroup(&g1)
@@ -184,6 +184,7 @@ const accountMail = `<p>您好:</p>
184184
用户组: <b>{{.Group}}</b> <br/>
185185
用户名: <b>{{.Username}}</b> <br/>
186186
用户PIN码: <b>{{.PinCode}}</b> <br/>
187+
用户过期时间: <b>{{.LimitTime}}</b> <br/>
187188
{{if .DisableOtp}}
188189
<!-- nothing -->
189190
{{else}}

server/dbdata/group.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,33 @@ import (
1010
"time"
1111

1212
"github.com/bjdgyc/anylink/base"
13+
"github.com/songgao/water/waterutil"
1314
"golang.org/x/text/language"
1415
"golang.org/x/text/message"
1516
)
1617

1718
const (
1819
Allow = "allow"
1920
Deny = "deny"
20-
All = "all"
21+
ALL = "all"
22+
TCP = "tcp"
23+
UDP = "udp"
24+
ICMP = "icmp"
2125
)
2226

2327
// 域名分流最大字符2万
2428
const DsMaxLen = 20000
2529

2630
type GroupLinkAcl struct {
2731
// 自上而下匹配 默认 allow * *
28-
Action string `json:"action"` // allow、deny
29-
Val string `json:"val"`
30-
Port string `json:"port"` // 兼容单端口历史数据类型uint16
31-
Ports map[uint16]int8 `json:"ports"`
32-
IpNet *net.IPNet `json:"ip_net"`
33-
Note string `json:"note"`
32+
Action string `json:"action"` // allow、deny
33+
Protocol string `json:"protocol"` // 支持 ALL、TCP、UDP、ICMP 协议
34+
IpProto waterutil.IPProtocol `json:"ip_protocol"` // 判断协议使用
35+
Val string `json:"val"`
36+
Port string `json:"port"` // 兼容单端口历史数据类型uint16
37+
Ports map[uint16]int8 `json:"ports"`
38+
IpNet *net.IPNet `json:"ip_net"`
39+
Note string `json:"note"`
3440
}
3541

3642
type ValData struct {
@@ -114,7 +120,7 @@ func SetGroup(g *Group) error {
114120
routeInclude := []ValData{}
115121
for _, v := range g.RouteInclude {
116122
if v.Val != "" {
117-
if v.Val == All {
123+
if v.Val == ALL {
118124
routeInclude = append(routeInclude, v)
119125
continue
120126
}
@@ -164,6 +170,19 @@ func SetGroup(g *Group) error {
164170
}
165171
v.IpNet = ipNet
166172

173+
// 设置协议数据
174+
switch v.Protocol {
175+
case TCP:
176+
v.IpProto = waterutil.TCP
177+
case UDP:
178+
v.IpProto = waterutil.UDP
179+
case ICMP:
180+
v.IpProto = waterutil.ICMP
181+
default:
182+
// 其他类型都是 all
183+
v.Protocol = ALL
184+
}
185+
167186
portsStr := v.Port
168187
v.Port = strings.TrimSpace(portsStr)
169188
// switch vp := v.Port.(type) {

server/dbdata/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func SetPolicy(p *Policy) error {
2727
routeInclude := []ValData{}
2828
for _, v := range p.RouteInclude {
2929
if v.Val != "" {
30-
if v.Val == All {
30+
if v.Val == ALL {
3131
routeInclude = append(routeInclude, v)
3232
continue
3333
}

0 commit comments

Comments
 (0)