]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/client_conn.go
Tests and minor fixes
[rbdr/mobius] / hotline / client_conn.go
index 5c25f928860348d66814f60f63f2f46fc8e5fef1..367b70fdd9f1d92cab447d7035648aaf3e2756f1 100644 (file)
@@ -29,7 +29,7 @@ type ClientConn struct {
        ID         *[]byte
        Icon       *[]byte
        Flags      *[]byte
        ID         *[]byte
        Icon       *[]byte
        Flags      *[]byte
-       UserName   *[]byte
+       UserName   []byte
        Account    *Account
        IdleTime   *int
        Server     *Server
        Account    *Account
        IdleTime   *int
        Server     *Server
@@ -55,7 +55,7 @@ func (cc *ClientConn) handleTransaction(transaction *Transaction) error {
                        if field.ID == nil {
                                cc.Server.Logger.Infow(
                                        "Missing required field",
                        if field.ID == nil {
                                cc.Server.Logger.Infow(
                                        "Missing required field",
-                                       "Account", cc.Account.Login, "UserName", string(*cc.UserName), "RequestType", handler.Name, "FieldID", reqField.ID,
+                                       "Account", cc.Account.Login, "UserName", string(cc.UserName), "RequestType", handler.Name, "FieldID", reqField.ID,
                                )
                                return nil
                        }
                                )
                                return nil
                        }
@@ -63,7 +63,7 @@ func (cc *ClientConn) handleTransaction(transaction *Transaction) error {
                        if len(field.Data) < reqField.minLen {
                                cc.Server.Logger.Infow(
                                        "Field does not meet minLen",
                        if len(field.Data) < reqField.minLen {
                                cc.Server.Logger.Infow(
                                        "Field does not meet minLen",
-                                       "Account", cc.Account.Login, "UserName", string(*cc.UserName), "RequestType", handler.Name, "FieldID", reqField.ID,
+                                       "Account", cc.Account.Login, "UserName", string(cc.UserName), "RequestType", handler.Name, "FieldID", reqField.ID,
                                )
                                return nil
                        }
                                )
                                return nil
                        }
@@ -71,7 +71,7 @@ func (cc *ClientConn) handleTransaction(transaction *Transaction) error {
                if !authorize(cc.Account.Access, handler.Access) {
                        cc.Server.Logger.Infow(
                                "Unauthorized Action",
                if !authorize(cc.Account.Access, handler.Access) {
                        cc.Server.Logger.Infow(
                                "Unauthorized Action",
-                               "Account", cc.Account.Login, "UserName", string(*cc.UserName), "RequestType", handler.Name,
+                               "Account", cc.Account.Login, "UserName", string(cc.UserName), "RequestType", handler.Name,
                        )
                        cc.Server.outbox <- cc.NewErrReply(transaction, handler.DenyMsg)
 
                        )
                        cc.Server.outbox <- cc.NewErrReply(transaction, handler.DenyMsg)
 
@@ -81,7 +81,7 @@ func (cc *ClientConn) handleTransaction(transaction *Transaction) error {
                cc.Server.Logger.Infow(
                        "Received Transaction",
                        "login", cc.Account.Login,
                cc.Server.Logger.Infow(
                        "Received Transaction",
                        "login", cc.Account.Login,
-                       "name", string(*cc.UserName),
+                       "name", string(cc.UserName),
                        "RequestType", handler.Name,
                )
 
                        "RequestType", handler.Name,
                )
 
@@ -95,7 +95,7 @@ func (cc *ClientConn) handleTransaction(transaction *Transaction) error {
        } else {
                cc.Server.Logger.Errorw(
                        "Unimplemented transaction type received",
        } else {
                cc.Server.Logger.Errorw(
                        "Unimplemented transaction type received",
-                       "UserName", string(*cc.UserName), "RequestID", requestNum,
+                       "UserName", string(cc.UserName), "RequestID", requestNum,
                )
        }
 
                )
        }
 
@@ -114,7 +114,7 @@ func (cc *ClientConn) handleTransaction(transaction *Transaction) error {
                        tranNotifyChangeUser,
                        NewField(fieldUserID, *cc.ID),
                        NewField(fieldUserFlags, *cc.Flags),
                        tranNotifyChangeUser,
                        NewField(fieldUserID, *cc.ID),
                        NewField(fieldUserFlags, *cc.Flags),
-                       NewField(fieldUserName, *cc.UserName),
+                       NewField(fieldUserName, cc.UserName),
                        NewField(fieldUserIconID, *cc.Icon),
                )
 
                        NewField(fieldUserIconID, *cc.Icon),
                )
 
@@ -201,7 +201,7 @@ type handshake struct {
 // Description         Size    Data    Note
 // Protocol ID         4               TRTP
 //Error code           4                               Error code returned by the server (0 = no error)
 // Description         Size    Data    Note
 // Protocol ID         4               TRTP
 //Error code           4                               Error code returned by the server (0 = no error)
-func  Handshake(conn net.Conn, buf []byte) error {
+func Handshake(conn net.Conn, buf []byte) error {
        var h handshake
        r := bytes.NewReader(buf)
        if err := binary.Read(r, binary.BigEndian, &h); err != nil {
        var h handshake
        r := bytes.NewReader(buf)
        if err := binary.Read(r, binary.BigEndian, &h); err != nil {