Skip to content

Commit

Permalink
set dscp value (#32)
Browse files Browse the repository at this point in the history
* set dscp value

* update go mod

* linter
  • Loading branch information
loganmc10 authored Sep 6, 2023
1 parent 89c043e commit cb99340
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ require (
golang.org/x/net v0.14.0
)

require github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
require (
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
golang.org/x/sys v0.11.0 // indirect
)

require (
github.com/go-logr/logr v1.2.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
10 changes: 10 additions & 0 deletions internal/gameServer/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"math"
"net"
"time"

"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
)

type GameData struct {
Expand Down Expand Up @@ -37,6 +40,7 @@ const (
DisconnectTimeoutS = 30
NoRegID = 255
InputDataMax uint32 = 5000
CS4 = 32
)

// returns true if v is bigger than w (accounting for uint32 wrap around).
Expand Down Expand Up @@ -198,6 +202,12 @@ func (g *GameServer) createUDPServer() error {
if err != nil {
return err //nolint:wrapcheck
}
if err := ipv4.NewConn(g.UDPListener).SetTOS(CS4 << 2); err != nil { //nolint:gomnd
g.Logger.Error(err, "could not set IPv4 DSCP")
}
if err := ipv6.NewConn(g.UDPListener).SetTrafficClass(CS4 << 2); err != nil { //nolint:gomnd
g.Logger.Error(err, "could not set IPv6 DSCP")
}
g.Logger.Info("Created UDP server", "port", g.Port)

g.GameData.PlayerAddresses = make([]*net.UDPAddr, 4) //nolint:gomnd
Expand Down

0 comments on commit cb99340

Please sign in to comment.