mirror of
				https://codeberg.org/cunicu/cunicu.git
				synced 2025-10-31 18:22:38 +08:00 
			
		
		
		
	fix golangci-lint errors
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -92,3 +92,5 @@ require ( | ||||
| 	kernel.org/pub/linux/libs/security/libcap/psx v1.2.69 // indirect | ||||
| 	rsc.io/qr v0.2.0 // indirect | ||||
| ) | ||||
|  | ||||
| // replace github.com/stv0g/gont/v2 => ../gont | ||||
|   | ||||
| @@ -31,6 +31,7 @@ var ( | ||||
| 	errSwitchToIdle                     = errors.New("failed to switch to idle state") | ||||
| 	errStillIdle                        = errors.New("not connected yet") | ||||
| 	errClosing                          = errors.New("already closing") | ||||
| 	errInvalidConnectionStateForRestart = errors.New("can not restart agent while in state") | ||||
| ) | ||||
|  | ||||
| type Peer struct { | ||||
| @@ -235,7 +236,7 @@ func (p *Peer) Restart() error { | ||||
| 	invalidRestartStates := []ConnectionState{ConnectionStateClosed, ConnectionStateClosing, ConnectionStateRestarting} | ||||
|  | ||||
| 	if prev, ok := p.connectionState.SetIfNot(ConnectionStateRestarting, invalidRestartStates...); !ok { | ||||
| 		return fmt.Errorf("can not restart agent while in state: %s", strings.ToLower(prev.String())) | ||||
| 		return fmt.Errorf("%w: %s", errInvalidConnectionStateForRestart, strings.ToLower(prev.String())) | ||||
| 	} | ||||
|  | ||||
| 	p.logger.Debug("Restarting ICE session") | ||||
|   | ||||
| @@ -12,6 +12,8 @@ import ( | ||||
| 	wgdevice "golang.zx2c4.com/wireguard/device" | ||||
| ) | ||||
|  | ||||
| var errNotWireGuardLink = errors.New("link is not a WireGuard link") | ||||
|  | ||||
| type KernelDevice struct { | ||||
| 	link.Link | ||||
|  | ||||
| @@ -52,7 +54,7 @@ func FindKernelDevice(name string) (*KernelDevice, error) { | ||||
|  | ||||
| 	// TODO: Is this portable? | ||||
| 	if lnk.Type() != link.TypeWireGuard { | ||||
| 		return nil, fmt.Errorf("link '%s' is not a WireGuard link", lnk.Name()) | ||||
| 		return nil, fmt.Errorf("%w: %s", errNotWireGuardLink, lnk.Name()) | ||||
| 	} | ||||
|  | ||||
| 	return &KernelDevice{ | ||||
|   | ||||
| @@ -94,7 +94,7 @@ func Connect(path string) (*Client, error) { | ||||
| } | ||||
|  | ||||
| func (c *Client) Close() error { | ||||
| 	if err := c.conn.Close(); err != nil && !errors.Is(err, grpc.ErrClientConnClosing) { | ||||
| 	if err := c.conn.Close(); err != nil && status.Code(err) != codes.Canceled { | ||||
| 		return fmt.Errorf("failed to close gRPC client connection: %w", err) | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/stv0g/cunicu/pkg/crypto" | ||||
| @@ -11,6 +10,8 @@ import ( | ||||
| 	"github.com/stv0g/cunicu/pkg/signaling" | ||||
| 	"go.uber.org/zap" | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/status" | ||||
| ) | ||||
|  | ||||
| func init() { //nolint:gochecknoinits | ||||
| @@ -146,7 +147,7 @@ func (b *Backend) subscribeFromServer(ctx context.Context, pk *crypto.Key) error | ||||
| 			if err != nil { | ||||
| 				b.logger.Error("Subscription stream closed. Re-subscribing..", zap.Error(err)) | ||||
|  | ||||
| 				if err := b.subscribeFromServer(ctx, pk); err != nil && !errors.Is(err, grpc.ErrClientConnClosing) { | ||||
| 				if err := b.subscribeFromServer(ctx, pk); err != nil && status.Code(err) != codes.Canceled { | ||||
| 					b.logger.Error("Failed to resubscribe", zap.Error(err)) | ||||
| 				} | ||||
|  | ||||
|   | ||||
| @@ -62,7 +62,6 @@ func buildBinary(packagePath string) (string, []string, error) { | ||||
| 	} | ||||
|  | ||||
| 	runArgs := []string{} | ||||
| 	cmdArgs := []string{} | ||||
| 	profileArgs := profileArgs() | ||||
| 	buildArgs := []string{ | ||||
| 		"-buildvcs=false", // avoid build cache invalidation | ||||
| @@ -94,6 +93,7 @@ func buildBinary(packagePath string) (string, []string, error) { | ||||
|  | ||||
| 	logger := zap.L().Named("builder") | ||||
|  | ||||
| 	var cmdArgs []string | ||||
| 	var test bool | ||||
|  | ||||
| 	// Build a test binary if profiling is requested | ||||
| @@ -126,7 +126,7 @@ func buildBinary(packagePath string) (string, []string, error) { | ||||
| 		zap.Bool("test", test)) | ||||
|  | ||||
| 	if output, err := exec.Command("go", cmdArgs...).CombinedOutput(); err != nil { | ||||
| 		return "", nil, fmt.Errorf("Failed to build %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, path, string(output)) | ||||
| 		return "", nil, fmt.Errorf("ailed to build %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, path, string(output)) | ||||
| 	} | ||||
|  | ||||
| 	logger.Debug("Finished building", | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| package nodes | ||||
|  | ||||
| import ( | ||||
| 	"github.com/pion/ice/v2" | ||||
| 	"github.com/pion/stun" | ||||
| 	g "github.com/stv0g/gont/v2/pkg" | ||||
| ) | ||||
|  | ||||
| @@ -9,7 +9,7 @@ type RelayNode interface { | ||||
| 	Node | ||||
|  | ||||
| 	WaitReady() error | ||||
| 	URLs() []*ice.URL | ||||
| 	URLs() []*stun.URI | ||||
| 	Username() string | ||||
| 	Password() string | ||||
|  | ||||
|   | ||||
| @@ -9,7 +9,6 @@ import ( | ||||
| 	"strconv" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/pion/ice/v2" | ||||
| 	"github.com/pion/stun" | ||||
| 	g "github.com/stv0g/gont/v2/pkg" | ||||
| 	copt "github.com/stv0g/gont/v2/pkg/options/cmd" | ||||
| @@ -145,27 +144,27 @@ func (c *CoturnNode) WaitReady() error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (c *CoturnNode) URLs() []*ice.URL { | ||||
| func (c *CoturnNode) URLs() []*stun.URI { | ||||
| 	host := c.Name() | ||||
|  | ||||
| 	return []*ice.URL{ | ||||
| 	return []*stun.URI{ | ||||
| 		{ | ||||
| 			Scheme: ice.SchemeTypeSTUN, | ||||
| 			Scheme: stun.SchemeTypeSTUN, | ||||
| 			Host:   host, | ||||
| 			Port:   stun.DefaultPort, | ||||
| 			Proto:  ice.ProtoTypeUDP, | ||||
| 			Proto:  stun.ProtoTypeUDP, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Scheme: ice.SchemeTypeTURN, | ||||
| 			Scheme: stun.SchemeTypeTURN, | ||||
| 			Host:   host, | ||||
| 			Port:   stun.DefaultPort, | ||||
| 			Proto:  ice.ProtoTypeUDP, | ||||
| 			Proto:  stun.ProtoTypeUDP, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Scheme: ice.SchemeTypeTURN, | ||||
| 			Scheme: stun.SchemeTypeTURN, | ||||
| 			Host:   host, | ||||
| 			Port:   stun.DefaultPort, | ||||
| 			Proto:  ice.ProtoTypeTCP, | ||||
| 			Proto:  stun.ProtoTypeTCP, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -9,7 +9,7 @@ import ( | ||||
|  | ||||
| type RelayList []RelayNode | ||||
|  | ||||
| func AddRelayNodes(n *g.Network, numNodes int, opts ...g.Option) (RelayList, error) { | ||||
| func AddRelayNodes(n *g.Network, numNodes int, _ ...g.Option) (RelayList, error) { | ||||
| 	ns := RelayList{} | ||||
|  | ||||
| 	for i := 1; i <= numNodes; i++ { | ||||
|   | ||||
| @@ -9,7 +9,7 @@ import ( | ||||
|  | ||||
| type SignalingList []SignalingNode | ||||
|  | ||||
| func AddSignalingNodes(n *g.Network, numNodes int, opts ...g.Option) (SignalingList, error) { | ||||
| func AddSignalingNodes(n *g.Network, numNodes int, _ ...g.Option) (SignalingList, error) { | ||||
| 	ns := SignalingList{} | ||||
|  | ||||
| 	for i := 1; i <= numNodes; i++ { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Steffen Vogel
					Steffen Vogel