-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from XX-net/master
update to 2829b7
- Loading branch information
Showing
80 changed files
with
9,011 additions
and
6,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"-confirmDeletion":false,"-downloadInterval":720,"-enableQuickSwitch":false,"-quickSwitchProfiles":["direct"],"-refreshOnProfileChange":false,"-revertProxyChanges":false,"-startupProfileName":"","schemaVersion":2,"-showInspectMenu":true,"-monitorWebRequests":true,"+GAE-Proxy":{"bypassList":[{"conditionType":"BypassCondition","pattern":"<local>"}],"color":"#d42d09","fallbackProxy":{"host":"127.0.0.1","port":8087,"scheme":"http"},"name":"GAE-Proxy","profileType":"FixedProfile","revision":"15383570633"},"+GAE-Proxy自动切换":{"color":"#55bb55","defaultProfileName":"__ruleListOf_GAE-Proxy自动切换","name":"GAE-Proxy自动切换","profileType":"SwitchProfile","revision":"15383578bce","rules":[{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.ggpht.com"},"profileName":"GAE-Proxy"},{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.google.com.*"},"profileName":"GAE-Proxy"},{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.google*.com"},"profileName":"GAE-Proxy"},{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.wikipedia.org"},"profileName":"GAE-Proxy"}]},"+__ruleListOf_GAE-Proxy自动切换":{"color":"#dd6633","defaultProfileName":"direct","format":"AutoProxy","matchProfileName":"GAE-Proxy","name":"__ruleListOf_GAE-Proxy自动切换","profileType":"RuleListProfile","revision":"1538357da4c","ruleList":"","sourceUrl":"https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt"},"+X-Tunnel":{"profileType":"FixedProfile","name":"X-Tunnel","bypassList":[{"conditionType":"BypassCondition","pattern":"<local>"}],"color":"#092dba","revision":"1538358c83c","fallbackProxy":{"scheme":"socks5","port":1080,"host":"127.0.0.1"}},"+X-Tunnel自动切换":{"profileType":"SwitchProfile","name":"X-Tunnel自动切换","defaultProfileName":"__ruleListOf_X-Tunnel自动切换","rules":[{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.ggpht.com"},"profileName":"X-Tunnel"},{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.google.com.*"},"profileName":"X-Tunnel"},{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.google*.com"},"profileName":"X-Tunnel"},{"condition":{"conditionType":"HostWildcardCondition","pattern":"*.wikipedia.org"},"profileName":"X-Tunnel"}],"color":"#7c05ae","revision":"153835abfe0"},"+__ruleListOf_X-Tunnel自动切换":{"name":"__ruleListOf_X-Tunnel自动切换","defaultProfileName":"direct","profileType":"RuleListProfile","color":"#7c05ae","format":"Switchy","matchProfileName":"X-Tunnel","ruleList":"","revision":"153835b3117","sourceUrl":"https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt"}} | ||
{"+X-Tunnel": {"name": "X-Tunnel", "color": "#092dba", "fallbackProxy": {"host": "127.0.0.1", "scheme": "socks5", "port": 1080}, "bypassList": [{"pattern": "<local>", "conditionType": "BypassCondition"}], "profileType": "FixedProfile", "revision": "1538358c83c"}, "+GAE-Proxy\u81ea\u52a8\u5207\u6362": {"name": "GAE-Proxy\u81ea\u52a8\u5207\u6362", "color": "#55bb55", "rules": [{"profileName": "GAE-Proxy", "condition": {"pattern": "*.ggpht.com", "conditionType": "HostWildcardCondition"}}, {"profileName": "GAE-Proxy", "condition": {"pattern": "*.google.com.*", "conditionType": "HostWildcardCondition"}}, {"profileName": "GAE-Proxy", "condition": {"pattern": "*.google*.com", "conditionType": "HostWildcardCondition"}}, {"profileName": "GAE-Proxy", "condition": {"pattern": "*.wikipedia.org", "conditionType": "HostWildcardCondition"}}], "profileType": "SwitchProfile", "defaultProfileName": "__ruleListOf_GAE-Proxy\u81ea\u52a8\u5207\u6362", "revision": "15383578bce"}, "+__ruleListOf_GAE-Proxy\u81ea\u52a8\u5207\u6362": {"sourceUrl": "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt", "name": "__ruleListOf_GAE-Proxy\u81ea\u52a8\u5207\u6362", "format": "AutoProxy", "color": "#dd6633", "matchProfileName": "GAE-Proxy", "profileType": "RuleListProfile", "defaultProfileName": "direct", "ruleList": "", "revision": "1538357da4c"}, "+__ruleListOf_X-Tunnel\u81ea\u52a8\u5207\u6362": {"sourceUrl": "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt", "name": "__ruleListOf_X-Tunnel\u81ea\u52a8\u5207\u6362", "format": "Switchy", "color": "#7c05ae", "matchProfileName": "X-Tunnel", "profileType": "RuleListProfile", "defaultProfileName": "direct", "ruleList": "", "revision": "153835b3117"}, "-monitorWebRequests": true, "-startupProfileName": "", "-showInspectMenu": true, "+Smart-Router": {"name": "Smart-Router", "color": "#096dba", "fallbackProxy": {"host": "127.0.0.1", "scheme": "socks5", "port": 8086}, "bypassList": [{"pattern": "<local>", "conditionType": "BypassCondition"}], "profileType": "FixedProfile", "revision": "1538358c83c"}, "+GAE-Proxy": {"name": "GAE-Proxy", "color": "#d42d09", "fallbackProxy": {"host": "127.0.0.1", "scheme": "http", "port": 8087}, "bypassList": [{"pattern": "<local>", "conditionType": "BypassCondition"}], "profileType": "FixedProfile", "revision": "15383570633"}, "-confirmDeletion": false, "-revertProxyChanges": false, "+X-Tunnel\u81ea\u52a8\u5207\u6362": {"name": "X-Tunnel\u81ea\u52a8\u5207\u6362", "rules": [{"profileName": "X-Tunnel", "condition": {"pattern": "*.ggpht.com", "conditionType": "HostWildcardCondition"}}, {"profileName": "X-Tunnel", "condition": {"pattern": "*.google.com.*", "conditionType": "HostWildcardCondition"}}, {"profileName": "X-Tunnel", "condition": {"pattern": "*.google*.com", "conditionType": "HostWildcardCondition"}}, {"profileName": "X-Tunnel", "condition": {"pattern": "*.wikipedia.org", "conditionType": "HostWildcardCondition"}}], "color": "#7c05ae", "profileType": "SwitchProfile", "defaultProfileName": "__ruleListOf_X-Tunnel\u81ea\u52a8\u5207\u6362", "revision": "153835abfe0"}, "-refreshOnProfileChange": false, "-quickSwitchProfiles": ["direct"], "schemaVersion": 2, "-enableQuickSwitch": false, "-downloadInterval": 720} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,12 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
__author__ = '[email protected]' | ||
|
||
import re | ||
|
||
def ip_string_to_num(s): | ||
"""Convert dotted IPv4 address to integer.""" | ||
return reduce(lambda a, b: a << 8 | b, map(int, s.split("."))) | ||
from utils import * | ||
|
||
def get_ip_maskc(ip_str): | ||
head = ".".join(ip_str.split(".")[:-1]) | ||
return head + ".0" | ||
|
||
def ip_num_to_string(ip): | ||
"""Convert 32-bit integer to dotted IPv4 address.""" | ||
return ".".join(map(lambda n: str(ip >> n & 0xFF), [24, 16, 8, 0])) | ||
|
||
|
||
|
||
g_ip_check = re.compile(r'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$') | ||
|
||
def check_ip_valid4(ip): | ||
"""检查ipv4地址的合法性""" | ||
ret = g_ip_check.match(ip) | ||
if ret is not None: | ||
"each item range: [0,255]" | ||
for item in ret.groups(): | ||
if int(item) > 255: | ||
return 0 | ||
return 1 | ||
else: | ||
return 0 | ||
|
||
|
||
def is_valid_ipv6(ip): | ||
"""Copied from http://stackoverflow.com/a/319293/2755602""" | ||
"""Validates IPv6 addresses. | ||
""" | ||
pattern = re.compile(r""" | ||
^ | ||
\s* # Leading whitespace | ||
(?!.*::.*::) # Only a single whildcard allowed | ||
(?:(?!:)|:(?=:)) # Colon iff it would be part of a wildcard | ||
(?: # Repeat 6 times: | ||
[0-9a-f]{0,4} # A group of at most four hexadecimal digits | ||
(?:(?<=::)|(?<!::):) # Colon unless preceeded by wildcard | ||
){6} # | ||
(?: # Either | ||
[0-9a-f]{0,4} # Another group | ||
(?:(?<=::)|(?<!::):) # Colon unless preceeded by wildcard | ||
[0-9a-f]{0,4} # Last group | ||
(?: (?<=::) # Colon iff preceeded by exacly one colon | ||
| (?<!:) # | ||
| (?<=:) (?<!::) : # | ||
) # OR | ||
| # A v4 address with NO leading zeros | ||
(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d) | ||
(?: \. | ||
(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d) | ||
){3} | ||
) | ||
\s* # Trailing whitespace | ||
$ | ||
""", re.VERBOSE | re.IGNORECASE | re.DOTALL) | ||
return pattern.match(ip) is not None | ||
|
||
def check_ip_valid6(ip): | ||
"""检查ipv6地址的合法性""" | ||
if is_valid_ipv6(ip): | ||
return 1 | ||
else: | ||
return 0 | ||
|
||
def check_ip_valid(ip): | ||
if ':' in ip: | ||
return check_ip_valid6(ip) | ||
else: | ||
return check_ip_valid4(ip) | ||
|
||
def split_ip(strline): | ||
"""从每组地址中分离出起始IP以及结束IP""" | ||
|
@@ -113,7 +43,7 @@ def split_ip(strline): | |
elif "/" in strline: | ||
"xxx.xxx.xxx.xxx/xx" | ||
(ip, bits) = strline.split("/") | ||
if check_ip_valid(ip) and (0 <= int(bits) <= 32): | ||
if check_ip_valid4(ip) and (0 <= int(bits) <= 32): | ||
orgip = ip_string_to_num(ip) | ||
end_bits = (1 << (32 - int(bits))) - 1 | ||
begin_bits = 0xFFFFFFFF ^ end_bits | ||
|
Oops, something went wrong.