45 lines
909 B
Go
45 lines
909 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
"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)
|
|
}
|
|
|
|
MulticastEntity.MIpAddr = a.MulticastConfig.MIPAddr
|
|
MulticastEntity.MPort = a.MulticastConfig.MPort
|
|
MulticastEntity.MaxDatagramSize = a.MulticastConfig.MaxDatagramSize
|
|
|
|
ZoreideBridge.BridgeIpCIDR = a.InterfaceConfig.BridgeIPCIDR
|
|
ZoreideBridge.ExistingInterface = a.InterfaceConfig.ExistingInterface
|
|
|
|
if !a.Debug {
|
|
log.SetOutput(io.Discard)
|
|
}
|
|
|
|
log.Println("Inizialized Generic Config: ", a)
|
|
log.Println("Inizialized Interface Config: ", ZoreideBridge)
|
|
log.Println("Inizialized Multicast Config: ", MulticastEntity)
|
|
|
|
}
|