Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,42 @@ jobs:
with:
go-version: "1.24.x"
go-generate-ignore-protoc-version-comments: true

golangci-lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [ "1.23.x", "1.24.x" ]
env:
GOLANGCI_LINT_VERSION: v2.0.2
name: golangci-lint (Go ${{ matrix.go }})
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: golangci-lint (Linux)
uses: golangci/golangci-lint-action@v7
with:
args: --timeout=5m
version: ${{ env.GOLANGCI_LINT_VERSION }}
only-new-issues: true
- name: golangci-lint (Windows)
if: success() || failure() # run this step even if the previous one failed
uses: golangci/golangci-lint-action@v7
env:
GOOS: "windows"
with:
args: --timeout=5m
version: ${{ env.GOLANGCI_LINT_VERSION }}
only-new-issues: true
- name: golangci-lint (OSX)
if: success() || failure() # run this step even if the previous one failed
uses: golangci/golangci-lint-action@v7
env:
GOOS: "darwin"
with:
args: --timeout=5m
version: ${{ env.GOLANGCI_LINT_VERSION }}
only-new-issues: true
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "2"

run:
timeout: 5m

linters:
enable:
- revive
- unused
- prealloc

settings:
revive:
severity: warning
rules:
- name: unused-parameter
severity: warning

severity:
default: warning

4 changes: 2 additions & 2 deletions p2p/protocol/autonatv2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (as *server) serveDialRequest(s network.Stream) EventDialRequestCompleted {
nonce := msg.GetDialRequest().Nonce

isDialDataRequired := as.dialDataRequestPolicy(s.Conn().RemoteMultiaddr(), dialAddr)
if isDialDataRequired && !as.limiter.AcceptDialDataRequest(p) {
if isDialDataRequired && !as.limiter.AcceptDialDataRequest() {
msg = pb.Message{
Msg: &pb.Message_DialResponse{
DialResponse: &pb.DialResponse{
Expand Down Expand Up @@ -442,7 +442,7 @@ func (r *rateLimiter) Accept(p peer.ID) bool {
return true
}

func (r *rateLimiter) AcceptDialDataRequest(p peer.ID) bool {
func (r *rateLimiter) AcceptDialDataRequest() bool {
r.mu.Lock()
defer r.mu.Unlock()
if r.closed {
Expand Down
2 changes: 1 addition & 1 deletion p2p/protocol/autonatv2/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func TestRateLimiterStress(t *testing.T) {
success.Add(1)
peerSuccesses[j].Add(1)
}
if r.AcceptDialDataRequest(p) {
if r.AcceptDialDataRequest() {
dialDataSuccesses.Add(1)
}
r.CompleteRequest(p)
Expand Down