diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 0399601..1fa27ad 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -293,8 +293,21 @@ public class DConnection : Thread } else if(commandByte == 15) { - command = Command.SET_PROP; + command = Command.GET_USER_PROPS; } + else if(commandByte == 16) + { + command = Command.GET_USER_PROP; + } + else if(commandByte == 17) + { + command = Command.SET_USER_PROP; + } + else if(commandByte == 18) + { + command = Command.DELETE_USER_PROP; + } + return command; @@ -690,11 +703,17 @@ public class DConnection : Thread /* If `get_user_prop` (requires: authed, client) */ else if(command == Command.GET_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT) { + /* Get the , */ + string[] dataLine = split(cast(string)message.data[1..message.data.length],","); + + /* Get the username */ + string username = dataLine[0]; + /* Get the proerty */ - string propertyName = cast(string)message.data[1..message.data.length]; + string propertyName = dataLine[1]; /* Determine if it is a valid property */ - bool status = isProperty(propertyName); + bool status = server.isProperty(username, propertyName); /* Encode the status */ reply ~= [status]; @@ -703,7 +722,7 @@ public class DConnection : Thread if(status) { /* Get the property value */ - string propertyValue = getProperty(propertyName); + string propertyValue = server.getProperty(username, propertyName); /* Encode the property value */ reply ~= propertyValue; diff --git a/source/dnetd/dserver.d b/source/dnetd/dserver.d index dcb630b..c695d15 100644 --- a/source/dnetd/dserver.d +++ b/source/dnetd/dserver.d @@ -362,6 +362,76 @@ public class DServer : Thread return matchedConnection.getStatusMessage(username); } + /** + * Checks whether the given user has the given + * property + */ + public bool isProperty(string username, string propertyName) + { + /* Whether or not the user has the given property */ + bool status; + + /* Lock the connections list */ + connectionLock.lock(); + + /* The matching connection */ + DConnection matchedConnection; + + /* Find the connection */ + foreach(DConnection connection; connectionQueue) + { + if(cmp(connection.getUsername(), username) == 0) + { + matchedConnection = connection; + break; + } + } + + /* Unlock the connections list */ + connectionLock.unlock(); + + /* Check for the user's property */ + status = matchedConnection.isProperty(propertyName); + + return status; + } + + /** + * Checks whether the given user has the given + * property + */ + public string getProperty(string username, string propertyName) + { + /* The retrieved property value */ + string propertyValue; + + /* Lock the connections list */ + connectionLock.lock(); + + /* The matching connection */ + DConnection matchedConnection; + + /* Find the connection */ + foreach(DConnection connection; connectionQueue) + { + if(cmp(connection.getUsername(), username) == 0) + { + matchedConnection = connection; + break; + } + } + + /* Unlock the connections list */ + connectionLock.unlock(); + + /* Check for the user's property */ + propertyValue = matchedConnection.getProperty(propertyName); + + return propertyValue; + } + + + public string getServerInfo() { /* The server information */