forked from elghazal-a/autowire
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tidy, some unreachable code remains...
- Loading branch information
Showing
2 changed files
with
155 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
|
||
"flag" | ||
) | ||
|
||
|
||
// Config ... | ||
type Config struct { | ||
KVPrefix string | ||
LongKVPrefix string | ||
WGInterfaceName string | ||
WGConfigFolder string | ||
WGRange string | ||
WGPort int | ||
WGAllowedIPs string | ||
WGPostUp string | ||
InterfaceName string | ||
KVPrefix string | ||
LongKVPrefix string | ||
WGInterfaceName string | ||
WGConfigFolder string | ||
WGRange string | ||
WGPort int | ||
WGAllowedIPs string | ||
WGPostUp string | ||
InterfaceName string | ||
} | ||
|
||
var config Config | ||
|
||
func init() { | ||
flag.StringVar(&config.KVPrefix, "kv-prefix", "autowire", "Prefix in KV store where configurations will be stored") | ||
flag.StringVar(&config.WGInterfaceName, "wg-if-name", "wg0", "Wireguard interface name") | ||
flag.StringVar(&config.WGConfigFolder, "wg-config-folder", "/etc/wireguard", "Wireguard config folder") | ||
flag.StringVar(&config.WGRange, "wg-range", "192.168.10.0/24", "Wireguard CIDR") | ||
flag.IntVar(&config.WGPort, "wg-port", 51820, "Wireguard Port") | ||
flag.StringVar(&config.WGAllowedIPs, "allowed-ips", "", "Wireguard Allowed IPs (comma separated cidr)") | ||
flag.StringVar(&config.WGPostUp, "post-up", "", "steps to be run after the wireguard interface is up") | ||
flag.StringVar(&config.InterfaceName, "if-name", "", "The network ip address of this interface will be used for wireguard endpoint") | ||
flag.StringVar(&config.KVPrefix, "kv-prefix", "autowire", "Prefix in KV store where configurations will be stored") | ||
flag.StringVar(&config.WGInterfaceName, "wg-if-name", "wg0", "Wireguard interface name") | ||
flag.StringVar(&config.WGConfigFolder, "wg-config-folder", "/etc/wireguard", "Wireguard config folder") | ||
flag.StringVar(&config.WGRange, "wg-range", "192.168.10.0/24", "Wireguard CIDR") | ||
flag.IntVar(&config.WGPort, "wg-port", 51820, "Wireguard Port") | ||
flag.StringVar(&config.WGAllowedIPs, "allowed-ips", "", "Wireguard Allowed IPs (comma separated cidr)") | ||
flag.StringVar(&config.WGPostUp, "post-up", "", "steps to be run after the wireguard interface is up") | ||
flag.StringVar(&config.InterfaceName, "if-name", "", "The network ip address of this interface will be used for wireguard endpoint") | ||
} | ||
|
||
|
||
func initConfig() error { | ||
|
||
// ToDo: Update config from environment variables. | ||
// processEnv() | ||
// ToDo: Update config from environment variables. | ||
// processEnv() | ||
|
||
config.LongKVPrefix = config.KVPrefix + "/" + config.WGInterfaceName + "/" | ||
config.LongKVPrefix = config.KVPrefix + "/" + config.WGInterfaceName + "/" | ||
|
||
if config.WGAllowedIPs != "" { | ||
config.WGAllowedIPs = "," + config.WGAllowedIPs | ||
} | ||
if config.WGAllowedIPs != "" { | ||
config.WGAllowedIPs = "," + config.WGAllowedIPs | ||
} | ||
|
||
// if config.LogLevel != "" { | ||
// log.SetLevel(config.LogLevel) | ||
// } | ||
// if config.LogLevel != "" { | ||
// log.SetLevel(config.LogLevel) | ||
// } | ||
|
||
|
||
return nil | ||
} | ||
return nil | ||
} |
Oops, something went wrong.