diff --git a/client/src/main.c b/client/src/main.c index 075e194..bd24303 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -257,6 +257,9 @@ int main(int argc, char *argv[]) { __runtimeData.strings = NULL; __runtimeData.protocolVersion = 0; + sh_new_strdup(__runtimeData.integers); + sh_new_strdup(__runtimeData.strings); + //taskCreate(taskComDebugLoop, NULL); taskCreate(taskWelcome, NULL); taskCreate(taskGuiEventLoop, NULL); diff --git a/client/src/welcome.c b/client/src/welcome.c index b64a47a..27999a5 100644 --- a/client/src/welcome.c +++ b/client/src/welcome.c @@ -183,7 +183,6 @@ static void taskConnectClick(void *data) { case PACKET_TYPE_VERSION: __runtimeData.protocolVersion = *(uint32_t *)decoded->data; - packetDecodeDataDestroy(&decoded); // Do we need to update? if (PACKET_PROTOCOL_VERSION == __runtimeData.protocolVersion) { // Nope, we're good. @@ -207,6 +206,7 @@ static void taskConnectClick(void *data) { logWrite("Unexpected packet received: %d\n", decoded->packetType); break; } + packetDecodeDataDestroy(&decoded); } taskYield(); if (__timerSecondTick) timeout--; diff --git a/kanga.world/site/plugins/kangaworld-integration/classes/KwConfig.php b/kanga.world/site/plugins/kangaworld-integration/classes/KwConfig.php index 124bebd..e12c3af 100644 --- a/kanga.world/site/plugins/kangaworld-integration/classes/KwConfig.php +++ b/kanga.world/site/plugins/kangaworld-integration/classes/KwConfig.php @@ -76,8 +76,8 @@ class KwConfig { if (V::minlength($input['data'], 1) === false) { throw new InvalidArgumentException('The data must not be empty'); } - if (V::maxlength($input['data'], 4096) === false) { - throw new InvalidArgumentException('The data must not be longer than 4096 characters'); + if (V::maxlength($input['data'], 1024) === false) { + throw new InvalidArgumentException('The data must not be longer than 1024 characters'); } if (V::maxlength($input['description'], 255) === false) { diff --git a/kanga.world/site/plugins/kangaworld-integration/classes/KwStrings.php b/kanga.world/site/plugins/kangaworld-integration/classes/KwStrings.php index 0bb2d52..9f938c7 100644 --- a/kanga.world/site/plugins/kangaworld-integration/classes/KwStrings.php +++ b/kanga.world/site/plugins/kangaworld-integration/classes/KwStrings.php @@ -76,8 +76,8 @@ class KwStrings { if (V::minlength($input['data'], 1) === false) { throw new InvalidArgumentException('The data must not be empty'); } - if (V::maxlength($input['data'], 4096) === false) { - throw new InvalidArgumentException('The data must not be longer than 4096 characters'); + if (V::maxlength($input['data'], 1024) === false) { + throw new InvalidArgumentException('The data must not be longer than 1024 characters'); } if (V::maxlength($input['description'], 255) === false) { diff --git a/server/src/client.c b/server/src/client.c index fbf18f0..8dc58cb 100644 --- a/server/src/client.c +++ b/server/src/client.c @@ -136,6 +136,7 @@ static void clientProcessPacket(ClientThreadT *client, PacketDecodeDataT *data) // Send it. packetSend(client->packetThreadData, &encoded); DEL(buffer); + //logWrite("[%s] = [%s]\r\n", strings[i].key, strings[i].value); } restHelperConfigStringMapRelease(strings); // Fetch number table from REST. @@ -174,6 +175,7 @@ static void clientProcessPacket(ClientThreadT *client, PacketDecodeDataT *data) // Send it. packetSend(client->packetThreadData, &encoded); DEL(buffer); + //logWrite("[%s] = [%d]\r\n", integers[i].key, integers[i].value); } restHelperConfigIntegerMapRelease(integers); // Build PROCEED packet. diff --git a/server/src/rest.c b/server/src/rest.c index 20be626..0ebe7e1 100644 --- a/server/src/rest.c +++ b/server/src/rest.c @@ -52,7 +52,7 @@ int64_t restHelperConfigIntegerGet(json_object *object, char *name, int64_t defa json_object *item = NULL; int64_t result = defaultValue; - config = json_object_object_get(object, "config"); + config = json_object_object_get(object, "payload"); if (config) { data = json_object_object_get(config, "data"); if (data) { @@ -78,7 +78,9 @@ RestIntegerMapT *restHelperConfigIntegerMapGet(json_object *object) { json_object *item = NULL; RestIntegerMapT *result = NULL; - config = json_object_object_get(object, "config"); + sh_new_strdup(result); + + config = json_object_object_get(object, "payload"); if (config) { data = json_object_object_get(config, "data"); if (data) { @@ -109,7 +111,7 @@ char *restHelperConfigStringGet(json_object *object, char *name, char *defaultVa json_object *item = NULL; char *result = strdup(defaultValue); - config = json_object_object_get(object, "config"); + config = json_object_object_get(object, "payload"); if (config) { data = json_object_object_get(config, "data"); if (data) { @@ -136,7 +138,9 @@ RestStringMapT *restHelperConfigStringMapGet(json_object *object) { json_object *item = NULL; RestStringMapT *result = NULL; - config = json_object_object_get(object, "config"); + sh_new_strdup(result); + + config = json_object_object_get(object, "payload"); if (config) { data = json_object_object_get(config, "data"); if (data) { @@ -208,10 +212,10 @@ json_object *restRequest(char *command, char *format, ...) { } va_end(args); - logWrite("Request: %s\n", json_object_to_json_string_ext(request, JSON_C_TO_STRING_PRETTY)); + //logWrite("Request: %s\n", json_object_to_json_string_ext(request, JSON_C_TO_STRING_PRETTY)); response = restUrlPost(request); json_object_put(request); - logWrite("Response: %s\n", json_object_to_json_string_ext(response, JSON_C_TO_STRING_PRETTY)); + //logWrite("Response: %s\n", json_object_to_json_string_ext(response, JSON_C_TO_STRING_PRETTY)); if (response) { if (json_object_get_boolean(json_object_object_get(response, "result")) != TRUE) { diff --git a/shared/packet.h b/shared/packet.h index 425e2da..12db62a 100644 --- a/shared/packet.h +++ b/shared/packet.h @@ -40,8 +40,8 @@ */ -#define PACKET_MAX 1024 // Maximum number of bytes per packet -#define PACKET_SEQUENCE_MAX 16 // Five bits of data, 32 max. +#define PACKET_MAX 1024 // Maximum number of bytes per packet. +#define PACKET_SEQUENCE_MAX 32 // Five bits of data, 32 max. Represents size of replay history. Also maximum number of packets on the wire at a time. #define PACKET_INPUT_QUEUE_SIZE 4096 #define PACKET_BUFFER_SIZE (PACKET_MAX * 2 + 2 + 8) // Worst case, every byte is a PACKET_FRAME. Add two for ending frame. Add 8 for worst case header and CRC.