girl 9.1.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fb6e8b23d6592879331b008463de29fd523fa803ec64de30b276c21b6363c6e
4
- data.tar.gz: ad47b37c7378b2ac44be6b1f2d6fcea90eed1367b2f17d878e60fad943abe82b
3
+ metadata.gz: 8903a1ddd8c490bd520c6684412c5e3c9346d6a2b2b78717c33e68c9e4bf25cd
4
+ data.tar.gz: 92af066c0dd66a32a2cf762a7cbb0107712d22055b5bab04df500ada06b89c13
5
5
  SHA512:
6
- metadata.gz: b9167e14d9e01219abe7ea2005bc340d75cb22427d6b31d37de53a78b1be6af52e65fbd8282e45d55a54abe8f2f8239fbe5d66fe203191e2362c6e538f3be4e7
7
- data.tar.gz: a9f9c2298974bd7dd84d30d591aa0d76be07249f6c89135b409f1ba256ab36566c4ee46cef6294bcad8af65487ecec7df6aa2a09afa367bfd41b223e63526fc5
6
+ metadata.gz: de9cd1b645c64497a7c07774fec41cfc8082b6950aab8501cfabaa92847bab097ba7e4ac999efac499c72072c0db87e6efbf94ad301c0a5d6db6c60c0bf6f16c
7
+ data.tar.gz: 994c9a97eeee729ab09167d61bfaf5f4215437173547e8cca4ff71bde88b7957b0ad728fb16ae406c09fafa781ca9d2246ac70fa83db1d89fcbac83b2169fee6
data/girl.gemspec CHANGED
@@ -27,4 +27,5 @@ lib/girl/version.rb
27
27
  ]
28
28
 
29
29
  spec.require_paths = ['lib']
30
+ spec.required_ruby_version = '>= 1.6.7'
30
31
  end
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]
@@ -265,6 +265,7 @@ module Girl
265
265
  if bytesize >= CLOSE_ABOVE
266
266
  puts "p1 wpend full"
267
267
  close_p1(p1)
268
+ return
268
269
  end
269
270
 
270
271
  if !p1_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
@@ -371,6 +372,7 @@ module Girl
371
372
  if bytesize >= CLOSE_ABOVE
372
373
  puts "src wpend full"
373
374
  close_src(src)
375
+ return
374
376
  end
375
377
 
376
378
  if !src_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
@@ -580,7 +582,6 @@ module Girl
580
582
  return if data.bytesize < 9
581
583
  p2_id = data[1, 8].unpack('Q>').first
582
584
  data = data[9..-1]
583
- # puts "big got h_p2_traffic #{p2_id} #{data.bytesize}" if @is_debug
584
585
  p1, p1_info = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
585
586
 
586
587
  if p1_info
@@ -594,7 +595,6 @@ module Girl
594
595
  return if data.bytesize < 9
595
596
  src_id = data[1, 8].unpack('Q>').first
596
597
  data = data[9..-1]
597
- # puts "big got h_traffic #{src_id} #{data.bytesize}" if @is_debug
598
598
  src, src_info = @src_infos.find{|_, info| info[:src_id] == src_id}
599
599
 
600
600
  if src_info
@@ -1161,9 +1161,10 @@ module Girl
1161
1161
  when 'heartbeat'
1162
1162
  new_a_proxy if @proxy.closed?
1163
1163
  new_a_big if @big.closed?
1164
+ now = Time.new
1164
1165
  proxy_info = @proxy_infos[@proxy]
1165
1166
 
1166
- if Time.new.to_i - proxy_info[:recv_at].to_i >= @expire_proxy_after
1167
+ if now.to_i - proxy_info[:recv_at].to_i >= @expire_proxy_after
1167
1168
  puts "renew proxy"
1168
1169
  close_proxy(@proxy)
1169
1170
  new_a_proxy
@@ -1173,7 +1174,7 @@ module Girl
1173
1174
 
1174
1175
  big_info = @big_infos[@big]
1175
1176
 
1176
- if Time.new.to_i - big_info[:recv_at].to_i >= @expire_proxy_after
1177
+ if now.to_i - big_info[:recv_at].to_i >= @expire_proxy_after
1177
1178
  puts "renew big"
1178
1179
  close_big(@big)
1179
1180
  new_a_big
@@ -1871,8 +1872,6 @@ module Girl
1871
1872
  @writes.delete(big)
1872
1873
  return
1873
1874
  end
1874
-
1875
- return if @writes.include?(@proxy)
1876
1875
 
1877
1876
  data = big_info[:wbuff]
1878
1877
 
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,
@@ -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, _| now.to_i - @updates[big].to_i >= @expire_long_after}.each do |big, info|
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, _| now.to_i - @updates[proxy].to_i >= @expire_long_after}.each do |proxy, info|
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: Time.new,
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
- big_info = {
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)
@@ -1590,7 +1594,6 @@ module Girl
1590
1594
  return
1591
1595
  end
1592
1596
 
1593
- return if @writes.include?(im_info[:proxy])
1594
1597
  data = big_info[:wbuff]
1595
1598
 
1596
1599
  if data.empty?
data/lib/girl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Girl
2
- VERSION = '9.1.7'.freeze
2
+ VERSION = '9.1.9'.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.1.7
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: '0'
39
+ version: 1.6.7
40
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ">="