disable socks for local
This commit is contained in:
parent
372dda4c3b
commit
960c1f639b
15
stream.py
15
stream.py
@ -34,6 +34,9 @@ class ProxyElem():
|
||||
session.set_option("https-proxy", "socks5://" + self.proxy)
|
||||
session.set_option("http-proxy", "socks5://" + self.proxy)
|
||||
return session
|
||||
def local(self):
|
||||
timeout = aiohttp.ClientTimeout(total=1)
|
||||
return aiohttp.ClientSession(timeout=timeout)
|
||||
def session(self):
|
||||
connector = None
|
||||
if self.proxy is not None:
|
||||
@ -52,6 +55,9 @@ class ProxyElem():
|
||||
logger.info(e)
|
||||
return ctype
|
||||
async def proxy_url(self, current, path):
|
||||
if proxy_server is None:
|
||||
return data["upstream"]
|
||||
jdata = None
|
||||
data = {}
|
||||
data_list = [data]
|
||||
if path is None:
|
||||
@ -64,18 +70,13 @@ class ProxyElem():
|
||||
data["proxied"] = False
|
||||
else:
|
||||
data["proxy"] = self.proxy
|
||||
if proxy_server is None:
|
||||
return data["upstream"]
|
||||
|
||||
jdata = None
|
||||
try:
|
||||
async with self.session() as session:
|
||||
async with self.local() as session:
|
||||
resp = await session.post(proxy_server, json=data_list)
|
||||
text = await resp.text()
|
||||
jdata = json.loads(text)
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
|
||||
if isinstance(jdata, list) and len(jdata) == 1:
|
||||
return jdata[0]
|
||||
else:
|
||||
@ -268,7 +269,7 @@ async def rewrite(current, proxy):
|
||||
if isinstance(proxy_server, str):
|
||||
ndata = ""
|
||||
try:
|
||||
async with proxy.session() as session:
|
||||
async with proxy.local() as session:
|
||||
resp = await session.post(proxy_server, json=links)
|
||||
link_text = await resp.text()
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user