gfwlist2ipset 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gfwlist2ipset +51 -55
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c12a0f17faa22ec9f211c3b4490f9866fb8442d
|
4
|
+
data.tar.gz: 6dc106f6498608d0e083003a14fa13863fb77ed8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a740d0cbd497d4f8ddc95090d1d97e2aba8ed652d3b38941c520ed81e52d608657e0d3356ea18249d167097a38e1758bb848634f37704d43e8d97889c8696f
|
7
|
+
data.tar.gz: 7496d17e670b1c752cf9447be3c3f4659e050ff23f10ea08b44197d9952d60d3e83629598c44dcd5a53b81ca8ac0bf8a5076731e410f8d52e314366f7f2de884
|
data/bin/gfwlist2ipset
CHANGED
@@ -6,7 +6,7 @@ require 'public_suffix'
|
|
6
6
|
|
7
7
|
options = {}
|
8
8
|
OptionParser.new do |opts|
|
9
|
-
opts.banner =
|
9
|
+
opts.banner = 'Usage: gfwlist2ipset [options]'
|
10
10
|
|
11
11
|
options[:ipset] = 'outwall'
|
12
12
|
options[:output] = 'gfwlist.conf'
|
@@ -24,55 +24,57 @@ OptionParser.new do |opts|
|
|
24
24
|
end
|
25
25
|
end.parse!
|
26
26
|
|
27
|
-
gfwlist_url = 'https://
|
27
|
+
gfwlist_url = 'https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt'
|
28
28
|
extra_domains = [
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
29
|
+
'admob.com',
|
30
|
+
'akamaihd.net',
|
31
|
+
'amazonaws.com',
|
32
|
+
'appledaily.com.hk',
|
33
|
+
'appledaily.com.tw',
|
34
|
+
'bbc.com',
|
35
|
+
'blogspot.com',
|
36
|
+
'fastly.net',
|
37
|
+
'githubusercontent.com',
|
38
|
+
'google-analytics.com',
|
39
|
+
'google.as',
|
40
|
+
'google.co.jp',
|
41
|
+
'google.co.id',
|
42
|
+
'google.co.th',
|
43
|
+
'google.co.uk',
|
44
|
+
'google.com',
|
45
|
+
'google.com.hk',
|
46
|
+
'google.com.tw',
|
47
|
+
'googlesyndication.com',
|
48
|
+
's3.feedly.com',
|
49
|
+
'cloudfront.net',
|
50
|
+
'ace-cdn.atlassian.com',
|
51
|
+
'wufoo.com',
|
52
|
+
'nextmedia.com',
|
53
|
+
'cxense.com',
|
54
|
+
'krxd.net',
|
55
|
+
'chartbeat.net',
|
56
|
+
'slack-files.com',
|
57
|
+
'slack-redir.net',
|
58
|
+
'files.slack.com',
|
59
|
+
'fbinfer.com',
|
60
|
+
'line.naver.jp',
|
61
|
+
'packages.gitlab.com'
|
56
62
|
]
|
57
63
|
|
58
64
|
def get_hostname(rule)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
else
|
69
|
-
puts 'Hostname not valid: ' + host
|
70
|
-
end
|
71
|
-
return nil
|
72
|
-
rescue
|
73
|
-
puts 'can not parse rule as url: ' + rule
|
74
|
-
return nil
|
65
|
+
host = URI.parse(rule).host
|
66
|
+
if PublicSuffix.valid?(host)
|
67
|
+
return PublicSuffix.parse(host).domain
|
68
|
+
elsif PublicSuffix.valid?('.' + host)
|
69
|
+
tld = PublicSuffix.parse('.' + host).tld
|
70
|
+
return tld if tld.include?('.') && tld == host
|
71
|
+
else
|
72
|
+
puts 'Hostname not valid: ' + host
|
75
73
|
end
|
74
|
+
return nil
|
75
|
+
rescue
|
76
|
+
puts 'can not parse rule as url: ' + rule
|
77
|
+
return nil
|
76
78
|
end
|
77
79
|
|
78
80
|
enc = open(gfwlist_url).read
|
@@ -92,25 +94,19 @@ plain.each_line do |line|
|
|
92
94
|
elsif line.start_with? '.'
|
93
95
|
line = line.sub('.', '')
|
94
96
|
end
|
95
|
-
if line.start_with?
|
96
|
-
next
|
97
|
-
end
|
97
|
+
next if line.start_with?('!') || line.start_with?('[') || line.start_with?('@')
|
98
98
|
line.chomp!
|
99
99
|
if line.length > 0
|
100
|
-
|
101
|
-
line = 'http://' + line
|
102
|
-
end
|
100
|
+
line = 'http://' + line unless line.start_with? 'http'
|
103
101
|
hostname = get_hostname(line)
|
104
|
-
if hostname
|
105
|
-
domains.push(hostname)
|
106
|
-
end
|
102
|
+
domains.push(hostname) if hostname
|
107
103
|
end
|
108
104
|
end
|
109
105
|
|
110
106
|
domains.concat extra_domains
|
111
107
|
File.open(options[:output], 'w+') do |f|
|
112
108
|
f.puts '# Generated by gfwlist2ipset at ' + Time.new.inspect
|
113
|
-
if options.
|
109
|
+
if options.key?(:dns)
|
114
110
|
domains.sort.uniq.each do |domain|
|
115
111
|
f.puts('server=/' + domain + '/' + options[:dns])
|
116
112
|
f.puts('ipset=/' + domain + '/' + options[:ipset])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gfwlist2ipset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nullizer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: public_suffix
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
54
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
55
|
+
rubygems_version: 2.5.1
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: gfwlist2ipset
|