girl 9.2.1 → 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: f284c4b3e52a5727149b6770981eb2fd1e49728c4704e8a6d104f1dd98a3fe64
4
- data.tar.gz: 92a817464bc772630cb1313b51564aa46ae03c4baccaad8fa5cbcf6b7f7f910f
3
+ metadata.gz: f4ee7503a62e9790a615f594b369ce5170dad38f21e21c7918805b5376ae1e9b
4
+ data.tar.gz: b73cd2f06a84c49b0e620bb2f340073a2ed146cfbb78ef68cfa7cb69c67133f2
5
5
  SHA512:
6
- metadata.gz: c9df850fb2724b3e0b3c31646908f4b4f29217b47147f5cd080bbf8112ce7054a63f989ee7b0e92343ad1898aec964a56c361b2ff959f1f8d5413bb1ff34e19c
7
- data.tar.gz: c98ebd0b3624bcd6828c3cb538e4caf9d8fa7a0b7a030944c1f64a2e4805ee94a0ee2145d9be6c0826351579d7233508a607a510d116bf31f786974275497c44
6
+ metadata.gz: 5b98f165da508bec146215eb392ffb5124c495cb4b8e6b8019396f5924403f73ddcae47c97fa2e38927ce632553306347a4c728ae7d2d1231f3a35541e8d179c
7
+ data.tar.gz: 6f48f78bf0de89cfc3ccd96fe8045e10709ff16bff5757d8e74f9765fc0974a6e093a2079f0e202d6a0c8f0435debc0e13dc60b707607fc3a7960229d88400de
data/lib/girl/proxy.rb CHANGED
@@ -22,6 +22,8 @@ module Girl
22
22
  redir_host = conf[:redir_host]
23
23
  redir_port = conf[:redir_port]
24
24
  memd_port = conf[:memd_port]
25
+ rsvd_host = conf[:rsvd_host]
26
+ rsvd_port = conf[:rsvd_port]
25
27
  tspd_host = conf[:tspd_host]
26
28
  tspd_port = conf[:tspd_port]
27
29
  proxyd_host = conf[:proxyd_host]
@@ -30,7 +32,7 @@ module Girl
30
32
  nameserver = conf[:nameserver]
31
33
  im = conf[:im]
32
34
  direct_path = conf[:direct_path]
33
- remote_path = conf[:remote_path]
35
+ white_path = conf[:white_path]
34
36
  appd_host = conf[:appd_host]
35
37
  appd_port = conf[:appd_port]
36
38
  head_len = conf[:head_len] # 头长度
@@ -59,6 +61,8 @@ module Girl
59
61
  redir_host = redir_host ? redir_host.to_s : '0.0.0.0'
60
62
  redir_port = redir_port ? redir_port.to_i : 6666
61
63
  memd_port = memd_port ? memd_port.to_i : redir_port + 2
64
+ rsvd_host = rsvd_host ? rsvd_host.to_s : '0.0.0.0'
65
+ rsvd_port = rsvd_port ? rsvd_port.to_i : 53
62
66
  tspd_host = tspd_host ? tspd_host.to_s : '0.0.0.0'
63
67
  tspd_port = tspd_port ? tspd_port.to_i : 7777
64
68
  raise "missing proxyd host" unless proxyd_host
@@ -74,11 +78,18 @@ module Girl
74
78
  directs = (RESERVED_ROUTE.split("\n") + IO.binread(direct_path).split("\n")).map{|line| IPAddr.new(line.strip)}
75
79
  end
76
80
 
77
- remotes = []
81
+ whites = []
78
82
 
79
- if remote_path
80
- raise "not found remote file #{remote_path}" unless File.exist?(remote_path)
81
- 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
82
93
  end
83
94
 
84
95
  appd_host = appd_host ? appd_host.to_s : '127.0.0.1'
@@ -118,7 +129,7 @@ module Girl
118
129
  puts "girl proxy #{Girl::VERSION} #{im} #{redir_port} #{tspd_port}"
119
130
  puts "#{proxyd_host} #{proxyd_port} #{appd_host} #{appd_port} #{nameservers.inspect} #{is_client_fastopen} #{is_server_fastopen}"
120
131
  puts "#{direct_path} #{directs.size} directs"
121
- puts "#{remote_path} #{remotes.size} remotes"
132
+ puts "#{white_path} #{whites.size} whites"
122
133
 
123
134
  if %w[darwin linux].any?{|plat| RUBY_PLATFORM.include?(plat)}
124
135
  Process.setrlimit(:NOFILE, RLIMIT)
@@ -129,6 +140,8 @@ module Girl
129
140
  redir_host,
130
141
  redir_port,
131
142
  memd_port,
143
+ rsvd_host,
144
+ rsvd_port,
132
145
  tspd_host,
133
146
  tspd_port,
134
147
  proxyd_host,
@@ -137,7 +150,7 @@ module Girl
137
150
  nameservers,
138
151
  im,
139
152
  directs,
140
- remotes,
153
+ whites,
141
154
  appd_host,
142
155
  appd_port,
143
156
  head_len,
@@ -6,6 +6,8 @@ module Girl
6
6
  redir_host,
7
7
  redir_port,
8
8
  memd_port,
9
+ rsvd_host,
10
+ rsvd_port,
9
11
  tspd_host,
10
12
  tspd_port,
11
13
  proxyd_host,
@@ -14,7 +16,7 @@ module Girl
14
16
  nameservers,
15
17
  im,
16
18
  directs,
17
- remotes,
19
+ whites,
18
20
  appd_host,
19
21
  appd_port,
20
22
  head_len,
@@ -47,7 +49,8 @@ module Girl
47
49
  @nameserver_addrs = nameservers.map{|n| Socket.sockaddr_in(53, n)}
48
50
  @im = im
49
51
  @directs = directs
50
- @remotes = remotes
52
+ @whites = whites
53
+ @unknowns = []
51
54
  @local_ips = Socket.ip_address_list.select{|info| info.ipv4?}.map{|info| info.ip_address}
52
55
  @update_roles = [:dns, :dst, :mem, :p1, :src, :rsv] # 参与淘汰的角色
53
56
  @updates_limit = 1008 # 淘汰池上限,1015(mac) - [info infod memd proxy redir rsvd tspd]
@@ -97,7 +100,7 @@ module Girl
97
100
  new_a_redir(redir_host, redir_port)
98
101
  new_a_infod(redir_port)
99
102
  new_a_memd(memd_port)
100
- new_a_rsvd(tspd_host, tspd_port)
103
+ new_a_rsvd(rsvd_host, rsvd_port)
101
104
  new_a_tspd(tspd_host, tspd_port)
102
105
  new_a_proxy
103
106
  new_a_big
@@ -1209,9 +1212,11 @@ module Girl
1209
1212
  resolv_caches: @resolv_caches.sort,
1210
1213
  response_caches: @response_caches.sort.map{|a| [a[0], a[1][2], a[1][3]]},
1211
1214
  response6_caches: @response6_caches.sort.map{|a| [a[0], a[1][2], a[1][3]]},
1215
+ unknowns: @unknowns,
1212
1216
  sizes: {
1213
1217
  directs: @directs.size,
1214
- remotes: @remotes.size,
1218
+ whites: @whites.size,
1219
+ unknowns: @unknowns.size,
1215
1220
  reads: @reads.size,
1216
1221
  writes: @writes.size,
1217
1222
  roles: @roles.size,
@@ -1439,8 +1444,9 @@ module Girl
1439
1444
  end
1440
1445
  end
1441
1446
 
1442
- if @remotes.any?{|r| domain.include?(r)}
1447
+ if @whites.all?{|white| (domain.size < white.size) || (domain[(white.size * -1)..-1] != white)}
1443
1448
  if type == 1
1449
+ @unknowns << domain unless @unknowns.include?(domain)
1444
1450
  check_expire_nears
1445
1451
  near_id = rand((2 ** 64) - 2) + 1
1446
1452
  @near_infos[near_id] = {
@@ -1454,11 +1460,11 @@ module Girl
1454
1460
  msg = "#{@h_query}#{[near_id, type].pack('Q>C')}#{domain}"
1455
1461
  add_proxy_wbuff(pack_a_chunk(msg))
1456
1462
  end
1457
-
1458
- return
1463
+ else
1464
+ new_a_rsv(data, addrinfo, domain, type)
1459
1465
  end
1460
1466
 
1461
- new_a_rsv(data, addrinfo, domain, type)
1467
+
1462
1468
  end
1463
1469
 
1464
1470
  def read_src(src)
@@ -1721,7 +1727,8 @@ module Girl
1721
1727
  return
1722
1728
  end
1723
1729
 
1724
- 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)
1725
1732
  set_remote(src)
1726
1733
  return
1727
1734
  end
data/lib/girl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Girl
2
- VERSION = '9.2.1'.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.1
4
+ version: 9.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - takafan