Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
golangci-lint upgrade to v1.56.2 added more checks

Relates to pion/.goassets#201
  • Loading branch information
Sean-Der committed Mar 17, 2024
1 parent a9681a0 commit 9e4efcc
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestClientNonceExpiration(t *testing.T) {
assert.NoError(t, err)

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, realm string, _ net.Addr) (key []byte, ok bool) {
return GenerateAuthKey(username, realm, "pass"), true
},
PacketConnConfigs: []PacketConnConfig{
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestTCPClient(t *testing.T) {
require.NoError(t, err)

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, realm string, _ net.Addr) (key []byte, ok bool) {
return GenerateAuthKey(username, realm, "pass"), true
},
ListenerConfigs: []ListenerConfig{
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/add-software-attribute/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/log/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/perm-filter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/port-range/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
4 changes: 2 additions & 2 deletions examples/turn-server/simple-multithreaded/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
// UDP listeners share the same local address:port with setting SO_REUSEPORT and the kernel
// will load-balance received packets per the IP 5-tuple
listenerConfig := &net.ListenConfig{
Control: func(network, address string, conn syscall.RawConn) error {
Control: func(network, address string, conn syscall.RawConn) error { // nolint: revive
var operr error
if err = conn.Control(func(fd uintptr) {
operr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1)
Expand Down Expand Up @@ -90,7 +90,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/tcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
2 changes: 1 addition & 1 deletion examples/turn-server/tls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
// Set AuthHandler callback
// This is called every time a user tries to authenticate with the TURN server
// Return the key for that user, or false when no user is found
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) {
AuthHandler: func(username string, realm string, srcAddr net.Addr) ([]byte, bool) { // nolint: revive
if key, ok := usersMap[username]; ok {
return key, true
}
Expand Down
6 changes: 3 additions & 3 deletions internal/allocation/allocation_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func subTestManagerClose(t *testing.T, turnSocket net.PacketConn) {
}

func randomFiveTuple() *FiveTuple {
/* #nosec */
// nolint
return &FiveTuple{
SrcAddr: &net.UDPAddr{IP: nil, Port: rand.Int()},
DstAddr: &net.UDPAddr{IP: nil, Port: rand.Int()},
Expand All @@ -179,15 +179,15 @@ func newTestManager() (*Manager, error) {

config := ManagerConfig{
LeveledLogger: loggerFactory.NewLogger("test"),
AllocatePacketConn: func(network string, requestedPort int) (net.PacketConn, net.Addr, error) {
AllocatePacketConn: func(string, int) (net.PacketConn, net.Addr, error) {
conn, err := net.ListenPacket("udp4", "0.0.0.0:0")
if err != nil {
return nil, nil, err
}

return conn, conn.LocalAddr(), nil
},
AllocateConn: func(network string, requestedPort int) (net.Conn, net.Addr, error) { return nil, nil, nil },
AllocateConn: func(string, int) (net.Conn, net.Addr, error) { return nil, nil, nil },
}
return NewManager(config)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/client/tcp_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestTCPConn(t *testing.T) {
t.Run("Connect()", func(t *testing.T) {
var cid proto.ConnectionID = 5
client := &mockClient{
performTransaction: func(msg *stun.Message, to net.Addr, dontWait bool) (TransactionResult, error) {
performTransaction: func(msg *stun.Message, _ net.Addr, _ bool) (TransactionResult, error) {
if msg.Type.Class == stun.ClassRequest && msg.Type.Method == stun.MethodConnect {
msg, err := stun.Build(
stun.TransactionID,
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestTCPConn(t *testing.T) {
assert.Equal(t, cid, actualCid)

client = &mockClient{
performTransaction: func(msg *stun.Message, to net.Addr, dontWait bool) (TransactionResult, error) {
performTransaction: func(msg *stun.Message, _ net.Addr, _ bool) (TransactionResult, error) {
if msg.Type.Class == stun.ClassRequest && msg.Type.Method == stun.MethodConnect {
msg, err = stun.Build(
stun.TransactionID,
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestTCPConn(t *testing.T) {
var cid proto.ConnectionID = 5
loggerFactory := logging.NewDefaultLoggerFactory()
client := &mockClient{
performTransaction: func(msg *stun.Message, to net.Addr, dontWait bool) (TransactionResult, error) {
performTransaction: func(msg *stun.Message, _ net.Addr, _ bool) (TransactionResult, error) {
typ := stun.NewType(stun.MethodConnect, stun.ClassSuccessResponse)
if msg.Type.Method == stun.MethodCreatePermission {
typ = stun.NewType(stun.MethodCreatePermission, stun.ClassSuccessResponse)
Expand Down
6 changes: 3 additions & 3 deletions internal/client/udp_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func TestUDPConn(t *testing.T) {
t.Run("bind()", func(t *testing.T) {
client := &mockClient{
performTransaction: func(msg *stun.Message, to net.Addr, dontWait bool) (TransactionResult, error) {
performTransaction: func(*stun.Message, net.Addr, bool) (TransactionResult, error) {
return TransactionResult{}, errFake
},
}
Expand All @@ -40,10 +40,10 @@ func TestUDPConn(t *testing.T) {

t.Run("WriteTo()", func(t *testing.T) {
client := &mockClient{
performTransaction: func(msg *stun.Message, to net.Addr, dontWait bool) (TransactionResult, error) {
performTransaction: func(*stun.Message, net.Addr, bool) (TransactionResult, error) {
return TransactionResult{}, errFake
},
writeTo: func(data []byte, to net.Addr) (int, error) {
writeTo: func(data []byte, _ net.Addr) (int, error) {
return len(data), nil
},
}
Expand Down
6 changes: 3 additions & 3 deletions internal/proto/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (a attrs) pick(v byte) struct {
}

func FuzzSetters(f *testing.F) {
f.Fuzz(func(t *testing.T, attrType byte, value []byte) {
f.Fuzz(func(_ *testing.T, attrType byte, value []byte) {
var (
m1 = &stun.Message{
Raw: make([]byte, 0, 2048),
Expand Down Expand Up @@ -92,7 +92,7 @@ func FuzzSetters(f *testing.F) {
func FuzzChannelData(f *testing.F) {
d := &ChannelData{}

f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(_ *testing.T, data []byte) {
d.Reset()

if len(data) > channelDataHeaderSize {
Expand Down Expand Up @@ -123,7 +123,7 @@ func FuzzChannelData(f *testing.F) {
}

func FuzzIsChannelData(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(_ *testing.T, data []byte) {
IsChannelData(data)
})
}
6 changes: 3 additions & 3 deletions internal/server/turn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ func TestAllocationLifeTime(t *testing.T) {
logger := logging.NewDefaultLoggerFactory().NewLogger("turn")

allocationManager, err := allocation.NewManager(allocation.ManagerConfig{
AllocatePacketConn: func(network string, requestedPort int) (net.PacketConn, net.Addr, error) {
AllocatePacketConn: func(network string, _ int) (net.PacketConn, net.Addr, error) {
conn, listenErr := net.ListenPacket(network, "0.0.0.0:0")
if err != nil {
return nil, nil, listenErr
}

return conn, conn.LocalAddr(), nil
},
AllocateConn: func(network string, requestedPort int) (net.Conn, net.Addr, error) {
AllocateConn: func(string, int) (net.Conn, net.Addr, error) {
return nil, nil, nil
},
LeveledLogger: logger,
Expand All @@ -90,7 +90,7 @@ func TestAllocationLifeTime(t *testing.T) {
Conn: l,
SrcAddr: &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 5000},
Log: logger,
AuthHandler: func(username string, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(string, string, net.Addr) (key []byte, ok bool) {
return []byte(staticKey), true
},
}
Expand Down
12 changes: 6 additions & 6 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestServer(t *testing.T) {
assert.NoError(t, err)

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, _ string, _ net.Addr) (key []byte, ok bool) {
if pw, ok := credMap[username]; ok {
return pw, true
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestServer(t *testing.T) {
assert.NoError(t, err)

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, _ string, _ net.Addr) (key []byte, ok bool) {
if pw, ok := credMap[username]; ok {
return pw, true
}
Expand All @@ -150,7 +150,7 @@ func TestServer(t *testing.T) {

// make sure we can reuse the client port
dialer := &net.Dialer{
Control: func(network, address string, conn syscall.RawConn) error {
Control: func(_, _ string, conn syscall.RawConn) error {
return conn.Control(func(descriptor uintptr) {
_ = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
})
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestServer(t *testing.T) {
assert.NoError(t, err)

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, _ string, _ net.Addr) (key []byte, ok bool) {
if pw, ok := credMap[username]; ok {
return pw, true
}
Expand Down Expand Up @@ -453,7 +453,7 @@ func buildVNet() (*VNet, error) {
}

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, _ string, _ net.Addr) (key []byte, ok bool) {
if pw, ok := credMap[username]; ok {
return pw, true
}
Expand Down Expand Up @@ -591,7 +591,7 @@ func RunBenchmarkServer(b *testing.B, clientNum int) {
defer serverConn.Close() //nolint:errcheck

server, err := NewServer(ServerConfig{
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
AuthHandler: func(username, _ string, _ net.Addr) (key []byte, ok bool) {
if pw, ok := credMap[username]; ok {
return pw, true
}
Expand Down

0 comments on commit 9e4efcc

Please sign in to comment.