gfwlist2ipset 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/gfwlist2ipset +79 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d12008839913290b5803083a391f341870efd253
|
4
|
+
data.tar.gz: a82b404b919b973ddd0aea5f6a88bba201653dea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 297daedc74bba9d7f9d88613248e6bcc63af4a82f2fe1493af33cf24eace20520f10a78215463f86656fc9ab6bddac090ceb458829fc8c09d0f862fc45ae00e4
|
7
|
+
data.tar.gz: 2ad074bb4c2a7dcef7615c212891aa471447521b9ba14f22e7e5cafd56ccc317478eadcceaf8210aea2e47b6a2062e0524837bcc2c25c8fcebcc2d3d45aa64e8
|
data/bin/gfwlist2ipset
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'open-uri'
|
3
|
+
require 'base64'
|
4
|
+
require 'public_suffix'
|
5
|
+
|
6
|
+
gfwlist_url = 'https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt'
|
7
|
+
extra_domains = [
|
8
|
+
"blogspot.com",
|
9
|
+
"fastly.net",
|
10
|
+
"githubusercontent.com",
|
11
|
+
"google-analytics.com",
|
12
|
+
"google.co.hk",
|
13
|
+
"google.co.jp",
|
14
|
+
"google.com",
|
15
|
+
"google.com.hk",
|
16
|
+
"googlesyndication.com",
|
17
|
+
"s3.amazonaws.com",
|
18
|
+
"s3.feedly.com",
|
19
|
+
"cloudfront.net",
|
20
|
+
"ace-cdn.atlassian.com",
|
21
|
+
]
|
22
|
+
|
23
|
+
def get_hostname(rule)
|
24
|
+
begin
|
25
|
+
host = URI.parse(rule).host
|
26
|
+
if PublicSuffix.valid?(host)
|
27
|
+
return PublicSuffix.parse(host).domain
|
28
|
+
elsif PublicSuffix.valid?('.' + host)
|
29
|
+
tld = PublicSuffix.parse('.' + host).tld
|
30
|
+
if tld.include?('.') and tld == host
|
31
|
+
return tld
|
32
|
+
end
|
33
|
+
else
|
34
|
+
puts 'Hostname not valid: ' + host
|
35
|
+
end
|
36
|
+
return nil
|
37
|
+
rescue
|
38
|
+
puts 'can not parse rule as url: ' + rule
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
enc = open(gfwlist_url).read
|
44
|
+
plain = Base64.decode64(enc)
|
45
|
+
|
46
|
+
domains = []
|
47
|
+
plain.each_line do |line|
|
48
|
+
if line.include? '.*'
|
49
|
+
next
|
50
|
+
elsif line.include? '*'
|
51
|
+
line = line.gsub('*', '/')
|
52
|
+
end
|
53
|
+
if line.start_with? '||'
|
54
|
+
line = line.sub('||', '')
|
55
|
+
elsif line.start_with? '|'
|
56
|
+
line = line.sub('|', '')
|
57
|
+
elsif line.start_with? '.'
|
58
|
+
line = line.sub('.', '')
|
59
|
+
end
|
60
|
+
if line.start_with? '!' or line.start_with? '[' or line.start_with? '@'
|
61
|
+
next
|
62
|
+
end
|
63
|
+
line.chomp!
|
64
|
+
if line.length > 0
|
65
|
+
if not line.start_with? 'http'
|
66
|
+
line = 'http://' + line
|
67
|
+
end
|
68
|
+
hostname = get_hostname(line)
|
69
|
+
if hostname
|
70
|
+
domains.push(hostname)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
domains.concat extra_domains
|
76
|
+
File.open('gfwlist.conf', 'w+') do |f|
|
77
|
+
f.puts '# Generated by gfwlist2ipset at ' + Time.new.inspect
|
78
|
+
domains.sort.uniq.each { |domain| f.puts('ipset=/' + domain + '/outwall') }
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gfwlist2ipset
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nullizer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: public_suffix
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Generate dnsmasq ipset configure file from gfwlist
|
28
|
+
email: nullizer@gmail.com
|
29
|
+
executables:
|
30
|
+
- gfwlist2ipset
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/gfwlist2ipset
|
35
|
+
homepage: http://rubygems.org/gems/gfwlist2ipset
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.4.6
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: gfwlist2ipset
|
59
|
+
test_files: []
|