Skip to content

Commit 637f796

Browse files
committed
[bugfix] Add verification to rejected messages as well
Team and autoRef connections were downgraded to unverified state when a request was rejected. For requests like changing the goal keeper, this is not reasonable. The connection is still closed after sending the reject, when the registration was rejected.
1 parent 0b1f3e4 commit 637f796

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

cmd/ssl-team-client/main.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/golang/protobuf/proto"
1010
"log"
1111
"net"
12+
"time"
1213
)
1314

1415
var udpAddress = flag.String("udpAddress", "224.5.23.1:10003", "The multicast address of ssl-game-controller")
@@ -47,7 +48,9 @@ func main() {
4748
c.conn = conn
4849

4950
c.register()
50-
c.sendDesiredKeeper(3)
51+
for !c.sendDesiredKeeper(3) {
52+
time.Sleep(time.Second)
53+
}
5154

5255
for {
5356
c.ReplyToChoices()
@@ -93,10 +96,10 @@ func (c *Client) register() {
9396
}
9497
}
9598

96-
func (c *Client) sendDesiredKeeper(id int32) {
99+
func (c *Client) sendDesiredKeeper(id int32) (accepted bool) {
97100
message := refproto.TeamToController_DesiredKeeper{DesiredKeeper: id}
98101
request := refproto.TeamToController{Msg: &message}
99-
c.sendRequest(&request)
102+
return c.sendRequest(&request)
100103
}
101104

102105
func (c *Client) ReplyToChoices() {
@@ -112,7 +115,7 @@ func (c *Client) ReplyToChoices() {
112115
c.sendRequest(&response)
113116
}
114117

115-
func (c *Client) sendRequest(request *refproto.TeamToController) {
118+
func (c *Client) sendRequest(request *refproto.TeamToController) (accepted bool) {
116119
if privateKey != nil {
117120
request.Signature = &refproto.Signature{Token: &c.token, Pkcs1V15: []byte{}}
118121
request.Signature.Pkcs1V15 = client.Sign(privateKey, request)
@@ -132,10 +135,16 @@ func (c *Client) sendRequest(request *refproto.TeamToController) {
132135
log.Print("Received reply: ", proto.MarshalTextString(&reply))
133136
if reply.GetControllerReply().StatusCode == nil || *reply.GetControllerReply().StatusCode != refproto.ControllerReply_OK {
134137
log.Print("Message rejected: ", *reply.GetControllerReply().Reason)
138+
accepted = false
139+
} else {
140+
accepted = true
135141
}
142+
136143
if reply.GetControllerReply().NextToken != nil {
137144
c.token = *reply.GetControllerReply().NextToken
138145
} else {
139146
c.token = ""
140147
}
148+
149+
return
141150
}

internal/app/rcon/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ func (c *Client) Reject(reason string) (reply refproto.ControllerReply) {
121121
*reply.StatusCode = refproto.ControllerReply_REJECTED
122122
reply.Reason = new(string)
123123
*reply.Reason = reason
124+
c.addVerification(&reply)
124125
return
125126
}
126127

0 commit comments

Comments
 (0)