mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-08 19:20:29 +00:00
Move Core._applyOption
This commit is contained in:
parent
c6fe81b5d2
commit
dad0b10dfe
@ -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.
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user