girl 9.1.6 → 9.1.8
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/head.rb +2 -2
- data/lib/girl/proxy.rb +24 -12
- data/lib/girl/proxy_worker.rb +149 -30
- data/lib/girl/proxyd.rb +24 -12
- data/lib/girl/proxyd_worker.rb +191 -56
- 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: a2c6dd87559c942761c2b8c9ffc27801755af55ea4348d215e244a22eb322e73
|
|
4
|
+
data.tar.gz: 9d9600b04852239dc01e39ea078eb75353dc8734032ea96c00e56e14f84dfc85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54c9c01fef8adbb375aeba548473b117c1867cb515db9cd9672a959e3822589a122f27807b0523adf206b61b826f61df7c85e693cdbab757917b9fd56540826e
|
|
7
|
+
data.tar.gz: 3ff6355c411f60822c5c6d2a281b164c4d8a623af2de0f0003a84e5e215dada347b7637c7c1bd6867a2dd3f6011f692d0ae609d3a2070a429f5d61d661c92c59
|
data/lib/girl/head.rb
CHANGED
|
@@ -2,8 +2,8 @@ module Girl
|
|
|
2
2
|
BACKLOG = 512 # 听队列大小,满后掉SYN包
|
|
3
3
|
RLIMIT = 1024 # sock数上限
|
|
4
4
|
READ_SIZE = 1 * 1024 * 1024 # 一次最多读多少
|
|
5
|
-
WBUFF_LIMIT =
|
|
6
|
-
CLOSE_ABOVE =
|
|
5
|
+
WBUFF_LIMIT = 20 * 1024 * 1024 # 写前上限,超过上限暂停读另一头
|
|
6
|
+
CLOSE_ABOVE = 200 * 1024 * 1024 # 超过多少强制关闭
|
|
7
7
|
HEARTBEAT_INTERVAL = 10 # 心跳间隔
|
|
8
8
|
CHECK_TRAFF_INTERVAL = 3600 # 多久检查一次,今天是不是流量计数重置日
|
|
9
9
|
HTTP_OK = "HTTP/1.1 200 OK\r\n\r\n"
|
data/lib/girl/proxy.rb
CHANGED
|
@@ -33,18 +33,22 @@ module Girl
|
|
|
33
33
|
remote_path = conf[:remote_path]
|
|
34
34
|
appd_host = conf[:appd_host]
|
|
35
35
|
appd_port = conf[:appd_port]
|
|
36
|
-
head_len = conf[:head_len]
|
|
37
|
-
h_a_new_source = conf[:h_a_new_source]
|
|
38
|
-
h_a_new_p2 = conf[:h_a_new_p2]
|
|
39
|
-
h_dst_close = conf[:h_dst_close]
|
|
40
|
-
h_heartbeat = conf[:h_heartbeat]
|
|
41
|
-
h_p1_close = conf[:h_p1_close]
|
|
42
|
-
h_p2_close = conf[:h_p2_close]
|
|
43
|
-
h_p2_traffic = conf[:h_p2_traffic]
|
|
44
|
-
h_query = conf[:h_query]
|
|
45
|
-
h_response = conf[:h_response]
|
|
46
|
-
h_src_close = conf[:h_src_close]
|
|
47
|
-
h_traffic = conf[:h_traffic]
|
|
36
|
+
head_len = conf[:head_len] # 头长度
|
|
37
|
+
h_a_new_source = conf[:h_a_new_source] # A
|
|
38
|
+
h_a_new_p2 = conf[:h_a_new_p2] # B
|
|
39
|
+
h_dst_close = conf[:h_dst_close] # D
|
|
40
|
+
h_heartbeat = conf[:h_heartbeat] # H
|
|
41
|
+
h_p1_close = conf[:h_p1_close] # I
|
|
42
|
+
h_p2_close = conf[:h_p2_close] # J
|
|
43
|
+
h_p2_traffic = conf[:h_p2_traffic] # K
|
|
44
|
+
h_query = conf[:h_query] # Q
|
|
45
|
+
h_response = conf[:h_response] # R
|
|
46
|
+
h_src_close = conf[:h_src_close] # S
|
|
47
|
+
h_traffic = conf[:h_traffic] # T
|
|
48
|
+
h_dst_switch_to_big = conf[:h_dst_switch_to_big] # U
|
|
49
|
+
h_p2_switch_to_big = conf[:h_p2_switch_to_big] # V
|
|
50
|
+
h_src_switch_to_big = conf[:h_src_switch_to_big] # W
|
|
51
|
+
h_p1_switch_to_big = conf[:h_p1_switch_to_big] # X
|
|
48
52
|
expire_connecting = conf[:expire_connecting] # 连接多久没有建成关闭(秒)
|
|
49
53
|
expire_long_after = conf[:expire_long_after] # 长连接多久没有新流量关闭(秒)
|
|
50
54
|
expire_proxy_after = conf[:expire_proxy_after] # proxy多久没有收到流量重建(秒)
|
|
@@ -91,6 +95,10 @@ module Girl
|
|
|
91
95
|
h_response = h_response ? h_response.to_s : 'R'
|
|
92
96
|
h_src_close = h_src_close ? h_src_close.to_s : 'S'
|
|
93
97
|
h_traffic = h_traffic ? h_traffic.to_s : 'T'
|
|
98
|
+
h_dst_switch_to_big = h_dst_switch_to_big ? h_dst_switch_to_big.to_s : 'U'
|
|
99
|
+
h_p2_switch_to_big = h_p2_switch_to_big ? h_p2_switch_to_big.to_s : 'V'
|
|
100
|
+
h_src_switch_to_big = h_src_switch_to_big ? h_src_switch_to_big.to_s : 'W'
|
|
101
|
+
h_p1_switch_to_big = h_p1_switch_to_big ? h_p1_switch_to_big.to_s : 'X'
|
|
94
102
|
expire_connecting = expire_connecting ? expire_connecting.to_i : 5
|
|
95
103
|
expire_long_after = expire_long_after ? expire_long_after.to_i : 3600
|
|
96
104
|
expire_proxy_after = expire_proxy_after ? expire_proxy_after.to_i : 60
|
|
@@ -144,6 +152,10 @@ module Girl
|
|
|
144
152
|
h_response,
|
|
145
153
|
h_src_close,
|
|
146
154
|
h_traffic,
|
|
155
|
+
h_dst_switch_to_big,
|
|
156
|
+
h_p2_switch_to_big,
|
|
157
|
+
h_src_switch_to_big,
|
|
158
|
+
h_p1_switch_to_big,
|
|
147
159
|
expire_connecting,
|
|
148
160
|
expire_long_after,
|
|
149
161
|
expire_proxy_after,
|
data/lib/girl/proxy_worker.rb
CHANGED
|
@@ -29,6 +29,10 @@ module Girl
|
|
|
29
29
|
h_response,
|
|
30
30
|
h_src_close,
|
|
31
31
|
h_traffic,
|
|
32
|
+
h_dst_switch_to_big,
|
|
33
|
+
h_p2_switch_to_big,
|
|
34
|
+
h_src_switch_to_big,
|
|
35
|
+
h_p1_switch_to_big,
|
|
32
36
|
expire_connecting,
|
|
33
37
|
expire_long_after,
|
|
34
38
|
expire_proxy_after,
|
|
@@ -55,7 +59,7 @@ module Girl
|
|
|
55
59
|
@proxy_infos = {} # proxy => {:is_syn :rbuff :recv_at :wbuff}
|
|
56
60
|
@big_infos = {} # big => {:is_syn :overflowing :rbuff :recv_at :wbuff}
|
|
57
61
|
@mem_infos = {} # mem => {:wbuff}
|
|
58
|
-
@src_infos = {} # src => {:addrinfo :closing :destination_domain :destination_port :dst :in :is_big :is_connect :overflowing :proxy_proto :proxy_type :rbuff :src_id :wbuff}
|
|
62
|
+
@src_infos = {} # src => {:addrinfo :closing :destination_domain :destination_port :dst :in :is_big :is_connect :overflowing :proxy_proto :proxy_type :rbuff :src_id :switched :wbuff :wpend}
|
|
59
63
|
@dst_infos = {} # dst => {:closing :connected :domain :ip :overflowing :port :src :wbuff}
|
|
60
64
|
@dns_infos = {} # dns => {:domain :src}
|
|
61
65
|
@rsv_infos = {} # rsv => {:addrinfo :domain :type}
|
|
@@ -64,7 +68,7 @@ module Girl
|
|
|
64
68
|
@is_direct_caches = {} # ip => true / false
|
|
65
69
|
@response_caches = {} # domain => [response created_at ip is_remote]
|
|
66
70
|
@response6_caches = {} # domain => [response created_at ip is_remote]
|
|
67
|
-
@p1_infos = {} # p1 => {:closing :connected :in :is_big :overflowing :p2_id :wbuff}
|
|
71
|
+
@p1_infos = {} # p1 => {:closing :connected :in :is_big :overflowing :p2_id :switched :wbuff :wpend}
|
|
68
72
|
@appd_addr = Socket.sockaddr_in(appd_port, appd_host)
|
|
69
73
|
@head_len = head_len
|
|
70
74
|
@h_a_new_source = h_a_new_source
|
|
@@ -78,6 +82,10 @@ module Girl
|
|
|
78
82
|
@h_response = h_response
|
|
79
83
|
@h_src_close = h_src_close
|
|
80
84
|
@h_traffic = h_traffic
|
|
85
|
+
@h_dst_switch_to_big = h_dst_switch_to_big
|
|
86
|
+
@h_p2_switch_to_big = h_p2_switch_to_big
|
|
87
|
+
@h_src_switch_to_big = h_src_switch_to_big
|
|
88
|
+
@h_p1_switch_to_big = h_p1_switch_to_big
|
|
81
89
|
@expire_connecting = expire_connecting
|
|
82
90
|
@expire_long_after = expire_long_after
|
|
83
91
|
@expire_proxy_after = expire_proxy_after
|
|
@@ -246,6 +254,31 @@ module Girl
|
|
|
246
254
|
add_write(p1)
|
|
247
255
|
end
|
|
248
256
|
|
|
257
|
+
def add_p1_wpend(p1, data)
|
|
258
|
+
return if p1.nil? || p1.closed? || data.nil? || data.empty?
|
|
259
|
+
p1_info = @p1_infos[p1]
|
|
260
|
+
puts "add p1 wpend #{data.bytesize}" if @is_debug
|
|
261
|
+
p1_info[:wpend] << data
|
|
262
|
+
bytesize = p1_info[:wpend].bytesize
|
|
263
|
+
p2_id = p1_info[:p2_id]
|
|
264
|
+
|
|
265
|
+
if bytesize >= CLOSE_ABOVE
|
|
266
|
+
puts "p1 wpend full"
|
|
267
|
+
close_p1(p1)
|
|
268
|
+
return
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
if !p1_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
272
|
+
puts "p1 overflow #{p2_id}"
|
|
273
|
+
p1_info[:overflowing] = true
|
|
274
|
+
|
|
275
|
+
if @big
|
|
276
|
+
puts 'pause big'
|
|
277
|
+
@reads.delete(@big)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
249
282
|
def add_proxy_wbuff(data)
|
|
250
283
|
return if @proxy.closed? || data.nil? || data.empty?
|
|
251
284
|
proxy_info = @proxy_infos[@proxy]
|
|
@@ -291,7 +324,7 @@ module Girl
|
|
|
291
324
|
puts "add src rbuff #{data.bytesize}" if @is_debug
|
|
292
325
|
src_info[:rbuff] << data
|
|
293
326
|
|
|
294
|
-
if src_info[:rbuff].bytesize >=
|
|
327
|
+
if src_info[:rbuff].bytesize >= CLOSE_ABOVE
|
|
295
328
|
puts "src rbuff full"
|
|
296
329
|
close_src(src)
|
|
297
330
|
end
|
|
@@ -327,6 +360,35 @@ module Girl
|
|
|
327
360
|
add_write(src)
|
|
328
361
|
end
|
|
329
362
|
|
|
363
|
+
def add_src_wpend(src, data)
|
|
364
|
+
return if src.nil? || src.closed? || data.nil? || data.empty?
|
|
365
|
+
src_info = @src_infos[src]
|
|
366
|
+
puts "add src wpend #{data.bytesize}" if @is_debug
|
|
367
|
+
src_info[:wpend] << data
|
|
368
|
+
bytesize = src_info[:wpend].bytesize
|
|
369
|
+
src_id = src_info[:src_id]
|
|
370
|
+
domain = src_info[:destination_domain]
|
|
371
|
+
|
|
372
|
+
if bytesize >= CLOSE_ABOVE
|
|
373
|
+
puts "src wpend full"
|
|
374
|
+
close_src(src)
|
|
375
|
+
return
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
if !src_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
379
|
+
puts "src overflow #{src_id} #{domain}"
|
|
380
|
+
src_info[:overflowing] = true
|
|
381
|
+
|
|
382
|
+
if src_info[:proxy_type] == :direct
|
|
383
|
+
puts "pause dst"
|
|
384
|
+
@reads.delete(src_info[:dst])
|
|
385
|
+
elsif src_info[:proxy_type] == :remote
|
|
386
|
+
puts "pause big"
|
|
387
|
+
@reads.delete(@big)
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
330
392
|
def add_write(sock)
|
|
331
393
|
return if sock.nil? || sock.closed? || @writes.include?(sock)
|
|
332
394
|
@writes << sock
|
|
@@ -521,15 +583,29 @@ module Girl
|
|
|
521
583
|
p2_id = data[1, 8].unpack('Q>').first
|
|
522
584
|
data = data[9..-1]
|
|
523
585
|
# puts "big got h_p2_traffic #{p2_id} #{data.bytesize}" if @is_debug
|
|
524
|
-
p1,
|
|
525
|
-
|
|
586
|
+
p1, p1_info = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
587
|
+
|
|
588
|
+
if p1_info
|
|
589
|
+
if p1_info[:switched]
|
|
590
|
+
add_p1_wbuff(p1, data)
|
|
591
|
+
else
|
|
592
|
+
add_p1_wpend(p1, data)
|
|
593
|
+
end
|
|
594
|
+
end
|
|
526
595
|
when @h_traffic
|
|
527
596
|
return if data.bytesize < 9
|
|
528
597
|
src_id = data[1, 8].unpack('Q>').first
|
|
529
598
|
data = data[9..-1]
|
|
530
599
|
# puts "big got h_traffic #{src_id} #{data.bytesize}" if @is_debug
|
|
531
|
-
src,
|
|
532
|
-
|
|
600
|
+
src, src_info = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
601
|
+
|
|
602
|
+
if src_info
|
|
603
|
+
if src_info[:switched]
|
|
604
|
+
add_src_wbuff(src, data)
|
|
605
|
+
else
|
|
606
|
+
add_src_wpend(src, data)
|
|
607
|
+
end
|
|
608
|
+
end
|
|
533
609
|
end
|
|
534
610
|
end
|
|
535
611
|
|
|
@@ -599,6 +675,39 @@ module Girl
|
|
|
599
675
|
data = data[9..-1]
|
|
600
676
|
src, _ = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
601
677
|
add_src_wbuff(src, data)
|
|
678
|
+
when @h_dst_switch_to_big
|
|
679
|
+
return if data.bytesize < 9
|
|
680
|
+
src_id = data[1, 8].unpack('Q>').first
|
|
681
|
+
puts "got h_dst_switch_to_big #{src_id}" if @is_debug
|
|
682
|
+
src, src_info = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
683
|
+
|
|
684
|
+
if src_info && !src_info[:switched]
|
|
685
|
+
src_info[:switched] = true
|
|
686
|
+
|
|
687
|
+
unless src_info[:wpend].empty?
|
|
688
|
+
data = src_info[:wpend].dup
|
|
689
|
+
domain = src_info[:destination_domain]
|
|
690
|
+
puts "move src wpend to wbuff #{domain} #{data.bytesize}"
|
|
691
|
+
src_info[:wpend].clear
|
|
692
|
+
add_src_wbuff(src, data)
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
when @h_p2_switch_to_big
|
|
696
|
+
return if data.bytesize < 9
|
|
697
|
+
p2_id = data[1, 8].unpack('Q>').first
|
|
698
|
+
puts "got h_p2_switch_to_big #{p2_id}" if @is_debug
|
|
699
|
+
p1, p1_info = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
700
|
+
|
|
701
|
+
if p1_info && !p1_info[:switched]
|
|
702
|
+
p1_info[:switched] = true
|
|
703
|
+
|
|
704
|
+
unless p1_info[:wpend].empty?
|
|
705
|
+
data = p1_info[:wpend].dup
|
|
706
|
+
puts "move p1 wpend to wbuff #{p2_id} #{data.bytesize}"
|
|
707
|
+
p1_info[:wpend].clear
|
|
708
|
+
add_p1_wbuff(p1, data)
|
|
709
|
+
end
|
|
710
|
+
end
|
|
602
711
|
end
|
|
603
712
|
end
|
|
604
713
|
|
|
@@ -768,10 +877,11 @@ module Girl
|
|
|
768
877
|
|
|
769
878
|
add_read(dst, :dst)
|
|
770
879
|
add_write(dst)
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
880
|
+
|
|
881
|
+
unless src_info[:rbuff].empty?
|
|
882
|
+
data = src_info[:rbuff].dup
|
|
774
883
|
puts "move src rbuff to dst #{domain} #{data.bytesize}" if @is_debug
|
|
884
|
+
src_info[:rbuff].clear
|
|
775
885
|
add_dst_wbuff(dst, data)
|
|
776
886
|
end
|
|
777
887
|
end
|
|
@@ -830,7 +940,9 @@ module Girl
|
|
|
830
940
|
is_big: false,
|
|
831
941
|
overflowing: false,
|
|
832
942
|
p2_id: p2_id,
|
|
833
|
-
|
|
943
|
+
switched: false,
|
|
944
|
+
wbuff: '',
|
|
945
|
+
wpend: ''
|
|
834
946
|
}
|
|
835
947
|
add_read(p1, :p1)
|
|
836
948
|
add_write(p1)
|
|
@@ -1161,9 +1273,16 @@ module Girl
|
|
|
1161
1273
|
p1_info[:in] += data.bytesize
|
|
1162
1274
|
p2_id = p1_info[:p2_id]
|
|
1163
1275
|
|
|
1276
|
+
if @proxy.closed?
|
|
1277
|
+
close_p1(p1)
|
|
1278
|
+
return
|
|
1279
|
+
end
|
|
1280
|
+
|
|
1164
1281
|
if !p1_info[:is_big] && (p1_info[:in] >= READ_SIZE)
|
|
1165
1282
|
puts "set p1 is big #{p2_id}"
|
|
1166
1283
|
p1_info[:is_big] = true
|
|
1284
|
+
msg = "#{@h_p1_switch_to_big}#{[p2_id].pack('Q>')}"
|
|
1285
|
+
add_proxy_wbuff(pack_a_chunk(msg))
|
|
1167
1286
|
end
|
|
1168
1287
|
|
|
1169
1288
|
data = pack_p2_traffic(p2_id, data)
|
|
@@ -1181,11 +1300,6 @@ module Girl
|
|
|
1181
1300
|
@reads.delete(p1)
|
|
1182
1301
|
end
|
|
1183
1302
|
else
|
|
1184
|
-
if @proxy.closed?
|
|
1185
|
-
close_p1(p1)
|
|
1186
|
-
return
|
|
1187
|
-
end
|
|
1188
|
-
|
|
1189
1303
|
add_proxy_wbuff(data)
|
|
1190
1304
|
end
|
|
1191
1305
|
end
|
|
@@ -1235,7 +1349,9 @@ module Girl
|
|
|
1235
1349
|
proxy_type: :uncheck, # :uncheck / :checking / :negotiation / :remote / :direct
|
|
1236
1350
|
rbuff: '',
|
|
1237
1351
|
src_id: src_id,
|
|
1238
|
-
|
|
1352
|
+
switched: false,
|
|
1353
|
+
wbuff: '',
|
|
1354
|
+
wpend: ''
|
|
1239
1355
|
}
|
|
1240
1356
|
add_read(src, :src)
|
|
1241
1357
|
end
|
|
@@ -1497,9 +1613,16 @@ module Girl
|
|
|
1497
1613
|
src_id = src_info[:src_id]
|
|
1498
1614
|
domain = src_info[:destination_domain]
|
|
1499
1615
|
|
|
1616
|
+
if @proxy.closed?
|
|
1617
|
+
close_src(src)
|
|
1618
|
+
return
|
|
1619
|
+
end
|
|
1620
|
+
|
|
1500
1621
|
if !src_info[:is_big] && (src_info[:in] >= READ_SIZE)
|
|
1501
1622
|
puts "set src is big #{src_id} #{domain}"
|
|
1502
1623
|
src_info[:is_big] = true
|
|
1624
|
+
msg = "#{@h_src_switch_to_big}#{[src_id].pack('Q>')}"
|
|
1625
|
+
add_proxy_wbuff(pack_a_chunk(msg))
|
|
1503
1626
|
end
|
|
1504
1627
|
|
|
1505
1628
|
data = pack_traffic(src_id, data)
|
|
@@ -1517,11 +1640,6 @@ module Girl
|
|
|
1517
1640
|
@reads.delete(src)
|
|
1518
1641
|
end
|
|
1519
1642
|
else
|
|
1520
|
-
if @proxy.closed?
|
|
1521
|
-
close_src(src)
|
|
1522
|
-
return
|
|
1523
|
-
end
|
|
1524
|
-
|
|
1525
1643
|
add_proxy_wbuff(data)
|
|
1526
1644
|
end
|
|
1527
1645
|
when :direct
|
|
@@ -1575,7 +1693,9 @@ module Girl
|
|
|
1575
1693
|
proxy_type: :uncheck, # :uncheck / :checking / :negotiation / :remote / :direct
|
|
1576
1694
|
rbuff: '',
|
|
1577
1695
|
src_id: src_id,
|
|
1578
|
-
|
|
1696
|
+
switched: false,
|
|
1697
|
+
wbuff: '',
|
|
1698
|
+
wpend: ''
|
|
1579
1699
|
}
|
|
1580
1700
|
add_read(src, :src)
|
|
1581
1701
|
make_tunnel(dest_ip, src)
|
|
@@ -1698,10 +1818,11 @@ module Girl
|
|
|
1698
1818
|
puts "add h_a_new_source #{src_id} #{domain_port}" if @is_debug
|
|
1699
1819
|
msg = "#{@h_a_new_source}#{[src_id].pack('Q>')}#{domain_port}"
|
|
1700
1820
|
add_proxy_wbuff(pack_a_chunk(msg))
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1821
|
+
|
|
1822
|
+
unless src_info[:rbuff].empty?
|
|
1823
|
+
data = src_info[:rbuff].dup
|
|
1704
1824
|
puts "move src rbuff to proxy #{domain} #{data.bytesize}" if @is_debug
|
|
1825
|
+
src_info[:rbuff].clear
|
|
1705
1826
|
add_proxy_wbuff(pack_traffic(src_id, data))
|
|
1706
1827
|
end
|
|
1707
1828
|
end
|
|
@@ -1752,8 +1873,6 @@ module Girl
|
|
|
1752
1873
|
@writes.delete(big)
|
|
1753
1874
|
return
|
|
1754
1875
|
end
|
|
1755
|
-
|
|
1756
|
-
return if @writes.include?(@proxy)
|
|
1757
1876
|
|
|
1758
1877
|
data = big_info[:wbuff]
|
|
1759
1878
|
|
|
@@ -1910,7 +2029,7 @@ module Girl
|
|
|
1910
2029
|
p1_info[:wbuff] = data
|
|
1911
2030
|
p2_id = p1_info[:p2_id]
|
|
1912
2031
|
|
|
1913
|
-
if p1_info[:overflowing] && p1_info[:wbuff].empty?
|
|
2032
|
+
if p1_info[:overflowing] && p1_info[:wbuff].empty? && p1_info[:wpend].empty?
|
|
1914
2033
|
puts "p1 empty #{p2_id}"
|
|
1915
2034
|
p1_info[:overflowing] = false
|
|
1916
2035
|
puts "resume big"
|
|
@@ -1989,7 +2108,7 @@ module Girl
|
|
|
1989
2108
|
data = data[written..-1]
|
|
1990
2109
|
src_info[:wbuff] = data
|
|
1991
2110
|
|
|
1992
|
-
if src_info[:wbuff].empty? && src_info[:
|
|
2111
|
+
if src_info[:overflowing] && src_info[:wbuff].empty? && src_info[:wpend].empty?
|
|
1993
2112
|
src_id = src_info[:src_id]
|
|
1994
2113
|
domain = src_info[:destination_domain]
|
|
1995
2114
|
puts "src empty #{src_id} #{domain}"
|
data/lib/girl/proxyd.rb
CHANGED
|
@@ -24,18 +24,22 @@ module Girl
|
|
|
24
24
|
ims = conf[:ims]
|
|
25
25
|
p2d_host = conf[:p2d_host]
|
|
26
26
|
p2d_port = conf[:p2d_port]
|
|
27
|
-
head_len = conf[:head_len]
|
|
28
|
-
h_a_new_source = conf[:h_a_new_source]
|
|
29
|
-
h_a_new_p2 = conf[:h_a_new_p2]
|
|
30
|
-
h_dst_close = conf[:h_dst_close]
|
|
31
|
-
h_heartbeat = conf[:h_heartbeat]
|
|
32
|
-
h_p1_close = conf[:h_p1_close]
|
|
33
|
-
h_p2_close = conf[:h_p2_close]
|
|
34
|
-
h_p2_traffic = conf[:h_p2_traffic]
|
|
35
|
-
h_query = conf[:h_query]
|
|
36
|
-
h_response = conf[:h_response]
|
|
37
|
-
h_src_close = conf[:h_src_close]
|
|
38
|
-
h_traffic = conf[:h_traffic]
|
|
27
|
+
head_len = conf[:head_len] # 头长度
|
|
28
|
+
h_a_new_source = conf[:h_a_new_source] # A
|
|
29
|
+
h_a_new_p2 = conf[:h_a_new_p2] # B
|
|
30
|
+
h_dst_close = conf[:h_dst_close] # D
|
|
31
|
+
h_heartbeat = conf[:h_heartbeat] # H
|
|
32
|
+
h_p1_close = conf[:h_p1_close] # I
|
|
33
|
+
h_p2_close = conf[:h_p2_close] # J
|
|
34
|
+
h_p2_traffic = conf[:h_p2_traffic] # K
|
|
35
|
+
h_query = conf[:h_query] # Q
|
|
36
|
+
h_response = conf[:h_response] # R
|
|
37
|
+
h_src_close = conf[:h_src_close] # S
|
|
38
|
+
h_traffic = conf[:h_traffic] # T
|
|
39
|
+
h_dst_switch_to_big = conf[:h_dst_switch_to_big] # U
|
|
40
|
+
h_p2_switch_to_big = conf[:h_p2_switch_to_big] # V
|
|
41
|
+
h_src_switch_to_big = conf[:h_src_switch_to_big] # W
|
|
42
|
+
h_p1_switch_to_big = conf[:h_p1_switch_to_big] # X
|
|
39
43
|
expire_connecting = conf[:expire_connecting] # 连接多久没有建成关闭(秒)
|
|
40
44
|
expire_long_after = conf[:expire_long_after] # 长连接多久没有新流量关闭(秒)
|
|
41
45
|
expire_resolv_cache = conf[:expire_resolv_cache] # dns查询结果缓存多久(秒)
|
|
@@ -84,6 +88,10 @@ module Girl
|
|
|
84
88
|
h_response = h_response ? h_response.to_s : 'R'
|
|
85
89
|
h_src_close = h_src_close ? h_src_close.to_s : 'S'
|
|
86
90
|
h_traffic = h_traffic ? h_traffic.to_s : 'T'
|
|
91
|
+
h_dst_switch_to_big = h_dst_switch_to_big ? h_dst_switch_to_big.to_s : 'U'
|
|
92
|
+
h_p2_switch_to_big = h_p2_switch_to_big ? h_p2_switch_to_big.to_s : 'V'
|
|
93
|
+
h_src_switch_to_big = h_src_switch_to_big ? h_src_switch_to_big.to_s : 'W'
|
|
94
|
+
h_p1_switch_to_big = h_p1_switch_to_big ? h_p1_switch_to_big.to_s : 'X'
|
|
87
95
|
expire_connecting = expire_connecting ? expire_connecting.to_i : 5
|
|
88
96
|
expire_long_after = expire_long_after ? expire_long_after.to_i : 3600
|
|
89
97
|
expire_resolv_cache = expire_resolv_cache ? expire_resolv_cache.to_i : 600
|
|
@@ -127,6 +135,10 @@ module Girl
|
|
|
127
135
|
h_response,
|
|
128
136
|
h_src_close,
|
|
129
137
|
h_traffic,
|
|
138
|
+
h_dst_switch_to_big,
|
|
139
|
+
h_p2_switch_to_big,
|
|
140
|
+
h_src_switch_to_big,
|
|
141
|
+
h_p1_switch_to_big,
|
|
130
142
|
expire_connecting,
|
|
131
143
|
expire_long_after,
|
|
132
144
|
expire_resolv_cache,
|
data/lib/girl/proxyd_worker.rb
CHANGED
|
@@ -23,6 +23,10 @@ module Girl
|
|
|
23
23
|
h_response,
|
|
24
24
|
h_src_close,
|
|
25
25
|
h_traffic,
|
|
26
|
+
h_dst_switch_to_big,
|
|
27
|
+
h_p2_switch_to_big,
|
|
28
|
+
h_src_switch_to_big,
|
|
29
|
+
h_p1_switch_to_big,
|
|
26
30
|
expire_connecting,
|
|
27
31
|
expire_long_after,
|
|
28
32
|
expire_resolv_cache,
|
|
@@ -43,12 +47,12 @@ module Girl
|
|
|
43
47
|
@im_infos = {} # im => {:addrinfo :big :big_connect_at :in :out :p2d :p2d_host :p2d_port :proxy :proxy_connect_at}
|
|
44
48
|
@src_infos = {} # src_id => {:created_at :dst :im :rbuff}
|
|
45
49
|
@mem_infos = {} # mem => {:wbuff}
|
|
46
|
-
@dst_infos = {} # dst => {:closing :connected :domain :im :in :ip :is_big :overflowing :port :rbuffs :src_id :wbuff}
|
|
50
|
+
@dst_infos = {} # dst => {:closing :connected :domain :im :in :ip :is_big :overflowing :port :rbuffs :src_id :switched :wbuff :wpend}
|
|
47
51
|
@dns_infos = {} # dns => {:domain :im :port :src_id}
|
|
48
52
|
@rsv_infos = {} # rsv => {:domain :im :near_id}
|
|
49
53
|
@resolv_caches = {} # domain => [ip created_at]
|
|
50
54
|
@p2d_infos = {} # p2d => {:im}
|
|
51
|
-
@p2_infos = {} # p2 => {:addrinfo :closing :im :in :is_big :overflowing :p2_id :wbuff}
|
|
55
|
+
@p2_infos = {} # p2 => {:addrinfo :closing :im :in :is_big :overflowing :p2_id :switched :wbuff :wpend}
|
|
52
56
|
@head_len = head_len
|
|
53
57
|
@h_a_new_source = h_a_new_source
|
|
54
58
|
@h_a_new_p2 = h_a_new_p2
|
|
@@ -61,6 +65,10 @@ module Girl
|
|
|
61
65
|
@h_response = h_response
|
|
62
66
|
@h_src_close = h_src_close
|
|
63
67
|
@h_traffic = h_traffic
|
|
68
|
+
@h_dst_switch_to_big = h_dst_switch_to_big
|
|
69
|
+
@h_p2_switch_to_big = h_p2_switch_to_big
|
|
70
|
+
@h_src_switch_to_big = h_src_switch_to_big
|
|
71
|
+
@h_p1_switch_to_big = h_p1_switch_to_big
|
|
64
72
|
@expire_connecting = expire_connecting
|
|
65
73
|
@expire_long_after = expire_long_after
|
|
66
74
|
@expire_resolv_cache = expire_resolv_cache
|
|
@@ -199,6 +207,37 @@ module Girl
|
|
|
199
207
|
add_write(dst)
|
|
200
208
|
end
|
|
201
209
|
|
|
210
|
+
def add_dst_wpend(dst, data)
|
|
211
|
+
return if dst.nil? || dst.closed? || data.nil? || data.empty?
|
|
212
|
+
dst_info = @dst_infos[dst]
|
|
213
|
+
puts "add dst wpend #{data.bytesize}" if @is_debug
|
|
214
|
+
dst_info[:wpend] << data
|
|
215
|
+
bytesize = dst_info[:wpend].bytesize
|
|
216
|
+
im = dst_info[:im]
|
|
217
|
+
domain = dst_info[:domain]
|
|
218
|
+
|
|
219
|
+
if bytesize >= CLOSE_ABOVE
|
|
220
|
+
puts "dst wpend full"
|
|
221
|
+
close_dst(dst)
|
|
222
|
+
return
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
if !dst_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
226
|
+
puts "dst overflow #{im} #{domain}"
|
|
227
|
+
dst_info[:overflowing] = true
|
|
228
|
+
im_info = @im_infos[im]
|
|
229
|
+
|
|
230
|
+
if im_info
|
|
231
|
+
big = im_info[:big]
|
|
232
|
+
|
|
233
|
+
if big
|
|
234
|
+
puts 'pause big'
|
|
235
|
+
@reads.delete(big)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
202
241
|
def add_mem_wbuff(mem, data)
|
|
203
242
|
return if mem.nil? || mem.closed? || data.nil? || data.empty?
|
|
204
243
|
mem_info = @mem_infos[mem]
|
|
@@ -238,6 +277,37 @@ module Girl
|
|
|
238
277
|
add_write(p2)
|
|
239
278
|
end
|
|
240
279
|
|
|
280
|
+
def add_p2_wpend(p2, data)
|
|
281
|
+
return if p2.nil? || p2.closed? || data.nil? || data.empty?
|
|
282
|
+
p2_info = @p2_infos[p2]
|
|
283
|
+
puts "add p2 wpend #{data.bytesize}" if @is_debug
|
|
284
|
+
p2_info[:wpend] << data
|
|
285
|
+
bytesize = p2_info[:wpend].bytesize
|
|
286
|
+
im = p2_info[:im]
|
|
287
|
+
p2_id = p2_info[:p2_id]
|
|
288
|
+
|
|
289
|
+
if bytesize >= CLOSE_ABOVE
|
|
290
|
+
puts "p2 wpend full"
|
|
291
|
+
close_p2(p2)
|
|
292
|
+
return
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
if !p2_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
296
|
+
puts "p2 overflow #{im} #{p2_id}"
|
|
297
|
+
p2_info[:overflowing] = true
|
|
298
|
+
im_info = @im_infos[im]
|
|
299
|
+
|
|
300
|
+
if im_info
|
|
301
|
+
big = im_info[:big]
|
|
302
|
+
|
|
303
|
+
if big
|
|
304
|
+
puts 'pause big'
|
|
305
|
+
@reads.delete(big)
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
241
311
|
def add_proxy_wbuff(proxy, data)
|
|
242
312
|
return if proxy.nil? || proxy.closed? || data.nil? || data.empty?
|
|
243
313
|
proxy_info = @proxy_infos[proxy]
|
|
@@ -269,27 +339,6 @@ module Girl
|
|
|
269
339
|
end
|
|
270
340
|
end
|
|
271
341
|
|
|
272
|
-
def add_src_rbuff(src_id, data)
|
|
273
|
-
src_info = @src_infos[src_id]
|
|
274
|
-
|
|
275
|
-
if src_info
|
|
276
|
-
im = src_info[:im]
|
|
277
|
-
dst = src_info[:dst]
|
|
278
|
-
|
|
279
|
-
if dst
|
|
280
|
-
add_dst_wbuff(dst, data)
|
|
281
|
-
else
|
|
282
|
-
puts "add src rbuff #{im} #{data.bytesize}" if @is_debug
|
|
283
|
-
src_info[:rbuff] << data
|
|
284
|
-
|
|
285
|
-
if src_info[:rbuff].bytesize >= WBUFF_LIMIT
|
|
286
|
-
puts "src rbuff full"
|
|
287
|
-
@src_infos.delete(src_id)
|
|
288
|
-
end
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
342
|
def add_write(sock)
|
|
294
343
|
return if sock.nil? || sock.closed? || @writes.include?(sock)
|
|
295
344
|
@writes << sock
|
|
@@ -499,14 +548,37 @@ module Girl
|
|
|
499
548
|
p2_id = data[1, 8].unpack('Q>').first
|
|
500
549
|
data = data[9..-1]
|
|
501
550
|
# puts "big got h_p2_traffic #{im} #{p2_id} #{data.bytesize}" if @is_debug
|
|
502
|
-
p2,
|
|
503
|
-
|
|
551
|
+
p2, p2_info = @p2_infos.find{|_, info| (info[:im] == im) && (info[:p2_id] == p2_id)}
|
|
552
|
+
|
|
553
|
+
if p2_info
|
|
554
|
+
if p2_info[:switched]
|
|
555
|
+
add_p2_wbuff(p2, data)
|
|
556
|
+
else
|
|
557
|
+
add_p2_wpend(p2, data)
|
|
558
|
+
end
|
|
559
|
+
end
|
|
504
560
|
when @h_traffic
|
|
505
561
|
return if data.bytesize < 9
|
|
506
562
|
src_id = data[1, 8].unpack('Q>').first
|
|
507
563
|
data = data[9..-1]
|
|
508
564
|
# puts "big got h_traffic #{im} #{src_id} #{data.bytesize}" if @is_debug
|
|
509
|
-
|
|
565
|
+
src_info = @src_infos[src_id]
|
|
566
|
+
|
|
567
|
+
if src_info
|
|
568
|
+
dst = src_info[:dst]
|
|
569
|
+
|
|
570
|
+
if dst
|
|
571
|
+
dst_info = @dst_infos[dst]
|
|
572
|
+
|
|
573
|
+
if dst_info
|
|
574
|
+
if dst_info[:switched]
|
|
575
|
+
add_dst_wbuff(dst, data)
|
|
576
|
+
else
|
|
577
|
+
add_dst_wpend(dst, data)
|
|
578
|
+
end
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
end
|
|
510
582
|
end
|
|
511
583
|
end
|
|
512
584
|
|
|
@@ -561,7 +633,64 @@ module Girl
|
|
|
561
633
|
return if data.bytesize < 9
|
|
562
634
|
src_id = data[1, 8].unpack('Q>').first
|
|
563
635
|
data = data[9..-1]
|
|
564
|
-
|
|
636
|
+
src_info = @src_infos[src_id]
|
|
637
|
+
|
|
638
|
+
if src_info
|
|
639
|
+
dst = src_info[:dst]
|
|
640
|
+
|
|
641
|
+
if dst
|
|
642
|
+
add_dst_wbuff(dst, data)
|
|
643
|
+
else
|
|
644
|
+
puts "add src rbuff #{im} #{data.bytesize}" if @is_debug
|
|
645
|
+
src_info[:rbuff] << data
|
|
646
|
+
|
|
647
|
+
if src_info[:rbuff].bytesize >= CLOSE_ABOVE
|
|
648
|
+
puts "src rbuff full"
|
|
649
|
+
@src_infos.delete(src_id)
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
when @h_src_switch_to_big
|
|
654
|
+
return if data.bytesize < 9
|
|
655
|
+
src_id = data[1, 8].unpack('Q>').first
|
|
656
|
+
puts "got h_src_switch_to_big #{src_id}" if @is_debug
|
|
657
|
+
src_info = @src_infos[src_id]
|
|
658
|
+
|
|
659
|
+
if src_info
|
|
660
|
+
dst = src_info[:dst]
|
|
661
|
+
|
|
662
|
+
if dst
|
|
663
|
+
dst_info = @dst_infos[dst]
|
|
664
|
+
|
|
665
|
+
if dst_info && !dst_info[:switched]
|
|
666
|
+
dst_info[:switched] = true
|
|
667
|
+
|
|
668
|
+
unless dst_info[:wpend].empty?
|
|
669
|
+
data = dst_info[:wpend].dup
|
|
670
|
+
domain = dst_info[:domain]
|
|
671
|
+
puts "move dst wpend to wbuff #{domain} #{data.bytesize}"
|
|
672
|
+
dst_info[:wpend].clear
|
|
673
|
+
add_dst_wbuff(dst, data)
|
|
674
|
+
end
|
|
675
|
+
end
|
|
676
|
+
end
|
|
677
|
+
end
|
|
678
|
+
when @h_p1_switch_to_big
|
|
679
|
+
return if data.bytesize < 9
|
|
680
|
+
p2_id = data[1, 8].unpack('Q>').first
|
|
681
|
+
puts "got h_p1_switch_to_big #{p2_id}" if @is_debug
|
|
682
|
+
p2, p2_info = @p2_infos.find{|_, info| (info[:im] == im) && (info[:p2_id] == p2_id)}
|
|
683
|
+
|
|
684
|
+
if p2_info && !p2_info[:switched]
|
|
685
|
+
p2_info[:switched] = true
|
|
686
|
+
|
|
687
|
+
unless p2_info[:wpend].empty?
|
|
688
|
+
data = p2_info[:wpend].dup
|
|
689
|
+
puts "move p2 wpend to wbuff #{p2_id} #{data.bytesize}"
|
|
690
|
+
p2_info[:wpend].clear
|
|
691
|
+
add_p2_wbuff(p2, data)
|
|
692
|
+
end
|
|
693
|
+
end
|
|
565
694
|
end
|
|
566
695
|
end
|
|
567
696
|
|
|
@@ -685,12 +814,15 @@ module Girl
|
|
|
685
814
|
port: port,
|
|
686
815
|
rbuffs: [],
|
|
687
816
|
src_id: src_id,
|
|
688
|
-
|
|
817
|
+
switched: false,
|
|
818
|
+
wbuff: src_info[:rbuff].dup,
|
|
819
|
+
wpend: ''
|
|
689
820
|
}
|
|
690
821
|
|
|
691
822
|
@dst_infos[dst] = dst_info
|
|
692
823
|
add_read(dst, :dst)
|
|
693
824
|
add_write(dst)
|
|
825
|
+
src_info[:rbuff].clear
|
|
694
826
|
src_info[:dst] = dst
|
|
695
827
|
end
|
|
696
828
|
|
|
@@ -958,19 +1090,27 @@ module Girl
|
|
|
958
1090
|
im = dst_info[:im]
|
|
959
1091
|
src_id = dst_info[:src_id]
|
|
960
1092
|
domain = dst_info[:domain]
|
|
1093
|
+
im_info = @im_infos[im]
|
|
961
1094
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1095
|
+
unless im_info
|
|
1096
|
+
close_dst(dst)
|
|
1097
|
+
return
|
|
965
1098
|
end
|
|
966
1099
|
|
|
967
|
-
|
|
1100
|
+
proxy = im_info[:proxy]
|
|
968
1101
|
|
|
969
|
-
|
|
1102
|
+
if proxy.nil? || proxy.closed?
|
|
970
1103
|
close_dst(dst)
|
|
971
1104
|
return
|
|
972
1105
|
end
|
|
973
1106
|
|
|
1107
|
+
if !dst_info[:is_big] && (dst_info[:in] >= READ_SIZE)
|
|
1108
|
+
puts "set dst is big #{im} #{src_id} #{domain}"
|
|
1109
|
+
dst_info[:is_big] = true
|
|
1110
|
+
msg = "#{@h_dst_switch_to_big}#{[src_id].pack('Q>')}"
|
|
1111
|
+
add_proxy_wbuff(proxy, pack_a_chunk(msg))
|
|
1112
|
+
end
|
|
1113
|
+
|
|
974
1114
|
im_info[:in] += data.bytesize
|
|
975
1115
|
data = pack_traffic(src_id, data)
|
|
976
1116
|
|
|
@@ -989,13 +1129,6 @@ module Girl
|
|
|
989
1129
|
@reads.delete(dst)
|
|
990
1130
|
end
|
|
991
1131
|
else
|
|
992
|
-
proxy = im_info[:proxy]
|
|
993
|
-
|
|
994
|
-
if proxy.nil? || proxy.closed?
|
|
995
|
-
close_dst(dst)
|
|
996
|
-
return
|
|
997
|
-
end
|
|
998
|
-
|
|
999
1132
|
add_proxy_wbuff(proxy, data)
|
|
1000
1133
|
end
|
|
1001
1134
|
end
|
|
@@ -1115,19 +1248,27 @@ module Girl
|
|
|
1115
1248
|
p2_info[:in] += data.bytesize
|
|
1116
1249
|
im = p2_info[:im]
|
|
1117
1250
|
p2_id = p2_info[:p2_id]
|
|
1251
|
+
im_info = @im_infos[im]
|
|
1118
1252
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1253
|
+
unless im_info
|
|
1254
|
+
close_p2(p2)
|
|
1255
|
+
return
|
|
1122
1256
|
end
|
|
1123
1257
|
|
|
1124
|
-
|
|
1258
|
+
proxy = im_info[:proxy]
|
|
1125
1259
|
|
|
1126
|
-
|
|
1260
|
+
if proxy.nil? || proxy.closed?
|
|
1127
1261
|
close_p2(p2)
|
|
1128
1262
|
return
|
|
1129
1263
|
end
|
|
1130
1264
|
|
|
1265
|
+
if !p2_info[:is_big] && (p2_info[:in] >= READ_SIZE)
|
|
1266
|
+
puts "set p2 is big #{im} #{p2_id}"
|
|
1267
|
+
p2_info[:is_big] = true
|
|
1268
|
+
msg = "#{@h_p2_switch_to_big}#{[p2_id].pack('Q>')}"
|
|
1269
|
+
add_proxy_wbuff(proxy, pack_a_chunk(msg))
|
|
1270
|
+
end
|
|
1271
|
+
|
|
1131
1272
|
data = pack_p2_traffic(p2_id, data)
|
|
1132
1273
|
|
|
1133
1274
|
if p2_info[:is_big]
|
|
@@ -1145,13 +1286,6 @@ module Girl
|
|
|
1145
1286
|
@reads.delete(p2)
|
|
1146
1287
|
end
|
|
1147
1288
|
else
|
|
1148
|
-
proxy = im_info[:proxy]
|
|
1149
|
-
|
|
1150
|
-
if proxy.nil? || proxy.closed?
|
|
1151
|
-
close_p2(p2)
|
|
1152
|
-
return
|
|
1153
|
-
end
|
|
1154
|
-
|
|
1155
1289
|
add_proxy_wbuff(proxy, data)
|
|
1156
1290
|
end
|
|
1157
1291
|
end
|
|
@@ -1177,7 +1311,9 @@ module Girl
|
|
|
1177
1311
|
is_big: false, # 是否收流量大户
|
|
1178
1312
|
overflowing: false,
|
|
1179
1313
|
p2_id: p2_id,
|
|
1180
|
-
|
|
1314
|
+
switched: false,
|
|
1315
|
+
wbuff: '',
|
|
1316
|
+
wpend: ''
|
|
1181
1317
|
}
|
|
1182
1318
|
add_read(p2, :p2)
|
|
1183
1319
|
im_info = @im_infos[im]
|
|
@@ -1454,7 +1590,6 @@ module Girl
|
|
|
1454
1590
|
return
|
|
1455
1591
|
end
|
|
1456
1592
|
|
|
1457
|
-
return if @writes.include?(im_info[:proxy])
|
|
1458
1593
|
data = big_info[:wbuff]
|
|
1459
1594
|
|
|
1460
1595
|
if data.empty?
|
|
@@ -1537,7 +1672,7 @@ module Girl
|
|
|
1537
1672
|
src_id = dst_info[:src_id]
|
|
1538
1673
|
domain = dst_info[:domain]
|
|
1539
1674
|
|
|
1540
|
-
if dst_info[:wbuff].empty? && dst_info[:
|
|
1675
|
+
if dst_info[:overflowing] && dst_info[:wbuff].empty? && dst_info[:wpend].empty?
|
|
1541
1676
|
puts "dst empty #{im} #{src_id} #{domain}"
|
|
1542
1677
|
dst_info[:overflowing] = false
|
|
1543
1678
|
|
|
@@ -1617,7 +1752,7 @@ module Girl
|
|
|
1617
1752
|
p2_info[:wbuff] = data
|
|
1618
1753
|
p2_id = p2_info[:p2_id]
|
|
1619
1754
|
|
|
1620
|
-
if p2_info[:overflowing] && p2_info[:wbuff].empty?
|
|
1755
|
+
if p2_info[:overflowing] && p2_info[:wbuff].empty? && p2_info[:wpend].empty?
|
|
1621
1756
|
puts "p2 empty #{im} #{p2_id}"
|
|
1622
1757
|
p2_info[:overflowing] = false
|
|
1623
1758
|
|
data/lib/girl/version.rb
CHANGED