Limit V2ray user while they are behind another Server (Rinetd)
Report Bug
·
Request Feature
Rinetd efficiently redirects connections from one IP address/port combination to another. It is useful when operating virtual servers, firewalls, and the like.
It is a fantastic tool, especially in this scenario:
You have two servers.
One is the leading VPN server (located in France, for instance), and the other is in another location (e.g., Iran).
You want to connect the users to the Iran Server and redirect them to your France VPN server.
To achieve this, on France Server, you can install whatever VPN you want (V2ray, ocServe, etc.), and on the Iran Server, install Rinetd, and you are good to go.
Let's say you successfully deployed this setup.
Now you want to Limit users to two users at the same time.
If you are using V2ray, there is already a script does this.
But this script doesn't work with this setup because we redirect all traffic from Iran Server, and the VPN server (France) now sees only our Iran server's IP address.
So, we should monitor the users from the Iran Server, not the VPN Server (France).
This simple Python Script do this!
It reads your log file and sees if one particular port is used by more than X Ip addresses. (The X is the number that you'll define).
Just be aware of the following:
First) The log file should be in web-server style format. For this, your rinetd config file should be like this:
# logging information
logfile /var/log/rinetd.log
# uncomment the following line if you want web-server style logfile format
logcommon
Sample log file format:
8.8.8.8 - - [09/Mar/2023:07:27:50 +0000] "GET /rinetd-services/0.0.0.0/3000/1.1.1.1/3000/done-remote-closed HTTP/1.0" 200 203 - - - 131
8.8.4.4 - - [09/Mar/2023:07:27:51 +0000] "GET /rinetd-services/0.0.0.0/3001/1.1.1.1/3001/opened HTTP/1.0" 200 0 - - - 0
Second) You should enter your Usernames with their specified ports in the user_names.py
file with the dictionary type.
- install python.
pip3 install -r requirements.txt
- put it on background =>
nohup python3 main.py &
(without background process :python3 main.py
)
You can disable the user with the prevent
folder.
In there, you see three files:
main.py
: Keep this file on the VPN server that hosts V2ray (France).inventory.ini
: edit this file. Keep this file with other parent files.playbook.yaml
: edit this file to replace thedb
path and themain.py
script on the VPN server. Keep this file with other parent files.
- Add real-world examples
- Add exam tips
- Add Dockerfile and Docker Compose examples
- Automatically disabled user (With Ansible)
See the open issues for a complete list of proposed features (and known issues).
Any contributions you make are greatly appreciated.
If you have a suggestion to improve this, please fork the repo and create a pull request. You can also open an issue with the tag "enhancement."
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
The license is under the MIT License. See LICENSE for more information.
Give a ⭐️ if this project helped you!