mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Move Core._applyOption
				
					
				
			This commit is contained in:
		
							parent
							
								
									c6fe81b5d2
								
							
						
					
					
						commit
						dad0b10dfe
					
				
					 2 changed files with 21 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue