diff --git a/main.js b/main.js index 408e24b..12d7fd5 100644 --- a/main.js +++ b/main.js @@ -78,22 +78,22 @@ function VerifyJsonSignature(json) { } let ActionCode = { - "ServerMessage": 0, - - "Declare": 200, - "ObjectResponse": 201, - - "BulletinRequest": 211, - "BulletinFileRequest": 212, - - "ChatDH": 221, - "ChatMessage": 222, - "ChatSync": 223, - - "GroupRequest": 231, - "GroupManageSync": 232, - "GroupDH": 233, - "GroupMessageSync": 234 + "Declare": 100, + "ObjectResponse": 101, + + "BulletinRequest": 201, + "BulletinFileRequest": 202, + + "ChatDH": 301, + "ChatMessage": 302, + "ChatSync": 303, + "PrivateFileRequest": 304, + + "GroupRequest": 401, + "GroupManageSync": 402, + "GroupDH": 403, + "GroupMessageSync": 404, + "GroupFileRequest": 405 } //message @@ -111,11 +111,14 @@ const MessageCode = { } const ObjectType = { - "Bulletin": 111, - "BulletinFile": 112, + "Bulletin": 101, + "BulletinFile": 102, + + "PrivateFile": 201, - "GroupManage": 131, - "GroupMessage": 132 + "GroupManage": 301, + "GroupMessage": 302, + "GroupFile": 303 } function strServerMessage(msgCode) { @@ -304,7 +307,7 @@ function startClientServer() { ClientServer = new WebSocket.Server({ port: 3000, //to bind on 80, must use 'sudo node main.js' clientTracking: true, - maxPayload: 102400 + maxPayload: 150 * 1024 }) ClientServer.on('connection', function connection(ws) { diff --git a/schema.js b/schema.js index 3fd6e9d..0053556 100644 --- a/schema.js +++ b/schema.js @@ -76,7 +76,7 @@ let BulletinRequestSchema = { } } -let BulletinFileRequestSchema = { +let FileRequestSchema = { "type": "object", "required": ["Action", "SHA1", "CurrentChunk", "To", "Timestamp", "PublicKey", "Signature"], "maxProperties": 7, @@ -343,7 +343,7 @@ var vDeclare = ajv.compile(DeclareSchema) var vObjectResponseSchema = ajv.compile(ObjectResponseSchema) var vBulletinRequestSchema = ajv.compile(BulletinRequestSchema) -var vBulletinFileRequestSchema = ajv.compile(BulletinFileRequestSchema) +var vFileRequestSchema = ajv.compile(FileRequestSchema) var vChatMessageSchema = ajv.compile(ChatMessageSchema) var vChatSyncSchema = ajv.compile(ChatSyncSchema) @@ -358,7 +358,7 @@ function checkClientSchema(strJson) { if (typeof strJson == "string") { try { let json = JSON.parse(strJson) - if (vObjectResponseSchema(json) || vBulletinRequestSchema(json) || vBulletinFileRequestSchema(json) || vChatMessageSchema(json) || vChatSyncSchema(json) || vChatDHSchema(json) || vDeclare(json) || vGroupRequestSchema(json) || vGroupManageSyncSchema(json) || vGroupDHSchema(json) || vGroupMessageSyncSchema(json)) { + if (vObjectResponseSchema(json) || vBulletinRequestSchema(json) || vFileRequestSchema(json) || vChatMessageSchema(json) || vChatSyncSchema(json) || vChatDHSchema(json) || vDeclare(json) || vGroupRequestSchema(json) || vGroupManageSyncSchema(json) || vGroupDHSchema(json) || vGroupMessageSyncSchema(json)) { return json } else { return false