Compare commits
8 Commits
289d0db7eb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15b4013868 | ||
|
|
2517617d4f | ||
|
|
cd0a0d5e44 | ||
|
|
e7e42922b6 | ||
|
|
c0ed7ca721 | ||
|
|
08129fee79 | ||
|
|
fbbbef7da6 | ||
|
|
bba8c620bd |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
udpserver
|
udpserver
|
||||||
*.log
|
*.log
|
||||||
*.pid
|
*.pid
|
||||||
|
.vscode
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
# Simple multithreaded UDP server
|
# Simple C++ multithreaded UDP server
|
||||||
|
|
||||||
[](README.md)
|
[](README.md)
|
||||||
[](README.md)
|
[](README.md)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
Simple multithreaded UDP server.
|
Simple C++ multithreaded UDP server.
|
||||||
The number of threads is determined by the number of CPU cores.
|
The number of threads is determined by the number of CPU cores.
|
||||||
JSON logging.
|
JSON logging.
|
||||||
|
XTea encryption functions.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "json11.hpp"
|
#include "json11.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* g++ -o udpserver udpserver.cpp -std=c++11 json11.cpp -pthread -s -O2 */
|
/* g++ -o udpserver udpserver.cpp -std=c++11 json11.cpp -pthread -s -O2 */
|
||||||
/* udpserver 127.0.0.1 10003 */
|
/* udpserver 127.0.0.1 10003 */
|
||||||
|
/* Version 2022.04 */
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "json11.hpp"
|
#include "json11.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace json11;
|
using namespace json11;
|
||||||
@@ -192,8 +193,7 @@ void stringCrypt(char *inout, int len, bool encrypt) // encrypt true - encrypt,
|
|||||||
xteaDecipher(32, (uint32_t*)(inout + (i * BLOCK_SIZE)), key);
|
xteaDecipher(32, (uint32_t*)(inout + (i * BLOCK_SIZE)), key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len % BLOCK_SIZE != 0)
|
if (len % BLOCK_SIZE != 0) {
|
||||||
{
|
|
||||||
int mod = len % BLOCK_SIZE;
|
int mod = len % BLOCK_SIZE;
|
||||||
int offset = (len / BLOCK_SIZE) * BLOCK_SIZE;
|
int offset = (len / BLOCK_SIZE) * BLOCK_SIZE;
|
||||||
char data[BLOCK_SIZE];
|
char data[BLOCK_SIZE];
|
||||||
@@ -205,6 +205,5 @@ void stringCrypt(char *inout, int len, bool encrypt) // encrypt true - encrypt,
|
|||||||
xteaDecipher(32, (uint32_t*)data, key);
|
xteaDecipher(32, (uint32_t*)data, key);
|
||||||
}
|
}
|
||||||
memcpy(inout + offset, data, mod);
|
memcpy(inout + offset, data, mod);
|
||||||
cout << mod << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user