Adding check against garbage in multicast

master
Uriel Fanelli 2023-08-13 12:24:12 +02:00
parent ba3ba3099b
commit e0bac1798a
1 changed files with 10 additions and 1 deletions

View File

@ -81,7 +81,16 @@ func (b *AbstractBridge) HierarchyReLocator(entity AbstractMulticast) {
re := regexp.MustCompile("[0-9]+") re := regexp.MustCompile("[0-9]+")
for bstNumber := range BstChannel { for bstNumber := range BstChannel {
bstNumber = re.FindAllString(bstNumber, -1)[0]
cleanStr := re.FindAllString(bstNumber, -1)
if cleanStr == nil {
log.Println("No numbers in multicast: ", bstNumber)
continue
} else {
log.Println("Extracted numbers in multicast: ", cleanStr)
bstNumber = cleanStr[0]
}
brdNumber, err := strconv.ParseInt(bstNumber, 10, 64) brdNumber, err := strconv.ParseInt(bstNumber, 10, 64)
if err != nil { if err != nil {
log.Println("Garbage received on multicast: ", bstNumber) log.Println("Garbage received on multicast: ", bstNumber)