From dad0b10dfeb801049c6473e047fd22ff0e7b8e61 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 3 Sep 2022 10:51:44 +0100 Subject: [PATCH] Move `Core._applyOption` --- src/core/core.go | 21 --------------------- src/core/options.go | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/core/core.go b/src/core/core.go index 37a1d841..bc7ac831 100644 --- a/src/core/core.go +++ b/src/core/core.go @@ -88,27 +88,6 @@ func New(secret ed25519.PrivateKey, opts ...SetupOption) (*Core, error) { return c, nil } -func (c *Core) _applyOption(opt SetupOption) { - switch v := opt.(type) { - case Peer: - c.config._peers[v] = struct{}{} - case ListenAddress: - c.config._listeners[v] = struct{}{} - case NodeInfo: - c.config.nodeinfo = v - case NodeInfoPrivacy: - c.config.nodeinfoPrivacy = v - case IfName: - c.config.ifname = v - case IfMTU: - c.config.ifmtu = v - case AllowedPublicKey: - pk := [32]byte{} - copy(pk[:], v) - c.config._allowedPublicKeys[pk] = struct{}{} - } -} - // If any static peers were provided in the configuration above then we should // configure them. The loop ensures that disconnected peers will eventually // be reconnected with. diff --git a/src/core/options.go b/src/core/options.go index 0210a4ef..d46c9def 100644 --- a/src/core/options.go +++ b/src/core/options.go @@ -4,6 +4,27 @@ import ( "crypto/ed25519" ) +func (c *Core) _applyOption(opt SetupOption) { + switch v := opt.(type) { + case Peer: + c.config._peers[v] = struct{}{} + case ListenAddress: + c.config._listeners[v] = struct{}{} + case NodeInfo: + c.config.nodeinfo = v + case NodeInfoPrivacy: + c.config.nodeinfoPrivacy = v + case IfName: + c.config.ifname = v + case IfMTU: + c.config.ifmtu = v + case AllowedPublicKey: + pk := [32]byte{} + copy(pk[:], v) + c.config._allowedPublicKeys[pk] = struct{}{} + } +} + type SetupOption interface { isSetupOption() }