|
@ -1,6 +1,7 @@ |
|
|
#!/usr/bin/python |
|
|
#!/usr/bin/python |
|
|
# -*- coding:utf-8 -*- |
|
|
# -*- coding:utf-8 -*- |
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
import time |
|
|
import time |
|
|
import ctypes |
|
|
import ctypes |
|
|
import random |
|
|
import random |
|
@ -8,8 +9,13 @@ import socket |
|
|
import subprocess |
|
|
import subprocess |
|
|
from ProxyBuilder import Shadowsocks |
|
|
from ProxyBuilder import Shadowsocks |
|
|
|
|
|
|
|
|
# TODO: find in multi path |
|
|
libcPaths = [ |
|
|
libcPath = '/lib/libc.musl-x86_64.so.1' # for Alpine |
|
|
'/usr/lib64/libc.so.6', # CentOS |
|
|
|
|
|
'/lib/i386-linux-gnu/libc.so.6', # Debian / Ubuntu |
|
|
|
|
|
'/lib/x86_64-linux-gnu/libc.so.6', |
|
|
|
|
|
'/lib/aarch64-linux-gnu/libc.so.6', |
|
|
|
|
|
'/lib/libc.musl-x86_64.so.1', # Alpine |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
# TODO: TCP/UDP IPv4/IPv6 |
|
|
# TODO: TCP/UDP IPv4/IPv6 |
|
|
def __checkPortAvailable(port, host = '127.0.0.1'): # 检测端口可用性 |
|
|
def __checkPortAvailable(port, host = '127.0.0.1'): # 检测端口可用性 |
|
@ -59,6 +65,9 @@ def build(proxyInfo, configDir): # 构建代理节点连接 |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
|
|
|
for libcPath in libcPaths: |
|
|
|
|
|
if os.path.exists(libcPath): # 定位libc.so文件 |
|
|
|
|
|
break |
|
|
exitWithMe = lambda: ctypes.CDLL(libcPath).prctl(1, 15) # SIGTERM |
|
|
exitWithMe = lambda: ctypes.CDLL(libcPath).prctl(1, 15) # SIGTERM |
|
|
process = subprocess.Popen(startCommand, \ |
|
|
process = subprocess.Popen(startCommand, \ |
|
|
stdout = subprocess.DEVNULL, \ |
|
|
stdout = subprocess.DEVNULL, \ |
|
|