mirror of
https://github.com/alexbers/mtprotoproxy.git
synced 2026-03-13 23:03:09 +00:00
Add support for upstream SOCKS5 proxy (#143)
This commit is contained in:
committed by
Alexander Bersenev
parent
5fcd1c0158
commit
516600a32d
@@ -20,3 +20,7 @@ SECURE_ONLY = True
|
||||
|
||||
# Tag for advertising, obtainable from @MTProxybot
|
||||
# AD_TAG = "3c09c680b76ee91a4c25ad51f742267d"
|
||||
|
||||
# Use upstream SOCKS5 proxy for connections (f.e. Tor)
|
||||
# SOCKS5_HOST = "localhost"
|
||||
# SOCKS5_PORT = 9050
|
||||
|
||||
@@ -4,6 +4,7 @@ import asyncio
|
||||
import socket
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import socks
|
||||
import collections
|
||||
import time
|
||||
import datetime
|
||||
@@ -120,6 +121,10 @@ def init_config():
|
||||
|
||||
# load advanced settings
|
||||
|
||||
# use upstream SOCKS5 proxy
|
||||
conf_dict.setdefault("SOCKS5_HOST", "localhost")
|
||||
conf_dict.setdefault("SOCKS5_PORT", 0)
|
||||
|
||||
# use middle proxy, necessary to show ad
|
||||
conf_dict.setdefault("USE_MIDDLE_PROXY", len(conf_dict["AD_TAG"]) == 16)
|
||||
|
||||
@@ -1869,6 +1874,10 @@ def init_ip_info():
|
||||
global my_ip_info
|
||||
global disable_middle_proxy
|
||||
|
||||
if not config.SOCKS5_PORT == 0:
|
||||
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, config.SOCKS5_HOST, config.SOCKS5_PORT)
|
||||
socket.socket = socks.socksocket
|
||||
|
||||
def get_ip_from_url(url):
|
||||
TIMEOUT = 5
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user