High Availability daemon to share an IP around N servers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zoreide/conf.go

53 lines
1.2 KiB

package main
import (
"encoding/json"
"io/ioutil"
"log"
"os"
)
type AbstractConfig struct {
MulticastConfig struct {
MIPAddr string `json:"MIpAddr"`
MPort string `json:"MPort"`
} `json:"MulticastConfig"`
InterfaceConfig struct {
ExistingInterface string `json:"ExistingInterface"`
BridgeIPCIDR string `json:"BridgeIpCIDR"`
} `json:"InterfaceConfig"`
}
var a AbstractConfig
func init() {
//reading json file
file, err := ioutil.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 = numberlenght
ZoreideBridge.BridgeIpCIDR = a.InterfaceConfig.BridgeIPCIDR
ZoreideBridge.ExistingInterface = a.InterfaceConfig.ExistingInterface
ZoreideBridge.IsActive = false
ZoreideBridge.IsAlpha = true
log.Println("Inizialized Generic Config: ", a)
log.Println("Inizialized Interface Config: ", ZoreideBridge)
log.Println("Inizialized Multicast Config: ", MulticastEntity)
}