bugfix
This commit is contained in:
parent
540337895e
commit
983a30e197
15
proxy
Executable file
15
proxy
Executable file
@ -0,0 +1,15 @@
|
||||
###
|
||||
# need change username and domain to your
|
||||
# username
|
||||
# domain
|
||||
start_proxy()
|
||||
{
|
||||
while [ "1" = "1" ]
|
||||
do
|
||||
ssh -N -D 0.0.0.0:1086 username@domain
|
||||
done
|
||||
}
|
||||
|
||||
start_proxy &
|
||||
socks start
|
||||
echo "proxy started"
|
46
socks
Executable file
46
socks
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sh
|
||||
def getNetWorkServices():
|
||||
x = sh.networksetup('-listallnetworkservices');
|
||||
s = x.split('\n')
|
||||
s = [ i for i in s if i!='' ]
|
||||
s = s[1:]
|
||||
print(s);
|
||||
return s
|
||||
|
||||
def getIpByService(s):
|
||||
print('s=', s)
|
||||
x = sh.networksetup('-getinfo', s)
|
||||
lines = x.split('\n')
|
||||
start = 'IP address: '
|
||||
for l in lines:
|
||||
if l.startswith(start):
|
||||
return l[len(start):]
|
||||
return None
|
||||
|
||||
def disableProxy():
|
||||
services = getNetWorkServices()
|
||||
ret = {s:getIpByService(s) for s in services}
|
||||
for s,ip in ret.items():
|
||||
if ip is not None:
|
||||
sh.networksetup('-setsocksfirewallproxystate', s, 'off')
|
||||
print(s, ip, 'socks stoped')
|
||||
|
||||
def enableProxy():
|
||||
services = getNetWorkServices()
|
||||
ret = {s:getIpByService(s) for s in services}
|
||||
for s,ip in ret.items():
|
||||
if ip is not None:
|
||||
ip_domain = '.'.join(ip.split('.')[:-1])
|
||||
sh.networksetup('-setsocksfirewallproxy', s, ip, '1086')
|
||||
sh.networksetup('-setproxybypassdomains', s, ip_domain)
|
||||
print(s, ip, 'socks started')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if len(sys.argv) > 1 and sys.argv[1] == 'stop':
|
||||
disableProxy()
|
||||
else:
|
||||
enableProxy()
|
Loading…
Reference in New Issue
Block a user