Skip to content

Commit

Permalink
chore: quick fixes
Browse files Browse the repository at this point in the history
Some field reorderings that missed previous PR.

Signed-off-by: Dmitriy Matrenichev <[email protected]>
  • Loading branch information
DmitriyMV committed Mar 22, 2024
1 parent 9300968 commit 5422b1c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
4 changes: 1 addition & 3 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ type NodeProvisioner interface {
}

// Config configures the server.
//
//nolint:govet
type Config struct {
NodeProvisioner NodeProvisioner
ServerAddress netip.Addr
ServerEndpoint netip.AddrPort
VirtualPrefix netip.Prefix
Logger *zap.Logger
JoinToken string
ServerPublicKey wgtypes.Key
Logger *zap.Logger
}

// NewServer initializes new server.
Expand Down
4 changes: 1 addition & 3 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ import (
)

// Config is the configuration for the agent.
//
//nolint:govet
type Config struct {
WireguardEndpoint string // WireguardEndpoint is the endpoint for the Wireguard server.
APIEndpoint string // APIEndpoint is the gRPC endpoint for the SideroLink API.
JoinToken string // JoinToken is the join token for the SideroLink API.
ForceUserspace bool // ForceUserspace forces the usage of the userspace UDP device for Wireguard.
SinkEndpoint string // SinkEndpoint is the gRPC endpoint for the event sink.
LogEndpoint string // LogEndpoint is the TCP log receiver endpoint.
UUIDIPv6Pairs []string // UUIDIPv6Pairs is a list of UUIDs=IPv6 addrs for the nodes.
ForceUserspace bool // ForceUserspace forces the usage of the userspace UDP device for Wireguard.
}

// Run runs the agent. [wireguard.PeerHandler] can be nil.
Expand Down
16 changes: 7 additions & 9 deletions pkg/agent/siderolink.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@ import (
"github.com/siderolabs/siderolink/pkg/wireguard"
)

//nolint:govet
type sideroLinkConfig struct {
wireguardEndpoint string
apiEndpoint string
joinToken string
forceUserspace bool
predefinedPairs []bindUUIDtoIPv6
forceUserspace bool
}

//nolint:govet
type bindUUIDtoIPv6 struct {
UUID string
IPv6 netip.Addr
UUID string
}

func sideroLink(ctx context.Context, eg *errgroup.Group, cfg sideroLinkConfig, peerHandler wireguard.PeerHandler, logger *zap.Logger) error {
Expand Down Expand Up @@ -80,14 +78,14 @@ func sideroLink(ctx context.Context, eg *errgroup.Group, cfg sideroLinkConfig, p

wgDevice, err := wireguard.NewDevice(
wireguard.DeviceConfig{
PrivateKey: privateKey,
ServerPrefix: serverPrefix,
ListenPort: wireguardEndpoint.Port(),
ForceUserspace: cfg.forceUserspace,
Bind: wgbind.NewServerBind(conn.NewDefaultBind(), grpcEndpointsPrefix, pt, logger),
AutoPeerRemoveInterval: 10 * time.Second,
PeerHandler: p,
Logger: logger,
ServerPrefix: serverPrefix,
PrivateKey: privateKey,
AutoPeerRemoveInterval: 10 * time.Second,
ListenPort: wireguardEndpoint.Port(),
ForceUserspace: cfg.forceUserspace,
},
)
if err != nil {
Expand Down
22 changes: 10 additions & 12 deletions pkg/wireguard/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,23 @@ type Device struct {
}

// DeviceConfig is the configuration for the wireguard device.
//
//nolint:govet
type DeviceConfig struct {
// PrivateKey is the server private key.
PrivateKey wgtypes.Key
// ServerPrefix is the prefix to bind to the wireguard device.
ServerPrefix netip.Prefix
// ListenPort is the port to listen on. If zero, a random port is used.
ListenPort uint16
// ForceUserspace forces the use of userspace wireguard implementation. If Bind is set this field is always true.
ForceUserspace bool
// Bind is the bind configuration for the wireguard device. If nil the default bind is used.
Bind conn.Bind
// AutoPeerRemoveInterval is the checks interval to remove downed peers. If zero, it's disabled.
AutoPeerRemoveInterval time.Duration
// PeerHandler is the optional handler for peer events.
PeerHandler PeerHandler
// Logger is the logger to use.
Logger *zap.Logger
// ServerPrefix is the prefix to bind to the wireguard device.
ServerPrefix netip.Prefix
// PrivateKey is the server private key.
PrivateKey wgtypes.Key
// AutoPeerRemoveInterval is the checks interval to remove downed peers. If zero, it's disabled.
AutoPeerRemoveInterval time.Duration
// ListenPort is the port to listen on. If zero, a random port is used.
ListenPort uint16
// ForceUserspace forces the use of userspace wireguard implementation. If Bind is set this field is always true.
ForceUserspace bool
}

// PeerHandler is an interface for handling peer events.
Expand Down

0 comments on commit 5422b1c

Please sign in to comment.