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
8faa0526
Commit
8faa0526
authored
Apr 18, 2010
by
911mxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TWFjIGNvbXBsaWFudCBmb3Igc2VuZEdGV0xpc3Quc2gK
parent
6f3ddd04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
addChecksum.pl
addChecksum.pl
+8
-0
sendGFWList.sh
sendGFWList.sh
+10
-14
No files found.
addChecksum.pl
View file @
8faa0526
...
...
@@ -17,6 +17,9 @@
use
strict
;
use
warnings
;
use
Digest::
MD5
qw(md5_base64)
;
use
File::
stat
;
use
POSIX
qw(locale_h)
;
use
POSIX
qw(strftime)
;
die
"
Usage: $^X $0 subscription.txt
\n
"
unless
@ARGV
;
...
...
@@ -26,6 +29,11 @@ my $data = readFile($file);
# Remove already existing checksum
$data
=~
s/^.*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n//gmi
;
# Update timestamp
setlocale
(
LC_TIME
,
"
C
");
my
$timestamp
=
strftime
("
%a, %d %b %Y %H:%M:%S %z
",
localtime
(
stat
(
$file
)
->
mtime
));
$data
=~
s/^!\s*Last Modified:.*$/! Last Modified: $timestamp/mi
;
# Calculate new checksum: remove all CR symbols and empty
# lines and get an MD5 checksum of the result (base64-encoded,
# without the trailing = characters).
...
...
sendGFWList.sh
View file @
8faa0526
...
...
@@ -15,7 +15,7 @@
# $svn checkout https://autoproxy-gfwlist.googlecode.com/svn/trunk/ gfwList --username your-google-user-name
# $cd gfwList
# $git init
# $
base64 -d gfwlist.txt >
list.txt
# $
openssl base64 -d -in gfwlist.txt -out
list.txt
# $git add list.txt
# $git commit -a -m "init"
# Normal Usage:
...
...
@@ -29,7 +29,7 @@
################################################################################
# dependence
for
cmd
in
sed
date base64
g
awk svn git perl file
for
cmd
in
sed
openssl
awk
svn git perl file
do
which
$cmd
&> /dev/null
;
if
[
$?
-ne
0
]
;
then
...
...
@@ -39,9 +39,8 @@ do
done
# get formated author and log information
log
=
$(
svn log
-r
BASE:HEAD
)
||
exit
1
;
log
=
$(
echo
$log
| gawk
-v
RS
=
'------------------------------------------------------------------------'
\
'NR > 2 { if (NF > 10) printf "%s:%s;", $3, $NF; }'
)
&&
log
=
$(
svn log
--xml
-r
BASE:HEAD
)
||
exit
1
;
log
=
$(
echo
$log
|
awk
-v
RS
=
''
-F
'</?author>|</?msg>'
'{ for(i=6;i<NF;i+=4) printf "%s:%s;",$i,$(i+2); }'
)
&&
# convert from base64
i
=
0
&&
...
...
@@ -55,7 +54,7 @@ do
# discard used string
log
=
${
log
#*
:
}
;
else
# log, decode it
temp
=
$(
echo
${
log
%%;*
}
|
base64
-d
)
;
temp
=
$(
echo
${
log
%%;*
}
|
openssl
base64
-d
)
;
convertedLog+
=
$temp
;
convertedLog+
=
"
\n
"
;
log
=
${
log
#*;
}
;
...
...
@@ -69,7 +68,7 @@ if [ "$convertedLog" != "" ]; then
svn update
||
exit
1
;
base64
-d
gfwlist.txt
>
list.txt
&&
./validateChecksum.pl list.txt
;
openssl
base64
-d
-in
gfwlist.txt
-out
list.txt
&&
./validateChecksum.pl list.txt
;
if
[
$?
-ne
0
]
;
then
echo
"Error: gfwlist.txt from svn is invalid!"
;
echo
"It must be a download error or somebody made a mistake."
;
...
...
@@ -101,7 +100,7 @@ if [ "$*" == "" ]; then
exit
1
;
fi
if
[
"
$(
file
list.txt
)
"
!=
"list.txt:
ASCII text"
]
;
then
if
[
"
$(
file
-b
list.txt
)
"
!=
"
ASCII text"
]
;
then
echo
"Error: list.txt, please make sure:"
;
echo
"1. there is no non-ASCII characters;"
;
echo
"2. configure your text editor to use unix style line break."
;
...
...
@@ -109,21 +108,18 @@ if [ "$(file list.txt)" != "list.txt: ASCII text" ]; then
fi
# update date and checksum
sed
-i
s/
"Last Modified:.*$"
/
"Last Modified:
$(
date
-Rr
list.txt
)
"
/ list.txt
&&
./addChecksum.pl list.txt
&&
# save local changes to git & svn
# if conflict or network problem occurs: do nothing & throw error message
git commit
-a
-m
"
$*
"
&&
(
base64
list.txt
>
gfwlist.txt
&&
# may be running under Windows + Cygwin?
openssl
base64
-in
list.txt |
# convert dos new line to unix style, old mac style ignored
sed
-i
's/\r$//g'
gfwlist.txt
&&
tr
-d
'\r'
>
gfwlist.txt
&&
# may be failed because of connection/authentication problems
svn ci gfwlist.txt
-m
$(
echo
"
$*
"
|
base64
-w
0
)
||
svn ci gfwlist.txt
-m
$(
echo
"
$*
"
|
openssl
base64
|
tr
-d
'\n'
)
||
# "svn ci" and "git commit" are atomic operations
git reset HEAD^ 1> /dev/null
;
...
...
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