Skip to content

Commit

Permalink
[bugfix] Add verification to rejected messages as well
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
g3force committed Feb 9, 2019
1 parent 0b1f3e4 commit 637f796
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmd/ssl-team-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/golang/protobuf/proto"
"log"
"net"
"time"
)

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

c.register()
c.sendDesiredKeeper(3)
for !c.sendDesiredKeeper(3) {
time.Sleep(time.Second)
}

for {
c.ReplyToChoices()
Expand Down Expand Up @@ -93,10 +96,10 @@ func (c *Client) register() {
}
}

func (c *Client) sendDesiredKeeper(id int32) {
func (c *Client) sendDesiredKeeper(id int32) (accepted bool) {
message := refproto.TeamToController_DesiredKeeper{DesiredKeeper: id}
request := refproto.TeamToController{Msg: &message}
c.sendRequest(&request)
return c.sendRequest(&request)
}

func (c *Client) ReplyToChoices() {
Expand All @@ -112,7 +115,7 @@ func (c *Client) ReplyToChoices() {
c.sendRequest(&response)
}

func (c *Client) sendRequest(request *refproto.TeamToController) {
func (c *Client) sendRequest(request *refproto.TeamToController) (accepted bool) {
if privateKey != nil {
request.Signature = &refproto.Signature{Token: &c.token, Pkcs1V15: []byte{}}
request.Signature.Pkcs1V15 = client.Sign(privateKey, request)
Expand All @@ -132,10 +135,16 @@ func (c *Client) sendRequest(request *refproto.TeamToController) {
log.Print("Received reply: ", proto.MarshalTextString(&reply))
if reply.GetControllerReply().StatusCode == nil || *reply.GetControllerReply().StatusCode != refproto.ControllerReply_OK {
log.Print("Message rejected: ", *reply.GetControllerReply().Reason)
accepted = false
} else {
accepted = true
}

if reply.GetControllerReply().NextToken != nil {
c.token = *reply.GetControllerReply().NextToken
} else {
c.token = ""
}

return
}
1 change: 1 addition & 0 deletions internal/app/rcon/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (c *Client) Reject(reason string) (reply refproto.ControllerReply) {
*reply.StatusCode = refproto.ControllerReply_REJECTED
reply.Reason = new(string)
*reply.Reason = reason
c.addVerification(&reply)
return
}

Expand Down

0 comments on commit 637f796

Please sign in to comment.