diff --git a/mtprotoproxy.py b/mtprotoproxy.py index 9a56cd8..d05df83 100755 --- a/mtprotoproxy.py +++ b/mtprotoproxy.py @@ -11,6 +11,7 @@ import random import binascii import sys + try: from Crypto.Cipher import AES from Crypto.Util import Counter @@ -48,6 +49,16 @@ except ImportError: return EncryptorAdapter(mode) +try: + import resource + soft_fd_limit, hard_fd_limit = resource.getrlimit(resource.RLIMIT_NOFILE) + resource.setrlimit(resource.RLIMIT_NOFILE, (hard_fd_limit, hard_fd_limit)) +except (ValueError, OSError): + print("Failed to increase the limit of opened files", flush=True, file=sys.stderr) +except ImportError: + pass + + import config PORT = getattr(config, "PORT") USERS = getattr(config, "USERS")