girl 9.1.8 → 9.1.9
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/girl.gemspec +1 -0
- data/lib/girl/proxy.rb +1 -1
- data/lib/girl/proxy_worker.rb +3 -4
- data/lib/girl/proxyd.rb +3 -0
- data/lib/girl/proxyd_worker.rb +16 -12
- data/lib/girl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8903a1ddd8c490bd520c6684412c5e3c9346d6a2b2b78717c33e68c9e4bf25cd
|
|
4
|
+
data.tar.gz: 92af066c0dd66a32a2cf762a7cbb0107712d22055b5bab04df500ada06b89c13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de9cd1b645c64497a7c07774fec41cfc8082b6950aab8501cfabaa92847bab097ba7e4ac999efac499c72072c0db87e6efbf94ad301c0a5d6db6c60c0bf6f16c
|
|
7
|
+
data.tar.gz: 994c9a97eeee729ab09167d61bfaf5f4215437173547e8cca4ff71bde88b7957b0ad728fb16ae406c09fafa781ca9d2246ac70fa83db1d89fcbac83b2169fee6
|
data/girl.gemspec
CHANGED
data/lib/girl/proxy.rb
CHANGED
|
@@ -51,7 +51,7 @@ module Girl
|
|
|
51
51
|
h_p1_switch_to_big = conf[:h_p1_switch_to_big] # X
|
|
52
52
|
expire_connecting = conf[:expire_connecting] # 连接多久没有建成关闭(秒)
|
|
53
53
|
expire_long_after = conf[:expire_long_after] # 长连接多久没有新流量关闭(秒)
|
|
54
|
-
expire_proxy_after = conf[:expire_proxy_after] # proxy
|
|
54
|
+
expire_proxy_after = conf[:expire_proxy_after] # proxy多久没有收到流量关闭(秒)
|
|
55
55
|
expire_resolv_cache = conf[:expire_resolv_cache] # dns查询结果缓存多久(秒)
|
|
56
56
|
expire_short_after = conf[:expire_short_after] # 短连接创建多久后关闭(秒)
|
|
57
57
|
is_debug = conf[:is_debug]
|
data/lib/girl/proxy_worker.rb
CHANGED
|
@@ -582,7 +582,6 @@ module Girl
|
|
|
582
582
|
return if data.bytesize < 9
|
|
583
583
|
p2_id = data[1, 8].unpack('Q>').first
|
|
584
584
|
data = data[9..-1]
|
|
585
|
-
# puts "big got h_p2_traffic #{p2_id} #{data.bytesize}" if @is_debug
|
|
586
585
|
p1, p1_info = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
587
586
|
|
|
588
587
|
if p1_info
|
|
@@ -596,7 +595,6 @@ module Girl
|
|
|
596
595
|
return if data.bytesize < 9
|
|
597
596
|
src_id = data[1, 8].unpack('Q>').first
|
|
598
597
|
data = data[9..-1]
|
|
599
|
-
# puts "big got h_traffic #{src_id} #{data.bytesize}" if @is_debug
|
|
600
598
|
src, src_info = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
601
599
|
|
|
602
600
|
if src_info
|
|
@@ -1163,9 +1161,10 @@ module Girl
|
|
|
1163
1161
|
when 'heartbeat'
|
|
1164
1162
|
new_a_proxy if @proxy.closed?
|
|
1165
1163
|
new_a_big if @big.closed?
|
|
1164
|
+
now = Time.new
|
|
1166
1165
|
proxy_info = @proxy_infos[@proxy]
|
|
1167
1166
|
|
|
1168
|
-
if
|
|
1167
|
+
if now.to_i - proxy_info[:recv_at].to_i >= @expire_proxy_after
|
|
1169
1168
|
puts "renew proxy"
|
|
1170
1169
|
close_proxy(@proxy)
|
|
1171
1170
|
new_a_proxy
|
|
@@ -1175,7 +1174,7 @@ module Girl
|
|
|
1175
1174
|
|
|
1176
1175
|
big_info = @big_infos[@big]
|
|
1177
1176
|
|
|
1178
|
-
if
|
|
1177
|
+
if now.to_i - big_info[:recv_at].to_i >= @expire_proxy_after
|
|
1179
1178
|
puts "renew big"
|
|
1180
1179
|
close_big(@big)
|
|
1181
1180
|
new_a_big
|
data/lib/girl/proxyd.rb
CHANGED
|
@@ -42,6 +42,7 @@ module Girl
|
|
|
42
42
|
h_p1_switch_to_big = conf[:h_p1_switch_to_big] # X
|
|
43
43
|
expire_connecting = conf[:expire_connecting] # 连接多久没有建成关闭(秒)
|
|
44
44
|
expire_long_after = conf[:expire_long_after] # 长连接多久没有新流量关闭(秒)
|
|
45
|
+
expire_proxy_after = conf[:expire_proxy_after] # proxy多久没有收到流量关闭(秒)
|
|
45
46
|
expire_resolv_cache = conf[:expire_resolv_cache] # dns查询结果缓存多久(秒)
|
|
46
47
|
expire_short_after = conf[:expire_short_after] # 短连接创建多久后关闭(秒)
|
|
47
48
|
is_debug = conf[:is_debug]
|
|
@@ -94,6 +95,7 @@ module Girl
|
|
|
94
95
|
h_p1_switch_to_big = h_p1_switch_to_big ? h_p1_switch_to_big.to_s : 'X'
|
|
95
96
|
expire_connecting = expire_connecting ? expire_connecting.to_i : 5
|
|
96
97
|
expire_long_after = expire_long_after ? expire_long_after.to_i : 3600
|
|
98
|
+
expire_proxy_after = expire_proxy_after ? expire_proxy_after.to_i : 60
|
|
97
99
|
expire_resolv_cache = expire_resolv_cache ? expire_resolv_cache.to_i : 600
|
|
98
100
|
expire_short_after = expire_short_after ? expire_short_after.to_i : 5
|
|
99
101
|
is_server_fastopen = false
|
|
@@ -141,6 +143,7 @@ module Girl
|
|
|
141
143
|
h_p1_switch_to_big,
|
|
142
144
|
expire_connecting,
|
|
143
145
|
expire_long_after,
|
|
146
|
+
expire_proxy_after,
|
|
144
147
|
expire_resolv_cache,
|
|
145
148
|
expire_short_after,
|
|
146
149
|
is_debug,
|
data/lib/girl/proxyd_worker.rb
CHANGED
|
@@ -29,6 +29,7 @@ module Girl
|
|
|
29
29
|
h_p1_switch_to_big,
|
|
30
30
|
expire_connecting,
|
|
31
31
|
expire_long_after,
|
|
32
|
+
expire_proxy_after,
|
|
32
33
|
expire_resolv_cache,
|
|
33
34
|
expire_short_after,
|
|
34
35
|
is_debug,
|
|
@@ -42,8 +43,8 @@ module Girl
|
|
|
42
43
|
@writes = [] # 写池
|
|
43
44
|
@roles = {} # sock => :big / :bigd / :dns / :dst / :infod / :mem / :memd / :p2 / :p2d / :proxy / :proxyd / :rsv
|
|
44
45
|
@updates = {} # sock => updated_at
|
|
45
|
-
@proxy_infos = {} # proxy => {:addrinfo :im :rbuff :wbuff}
|
|
46
|
-
@big_infos = {} # big => {:addrinfo :im :overflowing :rbuff :wbuff}
|
|
46
|
+
@proxy_infos = {} # proxy => {:addrinfo :im :rbuff :recv_at :wbuff}
|
|
47
|
+
@big_infos = {} # big => {:addrinfo :im :overflowing :rbuff :recv_at :wbuff}
|
|
47
48
|
@im_infos = {} # im => {:addrinfo :big :big_connect_at :in :out :p2d :p2d_host :p2d_port :proxy :proxy_connect_at}
|
|
48
49
|
@src_infos = {} # src_id => {:created_at :dst :im :rbuff}
|
|
49
50
|
@mem_infos = {} # mem => {:wbuff}
|
|
@@ -71,6 +72,7 @@ module Girl
|
|
|
71
72
|
@h_p1_switch_to_big = h_p1_switch_to_big
|
|
72
73
|
@expire_connecting = expire_connecting
|
|
73
74
|
@expire_long_after = expire_long_after
|
|
75
|
+
@expire_proxy_after = expire_proxy_after
|
|
74
76
|
@expire_resolv_cache = expire_resolv_cache
|
|
75
77
|
@expire_short_after = expire_short_after
|
|
76
78
|
@is_debug = is_debug
|
|
@@ -349,8 +351,8 @@ module Girl
|
|
|
349
351
|
def check_expire_bigs
|
|
350
352
|
now = Time.new
|
|
351
353
|
|
|
352
|
-
@big_infos.select{|big,
|
|
353
|
-
puts "expire big #{info[:im]}"
|
|
354
|
+
@big_infos.select{|big, info| now.to_i - info[:recv_at].to_i >= @expire_proxy_after}.each do |big, info|
|
|
355
|
+
puts "expire big #{info[:im]} #{info[:addrinfo].ip_unpack.inspect}"
|
|
354
356
|
close_big(big)
|
|
355
357
|
end
|
|
356
358
|
end
|
|
@@ -394,8 +396,8 @@ module Girl
|
|
|
394
396
|
def check_expire_proxies
|
|
395
397
|
now = Time.new
|
|
396
398
|
|
|
397
|
-
@proxy_infos.select{|proxy,
|
|
398
|
-
puts "expire proxy #{info[:im]}"
|
|
399
|
+
@proxy_infos.select{|proxy, info| now.to_i - info[:recv_at].to_i >= @expire_proxy_after}.each do |proxy, info|
|
|
400
|
+
puts "expire proxy #{info[:im]} #{info[:addrinfo].ip_unpack.inspect}"
|
|
399
401
|
close_proxy(proxy)
|
|
400
402
|
end
|
|
401
403
|
end
|
|
@@ -540,6 +542,8 @@ module Girl
|
|
|
540
542
|
big_info = @big_infos[big]
|
|
541
543
|
im = big_info[:im]
|
|
542
544
|
return unless im
|
|
545
|
+
now = Time.new
|
|
546
|
+
big_info[:recv_at] = now
|
|
543
547
|
h = data[0]
|
|
544
548
|
|
|
545
549
|
case h
|
|
@@ -547,7 +551,6 @@ module Girl
|
|
|
547
551
|
return if data.bytesize < 9
|
|
548
552
|
p2_id = data[1, 8].unpack('Q>').first
|
|
549
553
|
data = data[9..-1]
|
|
550
|
-
# puts "big got h_p2_traffic #{im} #{p2_id} #{data.bytesize}" if @is_debug
|
|
551
554
|
p2, p2_info = @p2_infos.find{|_, info| (info[:im] == im) && (info[:p2_id] == p2_id)}
|
|
552
555
|
|
|
553
556
|
if p2_info
|
|
@@ -561,7 +564,6 @@ module Girl
|
|
|
561
564
|
return if data.bytesize < 9
|
|
562
565
|
src_id = data[1, 8].unpack('Q>').first
|
|
563
566
|
data = data[9..-1]
|
|
564
|
-
# puts "big got h_traffic #{im} #{src_id} #{data.bytesize}" if @is_debug
|
|
565
567
|
src_info = @src_infos[src_id]
|
|
566
568
|
|
|
567
569
|
if src_info
|
|
@@ -587,6 +589,8 @@ module Girl
|
|
|
587
589
|
proxy_info = @proxy_infos[proxy]
|
|
588
590
|
im = proxy_info[:im]
|
|
589
591
|
return unless im
|
|
592
|
+
now = Time.new
|
|
593
|
+
proxy_info[:recv_at] = now
|
|
590
594
|
h = data[0]
|
|
591
595
|
|
|
592
596
|
case h
|
|
@@ -597,7 +601,7 @@ module Girl
|
|
|
597
601
|
domain_port = data[9..-1]
|
|
598
602
|
puts "got h_a_new_source #{im} #{src_id} #{domain_port.inspect}" if @is_debug
|
|
599
603
|
@src_infos[src_id] = {
|
|
600
|
-
created_at:
|
|
604
|
+
created_at: now,
|
|
601
605
|
dst: nil,
|
|
602
606
|
im: im,
|
|
603
607
|
rbuff: ''
|
|
@@ -1025,15 +1029,14 @@ module Girl
|
|
|
1025
1029
|
|
|
1026
1030
|
puts "accept a big #{addrinfo.ip_unpack.inspect}"
|
|
1027
1031
|
|
|
1028
|
-
|
|
1032
|
+
@big_infos[big] = {
|
|
1029
1033
|
addrinfo: addrinfo,
|
|
1030
1034
|
im: nil,
|
|
1031
1035
|
overflowing: false,
|
|
1032
1036
|
rbuff: '',
|
|
1037
|
+
recv_at: Time.new,
|
|
1033
1038
|
wbuff: ''
|
|
1034
1039
|
}
|
|
1035
|
-
|
|
1036
|
-
@big_infos[big] = big_info
|
|
1037
1040
|
add_read(big, :big)
|
|
1038
1041
|
end
|
|
1039
1042
|
|
|
@@ -1447,6 +1450,7 @@ module Girl
|
|
|
1447
1450
|
addrinfo: addrinfo,
|
|
1448
1451
|
im: nil,
|
|
1449
1452
|
rbuff: '',
|
|
1453
|
+
recv_at: Time.new,
|
|
1450
1454
|
wbuff: ''
|
|
1451
1455
|
}
|
|
1452
1456
|
add_read(proxy, :proxy)
|
data/lib/girl/version.rb
CHANGED
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.1.
|
|
4
|
+
version: 9.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- takafan
|
|
@@ -36,7 +36,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
39
|
+
version: 1.6.7
|
|
40
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
requirements:
|
|
42
42
|
- - ">="
|