Skip to content

Commit 0a2b333

Browse files
committed
feature: Add option to skip certain interfaces for multicast
1 parent fcb273b commit 0a2b333

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

cmd/ssl-game-controller/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import (
99
"net/http"
1010
"os"
1111
"os/signal"
12+
"strings"
1213
"syscall"
1314
)
1415

1516
var address = flag.String("address", "localhost:8081", "The address on which the UI and API is served")
1617
var visionAddress = flag.String("visionAddress", "", "The address (ip+port) from which vision packages are received")
1718
var publishAddress = flag.String("publishAddress", "", "The address (ip+port) to which referee command should be sent")
1819
var timeAcquisitionMode = flag.String("timeAcquisitionMode", "", "The time acquisitionMode to use (system, ci, vision)")
20+
var skipInterfaces = flag.String("skipInterfaces", "", "Comma separated list of interface names to ignore when receiving multicast packets")
1921

2022
const configFileName = "config/ssl-game-controller.yaml"
2123

@@ -43,6 +45,9 @@ func setupGameController() {
4345
if timeAcquisitionMode != nil && *timeAcquisitionMode != "" {
4446
cfg.TimeAcquisitionMode = config.TimeAcquisitionMode(*timeAcquisitionMode)
4547
}
48+
if skipInterfaces != nil && *skipInterfaces != "" {
49+
cfg.Network.SkipInterfaces = parseSkipInterfaces()
50+
}
4651

4752
gameController := gc.NewGameController(cfg)
4853
gameController.Start()
@@ -68,3 +73,7 @@ func setupUi() {
6873
log.Print("Backend-only version started. Run the UI separately or get a binary that has the UI included")
6974
}
7075
}
76+
77+
func parseSkipInterfaces() []string {
78+
return strings.Split(*skipInterfaces, ",")
79+
}

config/ssl-game-controller.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ network:
33
publish-address: 224.5.23.1:10003
44
vision-address: 224.5.23.2:10006
55
tracker-address: 224.5.23.2:10010
6+
skip-interfaces: []
67
server:
78
auto-ref:
89
address: :10007

internal/app/config/config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ type Game struct {
6565

6666
// Network holds configs for network communication
6767
type Network struct {
68-
PublishAddress string `yaml:"publish-address"`
69-
VisionAddress string `yaml:"vision-address"`
70-
TrackerAddress string `yaml:"tracker-address"`
68+
PublishAddress string `yaml:"publish-address"`
69+
VisionAddress string `yaml:"vision-address"`
70+
TrackerAddress string `yaml:"tracker-address"`
71+
SkipInterfaces []string `yaml:"skip-interfaces"`
7172
}
7273

7374
// Server holds configs for the available server services
@@ -167,6 +168,7 @@ func DefaultControllerConfig() (c Controller) {
167168
c.Network.PublishAddress = "224.5.23.1:10003"
168169
c.Network.VisionAddress = "224.5.23.2:10006"
169170
c.Network.TrackerAddress = "224.5.23.2:10010"
171+
c.Network.SkipInterfaces = []string{}
170172
c.Game.StateStoreFile = "state-store.json.stream"
171173
c.Game.YellowCardDuration = 2 * time.Minute
172174
c.Game.YellowCardBotRemovalTime = 10 * time.Second

internal/app/config/testdata/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ network:
33
publish-address: 224.5.23.1:10003
44
vision-address: 224.5.23.2:10006
55
tracker-address: 224.5.23.2:10010
6+
skip-interfaces: []
67
server:
78
auto-ref:
89
address: :10007

internal/app/gc/gc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ func NewGameController(cfg config.Controller) (c *GameController) {
4949
c.ciServer = ci.NewServer(cfg.Server.Ci.Address)
5050
c.visionReceiver = vision.NewReceiver(cfg.Network.VisionAddress)
5151
c.visionReceiver.GeometryCallback = c.gcEngine.ProcessGeometry
52+
c.visionReceiver.MulticastReceiver.SkipInterfaces = cfg.Network.SkipInterfaces
5253
c.trackerReceiver = tracker.NewReceiver(cfg.Network.TrackerAddress)
5354
c.trackerReceiver.Callback = c.gcEngine.ProcessTrackerFrame
55+
c.trackerReceiver.MulticastReceiver.SkipInterfaces = cfg.Network.SkipInterfaces
5456
return
5557
}
5658

0 commit comments

Comments
 (0)