Skip to content

Commit 084744c

Browse files
enable tests in CI and dont copy atomics
1 parent c0e609b commit 084744c

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ jobs:
3939
run: go vet ./...
4040
working-directory: src
4141

42+
- name: Run tests
43+
run: go test ./...
44+
working-directory: src
45+
4246
- name: install staticcheck
4347
run: go install honnef.co/go/tools/cmd/staticcheck@latest
4448
working-directory: src
45-
49+
4650
- name: Lint code (staticcheck)
4751
run: staticcheck ./...
4852
working-directory: src
49-
50-
# - name: Run tests # on my machine, the tests hang, so I'm not running them here yet
51-
# run: go test ./...

src/mod/streamproxy/streamproxy.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ type ProxyRelayInstance struct {
6161
Timeout int //Timeout for connection in sec
6262

6363
/* Internal */
64-
tcpStopChan chan bool //Stop channel for TCP listener
65-
udpStopChan chan bool //Stop channel for UDP listener
66-
aTobAccumulatedByteTransfer atomic.Int64 //Accumulated byte transfer from A to B
67-
bToaAccumulatedByteTransfer atomic.Int64 //Accumulated byte transfer from B to A
68-
udpClientMap sync.Map //map storing the UDP client-server connections
69-
parent *Manager `json:"-"`
64+
tcpStopChan chan bool //Stop channel for TCP listener
65+
udpStopChan chan bool //Stop channel for UDP listener
66+
aTobAccumulatedByteTransfer *atomic.Int64 //Accumulated byte transfer from A to B
67+
bToaAccumulatedByteTransfer *atomic.Int64 //Accumulated byte transfer from B to A
68+
udpClientMap sync.Map //map storing the UDP client-server connections
69+
parent *Manager `json:"-"`
7070
}
7171

7272
type Options struct {
@@ -183,8 +183,8 @@ func (m *Manager) NewConfig(config *ProxyRelayOptions) string {
183183
Timeout: config.Timeout,
184184
tcpStopChan: nil,
185185
udpStopChan: nil,
186-
aTobAccumulatedByteTransfer: aAcc,
187-
bToaAccumulatedByteTransfer: bAcc,
186+
aTobAccumulatedByteTransfer: &aAcc,
187+
bToaAccumulatedByteTransfer: &bAcc,
188188
udpClientMap: sync.Map{},
189189
parent: m,
190190
}

src/mod/streamproxy/tcpprox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (c *ProxyRelayInstance) Port2host(allowPort string, targetAddress string, s
174174
}
175175
}
176176

177-
c.forward(target, conn, &c.aTobAccumulatedByteTransfer, &c.bToaAccumulatedByteTransfer)
177+
c.forward(target, conn, c.aTobAccumulatedByteTransfer, c.bToaAccumulatedByteTransfer)
178178
}(targetAddress)
179179
}
180180
}

0 commit comments

Comments
 (0)