mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Refactoring: move tuntap and icmpv6 into separate package
This commit is contained in:
parent
67c670ab4c
commit
0b494a8255
20 changed files with 307 additions and 240 deletions
|
@ -2,11 +2,36 @@ package config
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"sync"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
)
|
||||
|
||||
// NodeState represents the active and previous configuration of the node and
|
||||
// protects it with a mutex
|
||||
type NodeState struct {
|
||||
Current NodeConfig
|
||||
Previous NodeConfig
|
||||
Mutex sync.RWMutex
|
||||
}
|
||||
|
||||
// Get returns both the current and previous node configs
|
||||
func (s *NodeState) Get() (NodeConfig, NodeConfig) {
|
||||
s.Mutex.RLock()
|
||||
defer s.Mutex.RUnlock()
|
||||
return s.Current, s.Previous
|
||||
}
|
||||
|
||||
// Replace the node configuration with new configuration
|
||||
func (s *NodeState) Replace(n NodeConfig) NodeConfig {
|
||||
s.Mutex.Lock()
|
||||
defer s.Mutex.Unlock()
|
||||
s.Previous = s.Current
|
||||
s.Current = n
|
||||
return s.Current
|
||||
}
|
||||
|
||||
// NodeConfig defines all configuration values needed to run a signle yggdrasil node
|
||||
type NodeConfig struct {
|
||||
Peers []string `comment:"List of connection strings for outbound peer connections in URI format,\ne.g. tcp://a.b.c.d:e or socks://a.b.c.d:e/f.g.h.i:j. These connections\nwill obey the operating system routing table, therefore you should\nuse this section when you may connect via different interfaces."`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue