Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Proxifier target hosts config format support #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion chnroutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ def generate_android(metric):
print "Old school way to call up/down script from openvpn client. " \
"use the regular openvpn 2.1 method to add routes if it's possible"

def generate_proxifier(metric):
import ipaddress
results = fetch_ip_data()
for ip, mask, _ in results:
network = ipaddress.IPv4Network("%s/%s" % (ip, mask))
print "%s-%s;" % (network.network_address, network.broadcast_address),
print "\nUsage: copy all IP ranges and paste to \"Target Hosts\" of your Proxifier rule. "


def fetch_ip_data():
#fetch data from apnic
Expand Down Expand Up @@ -235,7 +243,7 @@ def fetch_ip_data():
default='openvpn',
nargs='?',
help="Target platforms, it can be openvpn, mac, linux,"
"win, android. openvpn by default.")
"win, android, proxifier. openvpn by default.")
parser.add_argument('-m','--metric',
dest='metric',
default=5,
Expand All @@ -255,6 +263,8 @@ def fetch_ip_data():
generate_win(args.metric)
elif args.platform.lower() == 'android':
generate_android(args.metric)
elif args.platform.lower() == 'proxifier':
generate_proxifier(args.metric)
else:
print>>sys.stderr, "Platform %s is not supported."%args.platform
exit(1)