@@ -21,10 +21,11 @@ type Server struct {
2121}
2222
2323type Client struct {
24- Id string
25- Conn net.Conn
26- Token string
27- PubKey * rsa.PublicKey
24+ Id string
25+ Conn net.Conn
26+ Token string
27+ PubKey * rsa.PublicKey
28+ VerifiedConnection bool
2829}
2930
3031func NewServer () (s * Server ) {
@@ -34,12 +35,12 @@ func NewServer() (s *Server) {
3435 return
3536}
3637
37- func (s * Server ) Listen (address string ) error {
38+ func (s * Server ) Listen (address string ) {
3839 listener , err := net .Listen ("tcp" , address )
3940 if err != nil {
40- return err
41+ log .Print ("Failed to listen on " , address )
42+ return
4143 }
42- defer listener .Close ()
4344 log .Print ("Listening on " , address )
4445
4546 for {
@@ -49,7 +50,6 @@ func (s *Server) Listen(address string) error {
4950 } else {
5051 go s .ConnectionHandler (conn )
5152 }
52-
5353 }
5454}
5555
@@ -61,15 +61,21 @@ func (s *Server) CloseConnection(conn net.Conn, id string) {
6161func (c * Client ) Ok () (reply refproto.ControllerReply ) {
6262 reply .StatusCode = new (refproto.ControllerReply_StatusCode )
6363 * reply .StatusCode = refproto .ControllerReply_OK
64+ c .addVerification (& reply )
65+ return
66+ }
67+
68+ func (c * Client ) addVerification (reply * refproto.ControllerReply ) {
6469 reply .Verification = new (refproto.ControllerReply_Verification )
6570 if c .Token != "" {
6671 reply .NextToken = new (string )
6772 * reply .NextToken = c .Token
6873 * reply .Verification = refproto .ControllerReply_VERIFIED
74+ c .VerifiedConnection = true
6975 } else {
7076 * reply .Verification = refproto .ControllerReply_UNVERIFIED
77+ c .VerifiedConnection = false
7178 }
72- return
7379}
7480
7581func (c * Client ) Reject (reason string ) (reply refproto.ControllerReply ) {
0 commit comments