This commit is contained in:
Neil Alexander 2019-09-02 13:31:19 +01:00
parent 7444c46aa1
commit 90fb1925f6
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 9 additions and 18 deletions

View file

@ -11,12 +11,7 @@ import (
) )
// Generates default configuration. This is used when outputting the -genconf // Generates default configuration. This is used when outputting the -genconf
// parameter and also when using -autoconf. The isAutoconf flag is used to // parameter and also when using -autoconf.
// determine whether the operating system should select a free port by itself
// (which guarantees that there will not be a conflict with any other services)
// or whether to generate a random port number. The only side effect of setting
// isAutoconf is that the TCP and UDP ports will likely end up with different
// port numbers.
func GenerateConfig() *NodeConfig { func GenerateConfig() *NodeConfig {
// Generate encryption keys. // Generate encryption keys.
bpub, bpriv := crypto.NewBoxKeys() bpub, bpriv := crypto.NewBoxKeys()
@ -128,14 +123,7 @@ func (cfg *NodeConfig) decodeConfig(dat map[string]interface{}) error {
tunnelrouting["IPv6RemoteSubnets"] = c tunnelrouting["IPv6RemoteSubnets"] = c
} }
} }
// Sanitise the config // Overlay our newly mapped configuration onto the NodeConfig
/*confJson, err := json.Marshal(dat)
if err != nil {
return err
}
json.Unmarshal(confJson, &cfg)*/
// Overlay our newly mapped configuration onto the autoconf node config that
// we generated above.
if err := mapstructure.Decode(dat, &cfg); err != nil { if err := mapstructure.Decode(dat, &cfg); err != nil {
return err return err
} }

View file

@ -1,6 +1,9 @@
package config package config
// NodeConfig defines all configuration values needed to run a signle yggdrasil node // NodeConfig defines all of the options which are used to configure an
// Yggdrasil node. Create a NodeConfig struct by using the
// config.GenerateConfig() function and then unmarshal JSON or HJSON on top by
// using the config.UnmarshalJSON() or config.UnmarshalHJSON() functions.
type NodeConfig struct { 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."` 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."`
InterfacePeers map[string][]string `comment:"List of connection strings for outbound peer connections in URI format,\narranged by source interface, e.g. { \"eth0\": [ tcp://a.b.c.d:e ] }.\nNote that SOCKS peerings will NOT be affected by this option and should\ngo in the \"Peers\" section instead."` InterfacePeers map[string][]string `comment:"List of connection strings for outbound peer connections in URI format,\narranged by source interface, e.g. { \"eth0\": [ tcp://a.b.c.d:e ] }.\nNote that SOCKS peerings will NOT be affected by this option and should\ngo in the \"Peers\" section instead."`
@ -23,7 +26,7 @@ type NodeConfig struct {
NodeInfo map[string]interface{} `comment:"Optional node info. This must be a { \"key\": \"value\", ... } map\nor set as null. This is entirely optional but, if set, is visible\nto the whole network on request."` NodeInfo map[string]interface{} `comment:"Optional node info. This must be a { \"key\": \"value\", ... } map\nor set as null. This is entirely optional but, if set, is visible\nto the whole network on request."`
} }
// TunnelRouting contains the crypto-key routing tables for tunneling // TunnelRouting contains the crypto-key routing tables for tunneling.
type TunnelRouting struct { type TunnelRouting struct {
Enable bool `comment:"Enable or disable tunnel routing."` Enable bool `comment:"Enable or disable tunnel routing."`
IPv6RemoteSubnets map[string]string `comment:"IPv6 subnets belonging to remote nodes, mapped to the node's public\nkey, e.g. { \"aaaa:bbbb:cccc::/e\": \"boxpubkey\", ... }"` IPv6RemoteSubnets map[string]string `comment:"IPv6 subnets belonging to remote nodes, mapped to the node's public\nkey, e.g. { \"aaaa:bbbb:cccc::/e\": \"boxpubkey\", ... }"`
@ -32,7 +35,7 @@ type TunnelRouting struct {
IPv4LocalSubnets []string `comment:"IPv4 subnets belonging to this node's end of the tunnels. Only traffic\nfrom these ranges will be tunnelled."` IPv4LocalSubnets []string `comment:"IPv4 subnets belonging to this node's end of the tunnels. Only traffic\nfrom these ranges will be tunnelled."`
} }
// SessionFirewall controls the session firewall configuration // SessionFirewall controls the session firewall configuration.
type SessionFirewall struct { type SessionFirewall struct {
Enable bool `comment:"Enable or disable the session firewall. If disabled, network traffic\nfrom any node will be allowed. If enabled, the below rules apply."` Enable bool `comment:"Enable or disable the session firewall. If disabled, network traffic\nfrom any node will be allowed. If enabled, the below rules apply."`
AllowFromDirect bool `comment:"Allow network traffic from directly connected peers."` AllowFromDirect bool `comment:"Allow network traffic from directly connected peers."`
@ -42,7 +45,7 @@ type SessionFirewall struct {
BlacklistEncryptionPublicKeys []string `comment:"List of public keys from which network traffic is always rejected,\nregardless of the whitelist, AllowFromDirect or AllowFromRemote."` BlacklistEncryptionPublicKeys []string `comment:"List of public keys from which network traffic is always rejected,\nregardless of the whitelist, AllowFromDirect or AllowFromRemote."`
} }
// SwitchOptions contains tuning options for the switch // SwitchOptions contains tuning options for the switch.
type SwitchOptions struct { type SwitchOptions struct {
MaxTotalQueueSize uint64 `comment:"Maximum size of all switch queues combined (in bytes)."` MaxTotalQueueSize uint64 `comment:"Maximum size of all switch queues combined (in bytes)."`
} }