From 0d7d59d7fed5aafedd7d9517a9055937cf5e18a9 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Sun, 11 Apr 2021 20:04:44 +0200 Subject: [PATCH] Make whoami return "user," instead of "", to prevent collisions with other returns. --- README.md | 4 ++-- modules/[text server]/[api]/users/module.py | 2 +- modules/[text server]/main/module.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 51c80a9..9897acc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ A valid request contains a 4-byte (32-bit) big endian unsigned integer denoting - **req** Execute a command with an associated request ID. Returns with the same ID, and the command's return value(s). *Arguments:* `req,,,[argument 1],[argument 2],[...]` -*Return:* `,,[return value 1],[return value 2],[...]` +*Return:* `req,,[return value 1],[return value 2],[...]` - **register** Register a new user on the server. *Arguments:* `,` @@ -27,7 +27,7 @@ Log into an existing server. *Arguments:* `,` - **whoami** Check which user this session is using. -*Return:* `` +*Return:* `user,` - **send** Sends command to another user's clients. The command will arrive as-is, with the user switched to be the sender instead of the receiver. So if you are fier, and you execute `send,fier2,text,hello`, fier2 will get `send,fier,text,hello` *Arguments:* `,,[argument 1],[argument 2],[...]` diff --git a/modules/[text server]/[api]/users/module.py b/modules/[text server]/[api]/users/module.py index 7406106..3c72773 100644 --- a/modules/[text server]/[api]/users/module.py +++ b/modules/[text server]/[api]/users/module.py @@ -83,5 +83,5 @@ def textUserGet(self,command,args): if not user: return ["error","nonfatal","not_logged_in"] - return [user] + return ["user",user] textCommandAddHandler("whoami",textUserGet) \ No newline at end of file diff --git a/modules/[text server]/main/module.py b/modules/[text server]/main/module.py index 220d77c..b5cc90b 100644 --- a/modules/[text server]/main/module.py +++ b/modules/[text server]/main/module.py @@ -1,7 +1,7 @@ global textTimeout textTimeout = 30 global textKeepAliveTimeout -textKeepAliveTimeout = 600 # set to 0 for infinite time (not recommended) +textKeepAliveTimeout = 600 # set to None for infinite time (not recommended) global textOnConnect def textOnConnect(event,connection,address): @@ -13,7 +13,7 @@ global textOnPreRequest def textOnPreRequest(event,self,requestLength): global textTimeout self.connection.settimeout(textTimeout) - if requestLength <= 128: return + if requestLength <= 100000: return try: sendResponse(self.connection,textListToCommand(["error","fatal","request_too_long"]).encode("utf-8")) except threading.timeout: