heiher / hev-socks5-server

A high-performance socks5 server for Unix (Linux/Android/BSD/macOS/iOS)
MIT License
242 stars 39 forks source link

user connection limit #54

Closed enakhi closed 3 months ago

enakhi commented 3 months ago

Could you please add a property to the auth.txt file to set the maximum number of connections allowed for each user? Additionally, can you ensure the server is handling this limitation properly?

heiher commented 3 months ago

You can limit the number of connections of user by firewall, matching the mark value in auth.txt.

enakhi commented 3 months ago

Could you please explain it using an example?

heiher commented 3 months ago

Could you please explain it using an example?

For example, limit the number of connections for user jerry up to 2.

config file:

auth:
  file: conf/auth.txt

auth.txt:

jerry pass 1a

iptables:

iptables -A OUTPUT -p tcp --syn -m mark --mark 0x1a -m connlimit --connlimit-above 2 -j REJECT