From bd0471d2fe1a6f4fdf99e0aed4c7d0c889a76e1f Mon Sep 17 00:00:00 2001 From: Tamagoham Date: Tue, 16 Jul 2024 20:39:42 +0200 Subject: [PATCH] :warning: change multicast ttl --- go.mod | 5 ++++- go.sum | 2 ++ internal/app/publish/publisher.go | 11 +++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9edc4fc1..d8e96345 100644 --- a/go.mod +++ b/go.mod @@ -11,4 +11,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 ) -require golang.org/x/net v0.23.0 // indirect +require ( + golang.org/x/net v0.23.0 // indirect + golang.org/x/sys v0.18.0 // indirect +) diff --git a/go.sum b/go.sum index ae832906..2ea348d0 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= diff --git a/internal/app/publish/publisher.go b/internal/app/publish/publisher.go index 58ae9aab..39eb77d3 100644 --- a/internal/app/publish/publisher.go +++ b/internal/app/publish/publisher.go @@ -1,10 +1,12 @@ package publish import ( - "github.com/RoboCup-SSL/ssl-game-controller/internal/app/state" - "google.golang.org/protobuf/proto" "log" "net" + + "github.com/RoboCup-SSL/ssl-game-controller/internal/app/state" + "golang.org/x/net/ipv4" + "google.golang.org/protobuf/proto" ) const maxDatagramSize = 8192 @@ -51,6 +53,11 @@ func (p *Publisher) connect() bool { log.Printf("Could not connect to '%v': %v", addr, err) continue } + conn2 := ipv4.NewPacketConn(conn) + err = conn2.SetMulticastTTL(32) + if err != nil { + log.Printf("Could not set TTL to 32: %v", err) + } if err := conn.SetWriteBuffer(maxDatagramSize); err != nil { log.Printf("Could not set write buffer to %v.", maxDatagramSize)