gfwlist2ipset 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gfwlist2ipset +42 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d12008839913290b5803083a391f341870efd253
4
- data.tar.gz: a82b404b919b973ddd0aea5f6a88bba201653dea
3
+ metadata.gz: ec3da723af1f59cb914ccb38d3f2af34ce676af5
4
+ data.tar.gz: 627f9ac7ea9d24b522df3eb56a63ee0b67a47f80
5
5
  SHA512:
6
- metadata.gz: 297daedc74bba9d7f9d88613248e6bcc63af4a82f2fe1493af33cf24eace20520f10a78215463f86656fc9ab6bddac090ceb458829fc8c09d0f862fc45ae00e4
7
- data.tar.gz: 2ad074bb4c2a7dcef7615c212891aa471447521b9ba14f22e7e5cafd56ccc317478eadcceaf8210aea2e47b6a2062e0524837bcc2c25c8fcebcc2d3d45aa64e8
6
+ metadata.gz: 37c9b55d69ac549e56a3e711c959ab146cc5613e39074b07e3eb243b257b64f33f101c7fd0126ba5336f4b997d1c5f2912053d40a18141df3328b8e56ad13807
7
+ data.tar.gz: 5b30ae6602d573d74cee1969202f033b0ff670eeeb6f2d2e92883c413902fb5a737ea7e865edf7b5df450d1830a4e02ad999bf2199822bd532b6d59342c05d43
data/bin/gfwlist2ipset CHANGED
@@ -1,23 +1,52 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'optparse'
2
3
  require 'open-uri'
3
4
  require 'base64'
4
5
  require 'public_suffix'
5
6
 
7
+ options = {}
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: gfwlist2ipset [options]"
10
+
11
+ opts.on('-d <DNS Server>', '--dns <DNS Server>', 'Set a DNS Server') do |value|
12
+ options[:dns] = value
13
+ end
14
+
15
+ options[:output] = 'gfwlist.conf'
16
+ opts.on('-o OUTPUT', '--output OUTPUT', 'Output file, default: gfwlist.conf') do |value|
17
+ options[:output] = value
18
+ end
19
+ end.parse!
20
+
6
21
  gfwlist_url = 'https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt'
7
22
  extra_domains = [
23
+ "appledaily.com.hk",
24
+ "bbc.com",
8
25
  "blogspot.com",
9
26
  "fastly.net",
10
27
  "githubusercontent.com",
11
28
  "google-analytics.com",
12
- "google.co.hk",
29
+ "google.as",
13
30
  "google.co.jp",
31
+ "google.co.id",
32
+ "google.co.th",
33
+ "google.co.uk",
14
34
  "google.com",
15
35
  "google.com.hk",
36
+ "google.com.tw",
16
37
  "googlesyndication.com",
17
38
  "s3.amazonaws.com",
18
39
  "s3.feedly.com",
19
40
  "cloudfront.net",
20
41
  "ace-cdn.atlassian.com",
42
+ "wufoo.com",
43
+ "nextmedia.com",
44
+ "cxense.com",
45
+ "krxd.net",
46
+ "chartbeat.net",
47
+ "slack-files.com",
48
+ "fbinfer.com",
49
+ "line.naver.jp",
21
50
  ]
22
51
 
23
52
  def get_hostname(rule)
@@ -73,7 +102,16 @@ plain.each_line do |line|
73
102
  end
74
103
 
75
104
  domains.concat extra_domains
76
- File.open('gfwlist.conf', 'w+') do |f|
105
+ File.open(options[:output], 'w+') do |f|
77
106
  f.puts '# Generated by gfwlist2ipset at ' + Time.new.inspect
78
- domains.sort.uniq.each { |domain| f.puts('ipset=/' + domain + '/outwall') }
79
- end
107
+ if options.has_key?(:dns)
108
+ domains.sort.uniq.each do |domain|
109
+ f.puts('server=/' + domain + '/' + options[:dns])
110
+ f.puts('ipset=/' + domain + '/outwall')
111
+ end
112
+ else
113
+ domains.sort.uniq.each do |domain|
114
+ f.puts('ipset=/' + domain + '/outwall')
115
+ end
116
+ end
117
+ end
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nullizer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: public_suffix