Traffic volume limit for each user (for example, 50 GB for user a)

Post your questions about SoftEther VPN software here. Please answer questions if you can afford.
Post Reply
persianboy
Posts: 1
Joined: Tue Jul 25, 2023 6:07 am

Traffic volume limit for each user (for example, 50 GB for user a)

Post by persianboy » Tue Jul 25, 2023 4:05 pm

How to define a volume limit for each user? Is it possible for someone to give a simple and complete explanation? Or put its code in GitHub? How should I use the script that was asked in previous similar questions and where should I change its code?
Thank you for someone's help
(Why is the volume limit not added in the software?)

solo
Posts: 1287
Joined: Sun Feb 14, 2021 10:31 am

Re: Traffic volume limit for each user (for example, 50 GB for user a)

Post by solo » Thu Jul 27, 2023 11:56 am

persianboy wrote:
Tue Jul 25, 2023 4:05 pm
Is it possible for someone to give a simple and complete explanation? Or put its code in GitHub?
Since no one offers an explanation, here is a complex and incomplete solution. Firstly, there is some code on GitHub, ask for an update https://github.com/shakibamoshiri/secli

Meanwhile, a few pointers:
  • check traffic of eg user named "usr2"

Code: Select all

curl -s -k -H "X-VPNADMIN-PASSWORD: xxxxxx" --json "{\"jsonrpc\":\"2.0\",\"id\":\"rpc_call_id\",\"method\":\"GetUser\",\"params\":{\"HubName_str\":\"VPN\",\"Name_str\":\"usr2\"}}" https://localhost:5555/api/ | jq ".result.\"Recv.UnicastBytes_u64\""

86646
  • if in excess, EnumSession + DeleteSession (of "usr2") and...
  • SetUser ("usr2") "UsePolicy_bool": true //while "policy:Access_bool": false
Deploy on scheduler/cron with scripts.

shakibamoshiri
Posts: 288
Joined: Wed Dec 28, 2022 9:10 pm

Re: Traffic volume limit for each user (for example, 50 GB for user a)

Post by shakibamoshiri » Sat Jul 29, 2023 7:12 am

it is too simple but I added this functionality to a much bigger script which is not easy to be used by a non-technical person.
I think I should make one just for this purpose.

And I should mention to main issue is that SE server that does not have any hooks, making any extension for it wont be easy.

here is the approach (if you could code) using RPC-JSON api
1. get a user information
2. sum the income + outcome traffic
3. check if exceeded your threshold
4. if yes disable the user account
5. it may a user be connected at the moment so check if user is online (he is consuming traffic)
6. disconnect an online user session
7. notify yourself or the user

if SE had hooks, this could be done real simple, but since it does not have, it becomes complex and hard to manage
By the way you either have to run the script
- manually
- using a scheduler e.g crontab (Linux)
to check for users traffic every X minutes.

I have spent more five months and making two CLI to mange SE server and eventually gave up further development since it has not been designed for enterprise usage (= having users and sell VPNs) but it is super good for LAN-to-LAN, VPN router, etc.

Post Reply