girl 9.2.2 → 9.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55f30955ae63478d965bc22318bb3d2afed05b761fc4175ba6f322d412dbcb4f
4
- data.tar.gz: 3d8c72f7c8f88de9546f0add1d1a6eb8d5e3e070e79ce6929eb374a382892133
3
+ metadata.gz: f4ee7503a62e9790a615f594b369ce5170dad38f21e21c7918805b5376ae1e9b
4
+ data.tar.gz: b73cd2f06a84c49b0e620bb2f340073a2ed146cfbb78ef68cfa7cb69c67133f2
5
5
  SHA512:
6
- metadata.gz: 578cfb6933967ef88ac218c62e97dfad035eac184a8676c404e93f93d2864e61f99888823d6edacdbd59615306b3a3bb9fced768cdac8fa30a7ab7236637333c
7
- data.tar.gz: 5d4accd78932aa5385ba21e546002755973c92d0be9ee209af9fb75d9be9a526df1910bf68ecbf61ea9e4dd4bcee0727a421f414af04cb8513bf4c22cdb9d5c2
6
+ metadata.gz: 5b98f165da508bec146215eb392ffb5124c495cb4b8e6b8019396f5924403f73ddcae47c97fa2e38927ce632553306347a4c728ae7d2d1231f3a35541e8d179c
7
+ data.tar.gz: 6f48f78bf0de89cfc3ccd96fe8045e10709ff16bff5757d8e74f9765fc0974a6e093a2079f0e202d6a0c8f0435debc0e13dc60b707607fc3a7960229d88400de
data/lib/girl/proxy.rb CHANGED
@@ -32,7 +32,7 @@ module Girl
32
32
  nameserver = conf[:nameserver]
33
33
  im = conf[:im]
34
34
  direct_path = conf[:direct_path]
35
- remote_path = conf[:remote_path]
35
+ white_path = conf[:white_path]
36
36
  appd_host = conf[:appd_host]
37
37
  appd_port = conf[:appd_port]
38
38
  head_len = conf[:head_len] # 头长度
@@ -78,11 +78,18 @@ module Girl
78
78
  directs = (RESERVED_ROUTE.split("\n") + IO.binread(direct_path).split("\n")).map{|line| IPAddr.new(line.strip)}
79
79
  end
80
80
 
81
- remotes = []
81
+ whites = []
82
82
 
83
- if remote_path
84
- raise "not found remote file #{remote_path}" unless File.exist?(remote_path)
85
- remotes = IO.binread(remote_path).split("\n").map{|line| line.strip}
83
+ if white_path
84
+ raise "not found white file #{white_path}" unless File.exist?(white_path)
85
+
86
+ IO.binread(white_path).split("\n").each do |line|
87
+ domain = line.split(' ').first
88
+
89
+ if domain && (domain[0] != '#') && !whites.include?(domain)
90
+ whites << domain
91
+ end
92
+ end
86
93
  end
87
94
 
88
95
  appd_host = appd_host ? appd_host.to_s : '127.0.0.1'
@@ -122,7 +129,7 @@ module Girl
122
129
  puts "girl proxy #{Girl::VERSION} #{im} #{redir_port} #{tspd_port}"
123
130
  puts "#{proxyd_host} #{proxyd_port} #{appd_host} #{appd_port} #{nameservers.inspect} #{is_client_fastopen} #{is_server_fastopen}"
124
131
  puts "#{direct_path} #{directs.size} directs"
125
- puts "#{remote_path} #{remotes.size} remotes"
132
+ puts "#{white_path} #{whites.size} whites"
126
133
 
127
134
  if %w[darwin linux].any?{|plat| RUBY_PLATFORM.include?(plat)}
128
135
  Process.setrlimit(:NOFILE, RLIMIT)
@@ -143,7 +150,7 @@ module Girl
143
150
  nameservers,
144
151
  im,
145
152
  directs,
146
- remotes,
153
+ whites,
147
154
  appd_host,
148
155
  appd_port,
149
156
  head_len,
@@ -16,7 +16,7 @@ module Girl
16
16
  nameservers,
17
17
  im,
18
18
  directs,
19
- remotes,
19
+ whites,
20
20
  appd_host,
21
21
  appd_port,
22
22
  head_len,
@@ -49,7 +49,8 @@ module Girl
49
49
  @nameserver_addrs = nameservers.map{|n| Socket.sockaddr_in(53, n)}
50
50
  @im = im
51
51
  @directs = directs
52
- @remotes = remotes
52
+ @whites = whites
53
+ @unknowns = []
53
54
  @local_ips = Socket.ip_address_list.select{|info| info.ipv4?}.map{|info| info.ip_address}
54
55
  @update_roles = [:dns, :dst, :mem, :p1, :src, :rsv] # 参与淘汰的角色
55
56
  @updates_limit = 1008 # 淘汰池上限,1015(mac) - [info infod memd proxy redir rsvd tspd]
@@ -1211,9 +1212,11 @@ module Girl
1211
1212
  resolv_caches: @resolv_caches.sort,
1212
1213
  response_caches: @response_caches.sort.map{|a| [a[0], a[1][2], a[1][3]]},
1213
1214
  response6_caches: @response6_caches.sort.map{|a| [a[0], a[1][2], a[1][3]]},
1215
+ unknowns: @unknowns,
1214
1216
  sizes: {
1215
1217
  directs: @directs.size,
1216
- remotes: @remotes.size,
1218
+ whites: @whites.size,
1219
+ unknowns: @unknowns.size,
1217
1220
  reads: @reads.size,
1218
1221
  writes: @writes.size,
1219
1222
  roles: @roles.size,
@@ -1441,8 +1444,9 @@ module Girl
1441
1444
  end
1442
1445
  end
1443
1446
 
1444
- if @remotes.any?{|r| domain.include?(r)}
1447
+ if @whites.all?{|white| (domain.size < white.size) || (domain[(white.size * -1)..-1] != white)}
1445
1448
  if type == 1
1449
+ @unknowns << domain unless @unknowns.include?(domain)
1446
1450
  check_expire_nears
1447
1451
  near_id = rand((2 ** 64) - 2) + 1
1448
1452
  @near_infos[near_id] = {
@@ -1456,11 +1460,11 @@ module Girl
1456
1460
  msg = "#{@h_query}#{[near_id, type].pack('Q>C')}#{domain}"
1457
1461
  add_proxy_wbuff(pack_a_chunk(msg))
1458
1462
  end
1459
-
1460
- return
1463
+ else
1464
+ new_a_rsv(data, addrinfo, domain, type)
1461
1465
  end
1462
1466
 
1463
- new_a_rsv(data, addrinfo, domain, type)
1467
+
1464
1468
  end
1465
1469
 
1466
1470
  def read_src(src)
@@ -1723,7 +1727,8 @@ module Girl
1723
1727
  return
1724
1728
  end
1725
1729
 
1726
- if @remotes.any?{|remote| (domain.size >= remote.size) && (domain[(remote.size * -1)..-1] == remote)}
1730
+ if @whites.all?{|white| (domain.size < white.size) || (domain[(white.size * -1)..-1] != white)}
1731
+ @unknowns << domain unless @unknowns.include?(domain)
1727
1732
  set_remote(src)
1728
1733
  return
1729
1734
  end
data/lib/girl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Girl
2
- VERSION = '9.2.2'.freeze
2
+ VERSION = '9.2.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.2.2
4
+ version: 9.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - takafan