Compare commits
No commits in common. "e6e6b90201796676ee736daa2a5a0d4b3375ab31" and "6c4f09f4cba6659cf6f50d518526665c0b7c4d3c" have entirely different histories.
e6e6b90201
...
6c4f09f4cb
|
@ -24,6 +24,7 @@ To compile it , you need:
|
||||||
Configuration contains:
|
Configuration contains:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
{
|
||||||
"MulticastConfig": {
|
"MulticastConfig": {
|
||||||
"MIpAddr": "239.0.0.19",
|
"MIpAddr": "239.0.0.19",
|
||||||
"MPort": "9898",
|
"MPort": "9898",
|
||||||
|
@ -32,8 +33,8 @@ Configuration contains:
|
||||||
"InterfaceConfig": {
|
"InterfaceConfig": {
|
||||||
"ExistingInterface": "eth0",
|
"ExistingInterface": "eth0",
|
||||||
"BridgeIpCIDR": "10.0.1.1/24"
|
"BridgeIpCIDR": "10.0.1.1/24"
|
||||||
},
|
}
|
||||||
"debug": false
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
|
@ -44,7 +45,6 @@ Where:
|
||||||
|
|
||||||
- ExistingInterface: the name of your ingress interface (eth0, eno0 , enps18, whatever your system is using. This may be different node by node)
|
- ExistingInterface: the name of your ingress interface (eth0, eno0 , enps18, whatever your system is using. This may be different node by node)
|
||||||
- BridgeIpCidr: the IP address and mask you want to share among servers.
|
- BridgeIpCidr: the IP address and mask you want to share among servers.
|
||||||
- wether you want debug logs or not.
|
|
||||||
|
|
||||||
|
|
||||||
# FAQ
|
# FAQ
|
||||||
|
|
7
conf.go
7
conf.go
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
@ -11,13 +10,11 @@ type AbstractConfig struct {
|
||||||
MulticastConfig struct {
|
MulticastConfig struct {
|
||||||
MIPAddr string `json:"MIpAddr"`
|
MIPAddr string `json:"MIpAddr"`
|
||||||
MPort string `json:"MPort"`
|
MPort string `json:"MPort"`
|
||||||
MaxDatagramSize int `json:"MaxDatagramSize"`
|
|
||||||
} `json:"MulticastConfig"`
|
} `json:"MulticastConfig"`
|
||||||
InterfaceConfig struct {
|
InterfaceConfig struct {
|
||||||
ExistingInterface string `json:"ExistingInterface"`
|
ExistingInterface string `json:"ExistingInterface"`
|
||||||
BridgeIPCIDR string `json:"BridgeIpCIDR"`
|
BridgeIPCIDR string `json:"BridgeIpCIDR"`
|
||||||
} `json:"InterfaceConfig"`
|
} `json:"InterfaceConfig"`
|
||||||
Debug bool `json:"debug"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var a AbstractConfig
|
var a AbstractConfig
|
||||||
|
@ -47,10 +44,6 @@ func init() {
|
||||||
ZoreideBridge.ExistingInterface = a.InterfaceConfig.ExistingInterface
|
ZoreideBridge.ExistingInterface = a.InterfaceConfig.ExistingInterface
|
||||||
ZoreideBridge.IsActive = false
|
ZoreideBridge.IsActive = false
|
||||||
|
|
||||||
if !a.Debug {
|
|
||||||
log.SetOutput(io.Discard)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Println("Inizialized Generic Config: ", a)
|
log.Println("Inizialized Generic Config: ", a)
|
||||||
log.Println("Inizialized Interface Config: ", ZoreideBridge)
|
log.Println("Inizialized Interface Config: ", ZoreideBridge)
|
||||||
log.Println("Inizialized Multicast Config: ", MulticastEntity)
|
log.Println("Inizialized Multicast Config: ", MulticastEntity)
|
||||||
|
|
12
interface.go
12
interface.go
|
@ -71,8 +71,6 @@ func (b *AbstractBridge) configureIpAndBridgeUp() {
|
||||||
|
|
||||||
if err := br.SetLinkIp(brIp, brIpNet); err != nil {
|
if err := br.SetLinkIp(brIp, brIpNet); err != nil {
|
||||||
log.Println("Error setting UP the IP: ", err.Error())
|
log.Println("Error setting UP the IP: ", err.Error())
|
||||||
} else {
|
|
||||||
log.Printf("%s configured with %s\n", b.ExistingInterface, brIp.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,22 +105,18 @@ func (b *AbstractBridge) removeIPandBridgeInt() {
|
||||||
|
|
||||||
func isActive(bridgeip string) bool {
|
func isActive(bridgeip string) bool {
|
||||||
|
|
||||||
log.Println("Check for active IP: ", bridgeip)
|
|
||||||
|
|
||||||
pinger, err := ping.NewPinger(bridgeip)
|
pinger, err := ping.NewPinger(bridgeip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Ping error: " + err.Error())
|
log.Println("Ping error: " + err.Error())
|
||||||
}
|
}
|
||||||
// just in case it doesn't stops alone
|
// just in case it doesn't stops alone
|
||||||
defer pinger.Stop()
|
defer pinger.Stop()
|
||||||
pinger.Count = 3
|
pinger.Count = 5
|
||||||
pinger.Interval = time.Duration(100 * time.Millisecond)
|
pinger.Interval = time.Duration(10 * time.Millisecond)
|
||||||
pinger.Timeout = time.Duration(1 * time.Second)
|
pinger.Timeout = time.Duration(1 * time.Second)
|
||||||
pinger.Run() // blocks until finished
|
pinger.Run() // blocks until finished
|
||||||
stats := pinger.Statistics()
|
stats := pinger.Statistics()
|
||||||
log.Println("Ping results for: ", bridgeip)
|
|
||||||
log.Printf("%d packet sent, %d packet recv", pinger.Count, stats.PacketsRecv)
|
|
||||||
|
|
||||||
return stats.PacketsRecv == pinger.Count
|
return stats.PacketsRecv == 5
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,20 +116,11 @@ func (b *AbstractBridge) WaitAndClean(entity AbstractMulticast) {
|
||||||
|
|
||||||
log.Println("Inizializing Escalator")
|
log.Println("Inizializing Escalator")
|
||||||
|
|
||||||
entity.AddUniqueAndSort(b.hIerarchyNumber)
|
|
||||||
|
|
||||||
brIp, _, err := net.ParseCIDR(b.BridgeIpCIDR)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
entity.AddUniqueAndSort(b.hIerarchyNumber)
|
||||||
pollTime := len(entity.HierarchyArray) + 1
|
pollTime := len(entity.HierarchyArray) + 1
|
||||||
time.Sleep(time.Duration(pollTime) * time.Second)
|
time.Sleep(time.Duration(pollTime) * time.Second)
|
||||||
// svuotare l'array e rifare le elezioni
|
// svuotare l'array
|
||||||
if !isActive(string(brIp.String())) {
|
|
||||||
entity.HierarchyArray = entity.HierarchyArray[:0]
|
entity.HierarchyArray = entity.HierarchyArray[:0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -7,6 +7,5 @@
|
||||||
"InterfaceConfig": {
|
"InterfaceConfig": {
|
||||||
"ExistingInterface": "eth0",
|
"ExistingInterface": "eth0",
|
||||||
"BridgeIpCIDR": "10.0.1.1/24"
|
"BridgeIpCIDR": "10.0.1.1/24"
|
||||||
},
|
}
|
||||||
"debug": false
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue