Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gfwlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
gfwlist
Commits
6b5708ac
Commit
6b5708ac
authored
Aug 28, 2010
by
xu.jimmy.wrk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QWRkIGNvbW1lbnRzIHRvIGNoZWNrUnVsZXMucHk=
parent
d84cc5b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
checkRules.py
checkRules.py
+28
-5
No files found.
checkRules.py
View file @
6b5708ac
#!/usr/bin/python -u
#!/usr/bin/python -u
# vim: ai et fileencoding=utf-8 ts=4 sw=4:
# vim: ai et fileencoding=utf-8 ts=4 sw=4:
'''
This script will read `list.txt', and write both stdout and `list.err'.
Rules which are comments or regexs will be ignored.
* For `.example.com', if you got anything other than 56, then unless the
page contains DPI keyword, consider the rule invalid.
* For `||example.com', if you got anything other than 28, then consider
the rule invalid. (For issue 117, see below.)
* For `|https://*.example.com', if you got anything other than 35, check
it manually before considering it invalid.
In addition, if you got 6 or 7, check the rule again manually. If in
doubt, check the rule again manually. Also, please remember: `Garbage
in, garbage out.'
XXX: As a workaround for issue 117, `|http://example.com/' will be
tested as `.example.com/'.
'''
from
urllib
import
unquote
from
urllib
import
unquote
import
re
import
subprocess
import
subprocess
import
sys
import
sys
...
@@ -27,11 +50,11 @@ def getUrl(rule):
...
@@ -27,11 +50,11 @@ def getUrl(rule):
rule
=
rule
.
decode
(
'gbk'
,
'ignore'
)
rule
=
rule
.
decode
(
'gbk'
,
'ignore'
)
if
rule
.
startswith
(
'||'
):
return
(
'http://'
+
rule
[
2
:],
IP
)
if
rule
.
startswith
(
'||'
):
return
(
'http://'
+
rule
[
2
:],
IP
)
if
rule
.
startswith
(
'|https'
):
return
(
rule
[
1
:],
TLS
)
if
rule
.
startswith
(
'|https'
):
return
(
rule
[
1
:],
TLS
)
else
:
if
rule
.
startswith
(
'|http://'
)
:
offset
+=
1
rule
=
'.'
+
rule
[
8
:]
# XXX: issue 117
if
offset
>=
len
(
iplist
):
offset
=
0
offset
+=
1
return
(
testurl
%
iplist
[
offset
]
+
rule
,
URL
)
if
offset
>=
len
(
iplist
):
offset
=
0
return
(
rule
,
INVALID
)
return
(
testurl
%
iplist
[
offset
]
+
rule
,
URL
)
def
main
():
def
main
():
fin
=
open
(
'list.txt'
,
'r'
)
fin
=
open
(
'list.txt'
,
'r'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment