Coder Social home page Coder Social logo

xray-user-management's Introduction

Xray-User-Management

A simple program to manage xray users.

Installation

Install Xray-User-Management with the following steps:

1- Clone this project

git clone https://github.com/amirhrajabiz1/Xray-User-Management.git

2- Download xray core and unzip it and move the xray and geosite.dat and geoip.dat to the Xray-User-Management directory

3- go to Xray-User-Management directory

cd Xray-User-Management

4- make xray and run.sh executable

chmod +x xray run.sh

5- edit the 'conf/inbound.json' for inbound protocols you want to use. Note: Make sure the client is empty and you should use 'add_user_to_config_file.py' to add user to the 'conf/inbound.json'.

6- execute the 'run.sh' with root privilege

./run.sh

Usage

1- You should only add a user with 'add_user_to_config_file.py' python code

for help:

python3 add_user_to_config_file.py -h

2- you should can delete a user with 'del_user_from_config_file.py' python code

for help:

python del_user_from_config_file.py -h

Examples

1- This command will create a user, amir, in 'conf/inbound.json' with a maximum bandwidth of 100GB for 30 days. Additionally, only one different IP address can use this account simultaneously:

python3 add_user_to_config_file.py -u amir -c conf/inbound.json -l 100G -d 30 -s 1

2- Now, assume user 'amir' consumes 100GB with this account. In this case, amir's ID will be removed from the 'conf/inbound.json', and the following log will be recorded in 'reasonremove.log':

2024-01-28 15:18:29 user 'amir' removed because of quota_out.

3- After 30 days, amir's ID will be removed from the 'conf/inbound.json', and the following log will be recorded in 'reasonremove.log':

2025-10-10 10:10:18 user 'amir' removed because of time_out.

4- If amir connects with more than one connection (source IP address) to this account concurrently, amir's ID will be removed from the 'conf/inbound.json', and the following log will be recorded in 'reasonremove.log':

2025-10-10 10:12:49 user 'amir' removed because of CC_violation.

5- If you choose to delete amir manually, in this case, amir's ID will be removed from the 'conf/inbound.json', and the following log will be recorded in 'reasonremove.log':

2024-01-30 14:46:28 user 'amir' removed manually.

Note: use switch -f if you want to delete the user statistics and information completely.

6- Now, if you want to create the user 'amir' again with the previous ID, you can enter this:

python3 add_user_to_config_file.py -u amir -c conf/inbound.json -l 100G -d 30 -s 1 -f soft

7- If you want to create the user 'amir' with a new ID, you can enter this:

python3 add_user_to_config_file.py -u amir -c conf/inbound.json -l 100G -d 30 -s 1 -f hard

Files And Directories

conf/inbound.json: You put your inbound configs here.

users/user/Statistics/: You find user statistics here.

users/user/user.json: You find user information here.

reasonremove.log: You find logs of why a user removed from 'conf/inbound.json'.

Monitoring

to monitor the usages and domains of users, follow these steps:

sudo apt update
sudo apt install python3-venv
cd django_project
python3 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 127.0.0.1:8000 # Run the django server on 127.0.0.1:8000

Note: Don't expose this server to the Internet for security reasons!

Now open a new terminal and run the database update command:

cd django_project
. .venv/bin/activate
python manage.py update_db 60 # Update the database at regular intervals

Now you can go to this address in your browser and monitor the usages and domains for users: http://127.0.0.1:8000

xray-user-management's People

Contributors

amirhrajabiz1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.