zoreide/conf.go

46 lines
990 B
Go
Raw Normal View History

2023-08-09 09:08:05 -05:00
package main
import (
"encoding/json"
"io"
2023-08-09 09:08:05 -05:00
"log"
"os"
)
var a AbstractConfig
func init() {
//reading json file
file, err := os.ReadFile("zoreide.json")
if err != nil {
log.Println("Cannot open config file", err.Error())
os.Exit(1)
}
err = json.Unmarshal([]byte(file), &a)
if err != nil {
log.Println("Cannot marshal json: ", err.Error())
os.Exit(1)
}
2023-08-14 12:51:04 -05:00
a.MulticastConfig.MaxDatagramSize = len("75568770-cee4-4506-a790-036e232fb1b3")
2023-08-09 09:08:05 -05:00
MulticastEntity.MIpAddr = a.MulticastConfig.MIPAddr
MulticastEntity.MPort = a.MulticastConfig.MPort
MulticastEntity.MaxDatagramSize = a.MulticastConfig.MaxDatagramSize
2023-08-09 09:08:05 -05:00
ZoreideBridge.BridgeIpCIDR = a.InterfaceConfig.BridgeIPCIDR
ZoreideBridge.ExistingInterface = a.InterfaceConfig.ExistingInterface
if !a.Debug {
log.SetOutput(io.Discard)
}
2023-08-09 09:08:05 -05:00
log.Println("Inizialized Generic Config: ", a)
log.Println("Inizialized Interface Config: ", ZoreideBridge)
log.Println("Inizialized Multicast Config: ", MulticastEntity)
}