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 +4 -4
- data/lib/girl/proxy.rb +20 -7
- data/lib/girl/proxy_worker.rb +16 -9
- data/lib/girl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4ee7503a62e9790a615f594b369ce5170dad38f21e21c7918805b5376ae1e9b
|
|
4
|
+
data.tar.gz: b73cd2f06a84c49b0e620bb2f340073a2ed146cfbb78ef68cfa7cb69c67133f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
81
|
+
whites = []
|
|
78
82
|
|
|
79
|
-
if
|
|
80
|
-
raise "not found
|
|
81
|
-
|
|
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 "#{
|
|
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
|
-
|
|
153
|
+
whites,
|
|
141
154
|
appd_host,
|
|
142
155
|
appd_port,
|
|
143
156
|
head_len,
|
data/lib/girl/proxy_worker.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
@
|
|
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(
|
|
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
|
-
|
|
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 @
|
|
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
|
-
|
|
1463
|
+
else
|
|
1464
|
+
new_a_rsv(data, addrinfo, domain, type)
|
|
1459
1465
|
end
|
|
1460
1466
|
|
|
1461
|
-
|
|
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 @
|
|
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