mirror of
https://github.com/netbirdio/netbird.git
synced 2025-04-25 03:49:29 +02:00
Handle read config file errors
This commit is contained in:
parent
4587f7686e
commit
1e250fc0df
@ -22,13 +22,16 @@ var (
|
|||||||
os.Exit(ExitSetupFailed)
|
os.Exit(ExitSetupFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
config, _ := Read(configPath)
|
config, err := Read(configPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error reading config file, message: %v", err)
|
||||||
|
}
|
||||||
config.Peers = append(config.Peers, connection.Peer{
|
config.Peers = append(config.Peers, connection.Peer{
|
||||||
WgPubKey: key,
|
WgPubKey: key,
|
||||||
WgAllowedIps: allowedIPs,
|
WgAllowedIps: allowedIPs,
|
||||||
})
|
})
|
||||||
|
|
||||||
err := config.Write(configPath)
|
err = config.Write(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed writing config to %s: %s", config, err.Error())
|
log.Errorf("failed writing config to %s: %s", config, err.Error())
|
||||||
os.Exit(ExitSetupFailed)
|
os.Exit(ExitSetupFailed)
|
||||||
|
@ -17,7 +17,10 @@ var (
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
InitLog(logLevel)
|
InitLog(logLevel)
|
||||||
|
|
||||||
config, _ := Read(configPath)
|
config, err := Read(configPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error reading config file, message: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
myKey, err := wgtypes.ParseKey(config.PrivateKey)
|
myKey, err := wgtypes.ParseKey(config.PrivateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user