Skip to content

Commit 2649fec

Browse files
committed
Allow to choose a single network interface to publish referee messages
1 parent 74b1513 commit 2649fec

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

config/ssl-game-controller.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
time-acquisition-mode: system
22
network:
33
publish-address: 224.5.23.1:10003
4+
# set a network IP to only publish to that network - else messages will be published to all network interfaces
5+
publish-nif:
46
vision-address: 224.5.23.2:10006
57
tracker-address: 224.5.23.2:10010
68
skip-interfaces: []

internal/app/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ type Game struct {
6767
// Network holds configs for network communication
6868
type Network struct {
6969
PublishAddress string `yaml:"publish-address"`
70+
PublishNif string `yaml:"publish-nif"`
7071
VisionAddress string `yaml:"vision-address"`
7172
TrackerAddress string `yaml:"tracker-address"`
7273
SkipInterfaces []string `yaml:"skip-interfaces"`
@@ -167,6 +168,7 @@ func (c *Controller) WriteTo(fileName string) (err error) {
167168
// DefaultControllerConfig creates a config with default values
168169
func DefaultControllerConfig() (c Controller) {
169170
c.Network.PublishAddress = "224.5.23.1:10003"
171+
c.Network.PublishNif = ""
170172
c.Network.VisionAddress = "224.5.23.2:10006"
171173
c.Network.TrackerAddress = "224.5.23.2:10010"
172174
c.Network.SkipInterfaces = []string{}

internal/app/config/testdata/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
time-acquisition-mode: system
22
network:
33
publish-address: 224.5.23.1:10003
4+
publish-nif:
45
vision-address: 224.5.23.2:10006
56
tracker-address: 224.5.23.2:10010
67
skip-interfaces: []

internal/app/gc/gc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func NewGameController(cfg config.Controller) (c *GameController) {
3535
c.config = cfg
3636
c.gcEngine = engine.NewEngine(cfg.Game, cfg.Engine)
3737
c.messageGenerator = publish.NewMessageGenerator()
38-
c.publisher = publish.NewPublisher(c.config.Network.PublishAddress)
38+
c.publisher = publish.NewPublisher(c.config.Network.PublishAddress, c.config.Network.PublishNif)
3939
c.apiServer = api.NewServer(c.gcEngine)
4040
c.autoRefServer = rcon.NewAutoRefServer(cfg.Server.AutoRef.Address, c.gcEngine)
4141
c.autoRefServerTls = rcon.NewAutoRefServer(cfg.Server.AutoRef.AddressTls, c.gcEngine)

internal/app/publish/publisher.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ const maxDatagramSize = 8192
1212
// Publisher can publish state and commands to the teams
1313
type Publisher struct {
1414
address string
15+
nif string
1516
conns []*net.UDPConn
1617
}
1718

1819
// NewPublisher creates a new publisher that publishes referee messages via UDP to the teams
19-
func NewPublisher(address string) (p *Publisher) {
20+
func NewPublisher(address, nif string) (p *Publisher) {
2021
p = new(Publisher)
2122
p.address = address
23+
p.nif = nif
2224
p.conns = []*net.UDPConn{}
2325
return
2426
}
@@ -38,6 +40,9 @@ func (p *Publisher) connect() bool {
3840
if ip.To4() == nil {
3941
continue
4042
}
43+
if p.nif != "" && ip.String() != p.nif {
44+
continue
45+
}
4146
laddr := &net.UDPAddr{
4247
IP: ip,
4348
}

0 commit comments

Comments
 (0)