A multi-user asynchronous port forwarding tool based on the CHAP protocol , which provides a web-side management and monitoring platform, implements quota management based on duration and traffic, counts user traffic usage in real time and generates detailed orders, which are displayed on the front end in the form of charts.
Protocol: Enhanced CHAP protocol
Front-end: vue.js + vuex + vue-router + vue-cli + axios + element-ui + v-chart
Backend: asyncio + sanic + sanic_cors + sanic_jwt + aiomysql
(back_end) root@iZ2zehx50rbasf3o9jdehaZ:~/pylcx/back_end# python main.py -h
usage: main.py [-h] {listen,slave} ...
async LCX with CHAP
positional arguments:
{listen,slave} choose a mode to run
listen run in listen mode
slave run in slave mode
optional arguments:
-h, --help show this help message and exit
(back_end) root@iZ2zehx50rbasf3o9jdehaZ:~/pylcx/back_end# python main.py listen -h
usage: main.py listen [-h] -p PORT [-a ADDR] [-v]
optional arguments:
-h, --help show this help message and exit
-p PORT Port listen for slave side
-a ADDR Address for a web server to manage users, default
0.0.0.0:8000
-v, --verbose verbose log (repeat for more verbose)
(back_end) root@iZ2zehx50rbasf3o9jdehaZ:~/pylcx/back_end# python main.py slave -h
usage: main.py slave [-h] [-b BIND] -l LOCAL -r REMOTE -u USER [-v]
optional arguments:
-h, --help show this help message and exit
-b BIND Open a bind port at remote listen, connected by remote
client, default 0 (random port)
-l LOCAL Local server address in format host:port
-r REMOTE Remote listen address in format host:port
-u USER User in format username:password
-v, --verbose verbose log (repeat for more verbose)
main.py : program entry, read command line parameters and configure logs
chap.py : The data reading and writing module at the bottom of the protocol
listen.py : core module of remote listen
slave.py : the core module of local slave
server.py : core module of sanic app
User passwords are encrypted and stored using MD5 salt, and the handshake of the protocol uses random factors to prevent replay attacks.
The front-end and back-end are separated. The back-end uses Sanic to provide RESTful API and uses JWT for cross-domain authentication.
The protocol and two-way port forwarding are implemented based on asyncio, and the database uses aiomysql, and the entire backend is asynchronous and non-blocking.