Skip to content

Commit

Permalink
opt
Browse files Browse the repository at this point in the history
  • Loading branch information
itviewer committed May 2, 2024
1 parent e0ba441 commit 25da470
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
with:
submodules: 'recursive'
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.22.0
go-version: 'stable'
- name: Install dependencies
run: go get .
- name: Build
Expand Down
27 changes: 17 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,50 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, linux-arm64, linux-armv7, linux-mipsle, windows, windows-arm64, macos, macos-arm64]
build: [linux, linux-riscv64, linux-arm64, linux-armv7, linux-mipsle, windows, windows-arm64, macos, macos-arm64]
include:
- build: linux
os: ubuntu-20.04
go: 1.22.1
go: 'stable'
archive-name: sslcon-linux-amd64.tar.gz
- build: linux-riscv64
os: ubuntu-20.04
go: 'stable'
archive-name: sslcon-linux-riscv64.tar.gz
- build: linux-arm64
os: ubuntu-20.04
go: 1.22.1
go: 'stable'
archive-name: sslcon-linux-arm64.tar.gz
- build: linux-armv7
os: ubuntu-20.04
go: 1.22.1
go: 'stable'
archive-name: sslcon-linux-armv7.tar.gz
- build: linux-mipsle
os: ubuntu-20.04
go: 1.22.1
go: 'stable'
archive-name: sslcon-linux-mipsle.tar.gz
- build: windows
os: windows-2019
go: 1.22.1
go: 'stable'
archive-name: sslcon-windows10-amd64.7z
- build: windows-arm64
os: windows-2019
go: 1.22.1
go: 'stable'
archive-name: sslcon-windows10-arm64.7z
- build: macos
os: macos-12
go: 1.22.1
go: 'stable'
archive-name: sslcon-macOS-amd64.tar.gz
- build: macos-arm64
os: macos-14
go: 1.22.1
go: 'stable'
archive-name: sslcon-macOS-arm64.tar.gz
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Install dependencies
Expand All @@ -65,6 +69,9 @@ jobs:
if [ "${{ matrix.build }}" = "linux" ]; then
go build -trimpath -ldflags "-s -w" -o vpnagent vpnagent.go
go build -trimpath -ldflags "-s -w" -o sslcon sslcon.go
elif [ "${{ matrix.build }}" = "linux-riscv64" ]; then
GOOS=linux GOARCH=riscv64 go build -trimpath -ldflags "-s -w" -o vpnagent vpnagent.go
GOOS=linux GOARCH=riscv64 go build -trimpath -ldflags "-s -w" -o sslcon sslcon.go
elif [ "${{ matrix.build }}" = "linux-arm64" ]; then
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o vpnagent vpnagent.go
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o sslcon sslcon.go
Expand Down
12 changes: 6 additions & 6 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (cSess *ConnSession) DPDTimer() {
if dpdTime < 10 {
dpdTime = 10
}
tick := time.NewTicker(time.Duration(dpdTime) * time.Second)
ticker := time.NewTicker(time.Duration(dpdTime) * time.Second)

tlsDpd := proto.Payload{
Type: 0x03,
Expand All @@ -178,7 +178,7 @@ func (cSess *ConnSession) DPDTimer() {

for {
select {
case <-tick.C:
case <-ticker.C:
// base.Debug("dead peer detection")
select {
case cSess.PayloadOutTLS <- &tlsDpd:
Expand All @@ -191,7 +191,7 @@ func (cSess *ConnSession) DPDTimer() {
}
}
case <-cSess.CloseChan:
tick.Stop()
ticker.Stop()
return
}
}
Expand All @@ -205,11 +205,11 @@ func (cSess *ConnSession) ReadDeadTimer() {
}()
// 避免每次 for 循环都重置读超时的时间
// 这里是绝对时间,至于链接本身,服务器没有数据时 conn.Read 会阻塞,有数据时会不断判断
tick := time.NewTicker(4 * time.Second)
for range tick.C {
ticker := time.NewTicker(4 * time.Second)
for range ticker.C {
select {
case <-cSess.CloseChan:
tick.Stop()
ticker.Stop()
return
default:
cSess.ResetTLSReadDead.Store(true)
Expand Down

0 comments on commit 25da470

Please sign in to comment.