Skip to content

Commit d73816a

Browse files
committed
增加日志信息
1 parent 43a9d31 commit d73816a

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ anylink
66
anylink.db
77

88
dist
9-
artifact-dist
9+
artifact-dist
10+
11+
anylink_amd64
12+
anylink_arm64

release_bak.sh renamed to release_test.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,36 @@ function RETVAL() {
1414
#当前目录
1515
cpath=$(pwd)
1616

17+
ver=$(cat version)
18+
echo $ver
19+
1720
echo "copy二进制文件"
1821
cd $cpath/server
1922
# -tags osusergo,netgo,sqlite_omit_load_extension
2023
flags="-trimpath"
21-
ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.date=$(date --iso-8601=seconds)"
24+
ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.buildDate=$(date --iso-8601=seconds)"
2225
#github action
23-
gopath=$(go env GOPATH)
26+
gopath=/go
27+
28+
dockercmd=$(
29+
cat <<EOF
30+
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
31+
apk add gcc g++ musl musl-dev
32+
export GOPROXY=https://goproxy.cn
2433
go mod tidy
25-
# alpine3
26-
apk add gcc musl-dev
34+
echo "build:"
35+
export CGO_ENABLED=1
36+
go build -v -o anylink_amd64 $flags -ldflags "$ldflags"
37+
./anylink_amd64 -v
38+
EOF
39+
)
40+
2741
#使用 musl-dev 编译
2842
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/amd64 \
29-
golang:1.20-alpine3.19 go build -o anylink_amd64 $flags -ldflags "$ldflags"
30-
./anylink_amd64 -v
43+
golang:1.20-alpine3.19 sh -c "$dockercmd"
44+
45+
exit 0
46+
3147
#arm64编译
3248
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/arm64 \
3349
golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags"

server/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ ui/
1818
.idea/
1919
anylink
2020
data.db
21-
conf/*.db
21+
conf/*.db

server/handler/link_cstp.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,30 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
5757
switch pl.Data[6] {
5858
case 0x07: // KEEPALIVE
5959
// do nothing
60-
// base.Debug("recv keepalive", cSess.IpAddr)
60+
base.Trace("recv LinkCstp Keepalive", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
6161
// 判断超时时间
6262
if checkIdle {
6363
lastTime = cSess.LastDataTime.Load()
6464
if lastTime.Before(utils.NowSec().Add(-idle)) {
65-
base.Warn("IdleTimeout", cSess.Username, cSess.IpAddr, "lastTime", lastTime)
65+
base.Warn("IdleTimeout", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), "lastTime", lastTime)
6666
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserIdleTimeout)
6767
return
6868
}
6969
}
7070
case 0x05: // DISCONNECT
7171
cSess.UserLogoutCode = dbdata.UserLogoutClient
72-
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr)
72+
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
7373
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserLogoutClient)
7474
return
7575
case 0x03: // DPD-REQ
76-
// base.Debug("recv DPD-REQ", cSess.IpAddr)
76+
base.Trace("recv LinkCstp DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
7777
pl.PType = 0x04
7878
pl.Data = pl.Data[:n]
7979
if payloadOutCstp(cSess, pl) {
8080
return
8181
}
8282
case 0x04:
83-
// log.Println("recv DPD-RESP")
83+
base.Trace("recv LinkCstp DPD-RESP", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
8484
case 0x08: // decompress
8585
if cSess.CstpPickCmp == nil {
8686
continue

server/handler/link_dtls.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
5656
switch pl.Data[0] {
5757
case 0x07: // KEEPALIVE
5858
// do nothing
59-
// base.Debug("recv keepalive", cSess.IpAddr)
59+
base.Trace("recv LinkDtls Keepalive", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
6060
case 0x05: // DISCONNECT
6161
cSess.UserLogoutCode = dbdata.UserLogoutClient
62-
base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr)
62+
base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
6363
return
6464
case 0x03: // DPD-REQ
65-
// base.Debug("recv DPD-REQ", cSess.IpAddr)
65+
base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
6666
pl.PType = 0x04
6767
pl.Data = pl.Data[:n]
6868
if payloadOutDtls(cSess, dSess, pl) {
6969
return
7070
}
7171
case 0x04:
72-
// base.Debug("recv DPD-RESP", cSess.IpAddr)
72+
base.Trace("recv LinkDtls DPD-RESP", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
7373
case 0x08: // decompress
7474
if cSess.DtlsPickCmp == nil {
7575
continue

0 commit comments

Comments
 (0)