KAUST_CS231_Project, To build a proxy server
Welcome to push issues in GitHub! ๐ฅฐ
- The user can only access the Proxy Ports. the configuration file is unknown and untouchable for the user
- For convenience, we only consider proxies are running on only 1 machine but with different ports, the same as backend.
- The configuration file is right, without being corrupted. Because it's invisible to users.
git clone https://github.com/damaoooo/KAUST_CS231_Project
cd KAUST_CS231_Project
The program will automatically read config.json
in the same directory.
Run the Proxy
python proxy.py <--allow_local>
--allow_local
means whether you allow the traffic from 127.0.0.1
. By default, it's true.
if not very interested in it, you don't need to provide it to the program.
Run the Backend
python proxy.py
{
"proxy": [
{"ip": "127.0.0.1", "port": 11451},
{"ip": "127.0.0.1", "port": 11452}
],
"backend": [
{"ip": "127.0.0.1", "port": 11453},
{"ip": "127.0.0.1", "port": 11454}
],
"key": "123456"
}
You can modify to meet your requirement. Just follow the sample format.
just use the native client.
nc <ip> <port>
e.g.
nc 127.0.0.1 11451
For test, you can use the python file in the client_for_test
directory, but it is the same functionality as nc.
python client_for_test/bad_client_LI.py --ip 127.0.0.1 --port 11451
+---------+ +----------+
| proxy1 | | backend1 |
+---------+ +----------+
+--------+
| user |
+--------+ +---------+ +----------+
| proxy2 | | backend2 |
+---------+ +----------+
User can contact to Proxy 1-n, then ask the Proxy to forward the request to Backend 1-n. Then the result will be returned to the user.
IP Port Num1 Num2
1.1.1.1 5050 1 2
- the length of input must be smaller than 100
- Num can be HEX, like 0x1234abcd, can be FLOAT, like 1.23, can be INT, like 123
- FLOAT will be
round(num, 5)
, so 0.000001 will be INT 0 - Don't support Complex Number
Res1 Res2
- Res1 is
Num1 / Num2
, the result will round to 5 digits. - If Num1 and Num2 are integers, then the result will be
(Num1 ^ Num2) % 0xffffffff
, if one of Num1 or Num2 is float number, Res2 isNum1 ^ Num2
. Then, the result will directly output
- SYN Flood. Open the Syn Cookie(Linux)
sysctl -w net.ipv4.tcp_syncookies=1
- Max QPS is 100 for new user in proxy. For connections that already established, it depends on the hardware
โโโ README.md
โโโ backend.py
โโโ client_for_test
โย ย โโโ bad_client_LI.py
โย ย โโโ good_client_LI.py
โโโ config.cfg
โโโ proxy.py
โโโ test_all.py
โโโ utils.py