Giter Club home page Giter Club logo

Comments (21)

alexbers avatar alexbers commented on August 27, 2024 8

Hello, I've commited to master branch the ability to specify limits for users: 9da90d2.

Now you can put USER_CONN_LIMITS variable to config.py. Example:

USER_CONN_LIMITS = {
    "tg": 1
}

The radius is not supported.

from mtprotoproxy.

alexbers avatar alexbers commented on August 27, 2024 2

hello, it is simple to patch the program to limit the number of users. For example to restrict the number of users with one secret with 32 you can replace the code:

    update_stats(user, curr_connects=1)
    await asyncio.wait([task_tg_to_clt, task_clt_to_tg], return_when=asyncio.FIRST_COMPLETED)
    update_stats(user, curr_connects=-1)

with this code:

    update_stats(user, curr_connects=1)
    if stats[user]["curr_connects"] <= 32:
        await asyncio.wait([task_tg_to_clt, task_clt_to_tg], return_when=asyncio.FIRST_COMPLETED)
    update_stats(user, curr_connects=-1)

from mtprotoproxy.

alexbers avatar alexbers commented on August 27, 2024 2

Hello,

yes, just by replacing

 if stats[user]["curr_connects"] <= 32: 

with

if user == "any_username" and stats[user]["curr_connects"] <= 32:

from mtprotoproxy.

HirbodBehnam avatar HirbodBehnam commented on August 27, 2024 1

@fa1996raz
Hi
You can use my script to install mtproto proxy on Centos 7 link

After installing you can edit /opt/mtprotoproxy/config.py to config your settings. (Adding limiter for example)

I will add the limiter option to script later.

Plus you can install mtproto on windows by simply downloading this repository and opening mtprotoproxy.py with python3 (You should download and install python from here ) If python 3.7 didn't work try python 3.6

from mtprotoproxy.

HirbodBehnam avatar HirbodBehnam commented on August 27, 2024 1

@pouryare
From 6c5155c USER_CONN_LIMITS has renamed to USER_MAX_TCP_CONNS.

from mtprotoproxy.

pouryare avatar pouryare commented on August 27, 2024

Hello

Is there any way to limit "curr_connects" just for specific users(secret), not for all the secrets?

from mtprotoproxy.

fa1996raz avatar fa1996raz commented on August 27, 2024

hello, it is simple to patch the program to limit the number of users. For example to restrict the number of users with one secret with 32 you can replace the code:

    update_stats(user, curr_connects=1)
    await asyncio.wait([task_tg_to_clt, task_clt_to_tg], return_when=asyncio.FIRST_COMPLETED)
    update_stats(user, curr_connects=-1)

with this code:

    update_stats(user, curr_connects=1)
    if stats[user]["curr_connects"] <= 32:
        await asyncio.wait([task_tg_to_clt, task_clt_to_tg], return_when=asyncio.FIRST_COMPLETED)
    update_stats(user, curr_connects=-1)

Hi can you please explain that is which file I should change the codes please?
I am using the windows version of this file that has been written with pyton that I dont know him, and there is nothing especial in config file except port and secrets and channel tag that I can change them.
And another question is there any way to make it work with radius?
I need radius for multi user limiting and setting expiration time for each secret, if there is any other way I would be very glad if you help me.
Thanks alot

from mtprotoproxy.

fa1996raz avatar fa1996raz commented on August 27, 2024

Hello, I've commited to master branch the ability to specify limits for users: 9da90d2.

Now you can put USER_CONN_LIMITS variable to config.py. Example:

USER_CONN_LIMITS = {
    "tg": 1
}

The radius is not supported.

Hi and thanks alot for your quick response, As I said I am using it on windows and I think it has not been made by you, I had a question that if you have made an application for windows os too, you would give the download link please, or if it is not possible to make it, I am not too familar with Centos 7, you would help me to config it on an Centos server Step by Step if there is no problem, and another thing if you need the application that has been made for windows, I have the file and I think it has been developed for about a year and has not been updated, I can give the files.
Thanks again for your help
Hope to hear from you soon.

from mtprotoproxy.

fa1996raz avatar fa1996raz commented on August 27, 2024

@fa1996raz
Hi
You can use my script to install mtproto proxy on Centos 7 link

After installing you can edit /opt/mtprotoproxy/config.py to config your settings. (Adding limiter for example)

I will add the limiter option to script later.

Plus you can install mtproto on windows by simply downloading this repository and opening mtprotoproxy.py with python3 (You should download and install python from here ) If python 3.7 didn't work try python 3.6

Thanks man you are great
My only problem was executing these py projects, because I had never tried python before, I would try it now for both projects,
Thanks again for your helpπŸ™β€οΈ

from mtprotoproxy.

pouryare avatar pouryare commented on August 27, 2024

@alexbers
Would you please explain what's the difference between USER_CONN_LIMITS and USER_MAX_TCP_CONNS ?

from mtprotoproxy.

alexbers avatar alexbers commented on August 27, 2024

Yes, @HirbodBehnam is right. I think USER_MAX_TCP_CONNS is a better name because the proxy limits the number of tcp-connections per users, not the users itself. One telegram client can establish about 5 simultaneous connection (e.g. for file downloading)

from mtprotoproxy.

HirbodBehnam avatar HirbodBehnam commented on August 27, 2024

I think limiting users could be possible with their IP addresses.
So with print() command I realized that from here and cl_ip you can get the client's IP address. So if we store all IPs in a set (something like std::set I'm not a Python programmer) we can count them. If they reach a specific number, close all other connections. Also remove IPs that timeout.
Sorry if my explanation was not clear.

from mtprotoproxy.

alexbers avatar alexbers commented on August 27, 2024

the limiting by ip address is much less precise than by ip addresses, since almost all providers use nat technology that hides many ip addresses behind one

from mtprotoproxy.

HirbodBehnam avatar HirbodBehnam commented on August 27, 2024

Yeah you are right
Home WiFis and organization WiFis will cause a lot of problems and inaccuracy later.

from mtprotoproxy.

hamid-sarani avatar hamid-sarani commented on August 27, 2024

Hi @alexbers.

when i setting USER_MAX_TCP_CONNS, proxy works very slow? and cant download any thing
but when there is no USER_MAX_TCP_CONNS config, it's works fine!!!!

from mtprotoproxy.

alexbers avatar alexbers commented on August 27, 2024

The proxy can create several tcp connections for one user to download files fast. If you allow only few connections, like one or two, the proxy will be not able to make additional connections. You can just increase the connection limit, like if you want to have 10 user, then set 80 (multiply by 8)

from mtprotoproxy.

erfantkerfan avatar erfantkerfan commented on August 27, 2024

Im wondering if there is a way to recognize each specific user and implement such restriction rather than aiming high with tcp connections or making the risk (nat) and limiting by IP. πŸ€”

from mtprotoproxy.

ali-jk avatar ali-jk commented on August 27, 2024

Hello, I've commited to master branch the ability to specify limits for users: 9da90d2.

Now you can put USER_CONN_LIMITS variable to config.py. Example:

USER_CONN_LIMITS = {
    "tg": 1
}

The radius is not supported.

hi I try this method but it's not working at all
USER_CONN_LIMITS = { "karbar2": 2, "karbar1": 2, "karbar4": 1 }

all of them are unlimited to connect.
did I do something wrong?
can you help me in some other way?

from mtprotoproxy.

alexbers avatar alexbers commented on August 27, 2024

Are you restarted the proxy after changing config?

Also one client can make about 8 connections, so the numbers are too low even for 1 client

from mtprotoproxy.

ali-jk avatar ali-jk commented on August 27, 2024

I tried USER_MAX_TCP_CONNS and problem solved
thank you

from mtprotoproxy.

ali4796 avatar ali4796 commented on August 27, 2024

hi alexbers
I have several questions for you
Please comment on your Telegram ID

from mtprotoproxy.

Related Issues (20)

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.