mirror of https://github.com/bjdgyc/anylink.git
增加日志信息
This commit is contained in:
parent
43a9d31b82
commit
d73816a811
|
@ -7,3 +7,6 @@ anylink.db
|
||||||
|
|
||||||
dist
|
dist
|
||||||
artifact-dist
|
artifact-dist
|
||||||
|
|
||||||
|
anylink_amd64
|
||||||
|
anylink_arm64
|
||||||
|
|
|
@ -14,20 +14,36 @@ function RETVAL() {
|
||||||
#当前目录
|
#当前目录
|
||||||
cpath=$(pwd)
|
cpath=$(pwd)
|
||||||
|
|
||||||
|
ver=$(cat version)
|
||||||
|
echo $ver
|
||||||
|
|
||||||
echo "copy二进制文件"
|
echo "copy二进制文件"
|
||||||
cd $cpath/server
|
cd $cpath/server
|
||||||
# -tags osusergo,netgo,sqlite_omit_load_extension
|
# -tags osusergo,netgo,sqlite_omit_load_extension
|
||||||
flags="-trimpath"
|
flags="-trimpath"
|
||||||
ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.date=$(date --iso-8601=seconds)"
|
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
|
#github action
|
||||||
gopath=$(go env GOPATH)
|
gopath=/go
|
||||||
|
|
||||||
|
dockercmd=$(
|
||||||
|
cat <<EOF
|
||||||
|
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
||||||
|
apk add gcc g++ musl musl-dev
|
||||||
|
export GOPROXY=https://goproxy.cn
|
||||||
go mod tidy
|
go mod tidy
|
||||||
# alpine3
|
echo "build:"
|
||||||
apk add gcc musl-dev
|
export CGO_ENABLED=1
|
||||||
|
go build -v -o anylink_amd64 $flags -ldflags "$ldflags"
|
||||||
|
./anylink_amd64 -v
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
#使用 musl-dev 编译
|
#使用 musl-dev 编译
|
||||||
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/amd64 \
|
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/amd64 \
|
||||||
golang:1.20-alpine3.19 go build -o anylink_amd64 $flags -ldflags "$ldflags"
|
golang:1.20-alpine3.19 sh -c "$dockercmd"
|
||||||
./anylink_amd64 -v
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
#arm64编译
|
#arm64编译
|
||||||
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/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"
|
golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags"
|
|
@ -57,30 +57,30 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
|
||||||
switch pl.Data[6] {
|
switch pl.Data[6] {
|
||||||
case 0x07: // KEEPALIVE
|
case 0x07: // KEEPALIVE
|
||||||
// do nothing
|
// do nothing
|
||||||
// base.Debug("recv keepalive", cSess.IpAddr)
|
base.Trace("recv LinkCstp Keepalive", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
// 判断超时时间
|
// 判断超时时间
|
||||||
if checkIdle {
|
if checkIdle {
|
||||||
lastTime = cSess.LastDataTime.Load()
|
lastTime = cSess.LastDataTime.Load()
|
||||||
if lastTime.Before(utils.NowSec().Add(-idle)) {
|
if lastTime.Before(utils.NowSec().Add(-idle)) {
|
||||||
base.Warn("IdleTimeout", cSess.Username, cSess.IpAddr, "lastTime", lastTime)
|
base.Warn("IdleTimeout", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), "lastTime", lastTime)
|
||||||
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserIdleTimeout)
|
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserIdleTimeout)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 0x05: // DISCONNECT
|
case 0x05: // DISCONNECT
|
||||||
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
||||||
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr)
|
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserLogoutClient)
|
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserLogoutClient)
|
||||||
return
|
return
|
||||||
case 0x03: // DPD-REQ
|
case 0x03: // DPD-REQ
|
||||||
// base.Debug("recv DPD-REQ", cSess.IpAddr)
|
base.Trace("recv LinkCstp DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
pl.PType = 0x04
|
pl.PType = 0x04
|
||||||
pl.Data = pl.Data[:n]
|
pl.Data = pl.Data[:n]
|
||||||
if payloadOutCstp(cSess, pl) {
|
if payloadOutCstp(cSess, pl) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 0x04:
|
case 0x04:
|
||||||
// log.Println("recv DPD-RESP")
|
base.Trace("recv LinkCstp DPD-RESP", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
case 0x08: // decompress
|
case 0x08: // decompress
|
||||||
if cSess.CstpPickCmp == nil {
|
if cSess.CstpPickCmp == nil {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -56,20 +56,20 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
|
||||||
switch pl.Data[0] {
|
switch pl.Data[0] {
|
||||||
case 0x07: // KEEPALIVE
|
case 0x07: // KEEPALIVE
|
||||||
// do nothing
|
// do nothing
|
||||||
// base.Debug("recv keepalive", cSess.IpAddr)
|
base.Trace("recv LinkDtls Keepalive", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
case 0x05: // DISCONNECT
|
case 0x05: // DISCONNECT
|
||||||
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
cSess.UserLogoutCode = dbdata.UserLogoutClient
|
||||||
base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr)
|
base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
return
|
return
|
||||||
case 0x03: // DPD-REQ
|
case 0x03: // DPD-REQ
|
||||||
// base.Debug("recv DPD-REQ", cSess.IpAddr)
|
base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
pl.PType = 0x04
|
pl.PType = 0x04
|
||||||
pl.Data = pl.Data[:n]
|
pl.Data = pl.Data[:n]
|
||||||
if payloadOutDtls(cSess, dSess, pl) {
|
if payloadOutDtls(cSess, dSess, pl) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 0x04:
|
case 0x04:
|
||||||
// base.Debug("recv DPD-RESP", cSess.IpAddr)
|
base.Trace("recv LinkDtls DPD-RESP", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
|
||||||
case 0x08: // decompress
|
case 0x08: // decompress
|
||||||
if cSess.DtlsPickCmp == nil {
|
if cSess.DtlsPickCmp == nil {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue