girl 9.1.3 → 9.1.4
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 +3 -4
- data/lib/girl/proxy.rb +6 -34
- data/lib/girl/proxy_worker.rb +330 -501
- data/lib/girl/proxyd.rb +7 -31
- data/lib/girl/proxyd_worker.rb +501 -270
- data/lib/girl/version.rb +1 -1
- metadata +1 -1
data/lib/girl/proxy_worker.rb
CHANGED
|
@@ -6,12 +6,11 @@ module Girl
|
|
|
6
6
|
redir_host,
|
|
7
7
|
redir_port,
|
|
8
8
|
memd_port,
|
|
9
|
-
relayd_host,
|
|
10
|
-
relayd_port,
|
|
11
9
|
tspd_host,
|
|
12
10
|
tspd_port,
|
|
13
11
|
proxyd_host,
|
|
14
12
|
proxyd_port,
|
|
13
|
+
bigd_port,
|
|
15
14
|
nameservers,
|
|
16
15
|
im,
|
|
17
16
|
directs,
|
|
@@ -26,18 +25,10 @@ module Girl
|
|
|
26
25
|
h_p1_close,
|
|
27
26
|
h_p2_close,
|
|
28
27
|
h_p2_traffic,
|
|
29
|
-
h_p1_overflow,
|
|
30
|
-
h_p1_underhalf,
|
|
31
|
-
h_p2_overflow,
|
|
32
|
-
h_p2_underhalf,
|
|
33
28
|
h_query,
|
|
34
29
|
h_response,
|
|
35
30
|
h_src_close,
|
|
36
31
|
h_traffic,
|
|
37
|
-
h_src_overflow,
|
|
38
|
-
h_src_underhalf,
|
|
39
|
-
h_dst_overflow,
|
|
40
|
-
h_dst_underhalf,
|
|
41
32
|
expire_connecting,
|
|
42
33
|
expire_long_after,
|
|
43
34
|
expire_proxy_after,
|
|
@@ -45,27 +36,27 @@ module Girl
|
|
|
45
36
|
expire_short_after,
|
|
46
37
|
is_debug,
|
|
47
38
|
is_client_fastopen,
|
|
48
|
-
is_server_fastopen
|
|
39
|
+
is_server_fastopen)
|
|
49
40
|
|
|
50
41
|
@proxyd_host = proxyd_host
|
|
51
42
|
@proxyd_addr = Socket.sockaddr_in(proxyd_port, proxyd_host)
|
|
43
|
+
@bigd_addr = Socket.sockaddr_in(bigd_port, proxyd_host)
|
|
52
44
|
@nameserver_addrs = nameservers.map{|n| Socket.sockaddr_in(53, n)}
|
|
53
45
|
@im = im
|
|
54
46
|
@directs = directs
|
|
55
47
|
@remotes = remotes
|
|
56
48
|
@local_ips = Socket.ip_address_list.select{|info| info.ipv4?}.map{|info| info.ip_address}
|
|
57
49
|
@update_roles = [:dns, :dst, :mem, :p1, :src, :rsv] # 参与淘汰的角色
|
|
58
|
-
@updates_limit =
|
|
50
|
+
@updates_limit = 1008 # 淘汰池上限,1015(mac) - info, infod, memd, proxy, redir, rsvd, tspd
|
|
59
51
|
@eliminate_count = 0 # 淘汰次数
|
|
60
52
|
@reads = [] # 读池
|
|
61
53
|
@writes = [] # 写池
|
|
62
|
-
@roles = {} # sock => :
|
|
54
|
+
@roles = {} # sock => :big / :dns / :dst / :infod / :mem / :memd / :p1 / :proxy / :redir / :rsv / :rsvd / :src / :tspd
|
|
63
55
|
@updates = {} # sock => updated_at
|
|
64
|
-
@proxy_infos = {} # proxy => {:is_syn :
|
|
56
|
+
@proxy_infos = {} # proxy => {:is_syn :rbuff :recv_at :wbuff}
|
|
57
|
+
@big_infos = {} # big => {:is_syn :overflowing :rbuff :recv_at :wbuff}
|
|
65
58
|
@mem_infos = {} # mem => {:wbuff}
|
|
66
|
-
@
|
|
67
|
-
@girl_infos = {} # girl => {:closing :connected :is_syn :overflowing :relay :wbuff}
|
|
68
|
-
@src_infos = {} # src => {:addrinfo :closing :destination_domain :destination_port :dst :is_connect :overflowing :proxy_proto :proxy_type :rbuff :src_id :wbuff}
|
|
59
|
+
@src_infos = {} # src => {:addrinfo :closing :destination_domain :destination_port :dst :in :is_big :is_connect :overflowing :proxy_proto :proxy_type :rbuff :src_id :wbuff}
|
|
69
60
|
@dst_infos = {} # dst => {:closing :connected :domain :ip :overflowing :port :src :wbuff}
|
|
70
61
|
@dns_infos = {} # dns => {:domain :src}
|
|
71
62
|
@rsv_infos = {} # rsv => {:addrinfo :domain :type}
|
|
@@ -74,7 +65,7 @@ module Girl
|
|
|
74
65
|
@is_direct_caches = {} # ip => true / false
|
|
75
66
|
@response_caches = {} # domain => [response, created_at, ip, is_remote]
|
|
76
67
|
@response6_caches = {} # domain => [response, created_at, ip, is_remote]
|
|
77
|
-
@p1_infos = {} # p1 => {:closing :connected :overflowing :p2_id :wbuff}
|
|
68
|
+
@p1_infos = {} # p1 => {:closing :connected :in :is_big :overflowing :p2_id :wbuff}
|
|
78
69
|
@appd_addr = Socket.sockaddr_in(appd_port, appd_host)
|
|
79
70
|
|
|
80
71
|
@head_len = head_len
|
|
@@ -85,18 +76,10 @@ module Girl
|
|
|
85
76
|
@h_p1_close = h_p1_close
|
|
86
77
|
@h_p2_close = h_p2_close
|
|
87
78
|
@h_p2_traffic = h_p2_traffic
|
|
88
|
-
@h_p1_overflow = h_p1_overflow
|
|
89
|
-
@h_p1_underhalf = h_p1_underhalf
|
|
90
|
-
@h_p2_overflow = h_p2_overflow
|
|
91
|
-
@h_p2_underhalf = h_p2_underhalf
|
|
92
79
|
@h_query = h_query
|
|
93
80
|
@h_response = h_response
|
|
94
81
|
@h_src_close = h_src_close
|
|
95
82
|
@h_traffic = h_traffic
|
|
96
|
-
@h_src_overflow = h_src_overflow
|
|
97
|
-
@h_src_underhalf = h_src_underhalf
|
|
98
|
-
@h_dst_overflow = h_dst_overflow
|
|
99
|
-
@h_dst_underhalf = h_dst_underhalf
|
|
100
83
|
@expire_connecting = expire_connecting
|
|
101
84
|
@expire_long_after = expire_long_after
|
|
102
85
|
@expire_proxy_after = expire_proxy_after
|
|
@@ -109,10 +92,10 @@ module Girl
|
|
|
109
92
|
new_a_redir(redir_host, redir_port)
|
|
110
93
|
new_a_infod(redir_port)
|
|
111
94
|
new_a_memd(memd_port)
|
|
112
|
-
new_a_relayd(relayd_host, relayd_port)
|
|
113
95
|
new_a_rsvd(tspd_host, tspd_port)
|
|
114
96
|
new_a_tspd(tspd_host, tspd_port)
|
|
115
97
|
new_a_proxy
|
|
98
|
+
new_a_big
|
|
116
99
|
end
|
|
117
100
|
|
|
118
101
|
def looping
|
|
@@ -126,12 +109,12 @@ module Girl
|
|
|
126
109
|
role = @roles[sock]
|
|
127
110
|
|
|
128
111
|
case role
|
|
112
|
+
when :big
|
|
113
|
+
read_big(sock)
|
|
129
114
|
when :dns
|
|
130
115
|
read_dns(sock)
|
|
131
116
|
when :dst
|
|
132
117
|
read_dst(sock)
|
|
133
|
-
when :girl
|
|
134
|
-
read_girl(sock)
|
|
135
118
|
when :infod
|
|
136
119
|
read_infod(sock)
|
|
137
120
|
when :mem
|
|
@@ -144,10 +127,6 @@ module Girl
|
|
|
144
127
|
read_proxy(sock)
|
|
145
128
|
when :redir
|
|
146
129
|
read_redir(sock)
|
|
147
|
-
when :relay
|
|
148
|
-
read_relay(sock)
|
|
149
|
-
when :relayd
|
|
150
|
-
read_relayd(sock)
|
|
151
130
|
when :rsv
|
|
152
131
|
read_rsv(sock)
|
|
153
132
|
when :rsvd
|
|
@@ -165,18 +144,16 @@ module Girl
|
|
|
165
144
|
role = @roles[sock]
|
|
166
145
|
|
|
167
146
|
case role
|
|
147
|
+
when :big
|
|
148
|
+
write_big(sock)
|
|
168
149
|
when :dst
|
|
169
150
|
write_dst(sock)
|
|
170
|
-
when :girl
|
|
171
|
-
write_girl(sock)
|
|
172
151
|
when :mem
|
|
173
152
|
write_mem(sock)
|
|
174
153
|
when :p1
|
|
175
154
|
write_p1(sock)
|
|
176
155
|
when :proxy
|
|
177
156
|
write_proxy(sock)
|
|
178
|
-
when :relay
|
|
179
|
-
write_relay(sock)
|
|
180
157
|
when :src
|
|
181
158
|
write_src(sock)
|
|
182
159
|
else
|
|
@@ -195,46 +172,57 @@ module Girl
|
|
|
195
172
|
|
|
196
173
|
private
|
|
197
174
|
|
|
198
|
-
def
|
|
199
|
-
return if
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
bytesize =
|
|
175
|
+
def add_big_wbuff(data)
|
|
176
|
+
return if @big.nil? || @big.closed? || data.nil? || data.empty?
|
|
177
|
+
big_info = @big_infos[@big]
|
|
178
|
+
big_info[:wbuff] << data
|
|
179
|
+
bytesize = big_info[:wbuff].bytesize
|
|
203
180
|
|
|
204
181
|
if bytesize >= CLOSE_ABOVE
|
|
205
|
-
puts "close overflow
|
|
206
|
-
|
|
182
|
+
puts "close overflow big"
|
|
183
|
+
close_big(@big)
|
|
207
184
|
return
|
|
208
185
|
end
|
|
209
186
|
|
|
210
|
-
if !
|
|
211
|
-
puts "
|
|
212
|
-
|
|
213
|
-
|
|
187
|
+
if !big_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
188
|
+
puts "big overflow"
|
|
189
|
+
big_info[:overflowing] = true
|
|
190
|
+
|
|
191
|
+
@src_infos.select{|_, info| info[:is_big]}.each do |src, info|
|
|
192
|
+
puts "pause src #{info[:destination_domain]}"
|
|
193
|
+
@reads.delete(src)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
@p1_infos.select{|_, info| info[:is_big]}.each do |p1, info|
|
|
197
|
+
puts "pause p1 #{info[:p2_id]}"
|
|
198
|
+
@reads.delete(p1)
|
|
199
|
+
end
|
|
214
200
|
end
|
|
215
201
|
|
|
216
|
-
add_write(
|
|
202
|
+
add_write(@big)
|
|
217
203
|
end
|
|
218
204
|
|
|
219
|
-
def
|
|
220
|
-
return if
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
bytesize =
|
|
205
|
+
def add_dst_wbuff(dst, data)
|
|
206
|
+
return if dst.nil? || dst.closed? || data.nil? || data.empty?
|
|
207
|
+
dst_info = @dst_infos[dst]
|
|
208
|
+
dst_info[:wbuff] << data
|
|
209
|
+
bytesize = dst_info[:wbuff].bytesize
|
|
210
|
+
domain = dst_info[:domain]
|
|
224
211
|
|
|
225
212
|
if bytesize >= CLOSE_ABOVE
|
|
226
|
-
puts "close overflow
|
|
227
|
-
|
|
213
|
+
puts "close overflow dst #{domain}"
|
|
214
|
+
close_dst(dst)
|
|
228
215
|
return
|
|
229
216
|
end
|
|
230
217
|
|
|
231
|
-
if !
|
|
232
|
-
puts "
|
|
233
|
-
|
|
234
|
-
|
|
218
|
+
if !dst_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
219
|
+
puts "dst overflow #{domain}"
|
|
220
|
+
dst_info[:overflowing] = true
|
|
221
|
+
puts "pause src"
|
|
222
|
+
@reads.delete(dst_info[:src])
|
|
235
223
|
end
|
|
236
224
|
|
|
237
|
-
add_write(
|
|
225
|
+
add_write(dst)
|
|
238
226
|
end
|
|
239
227
|
|
|
240
228
|
def add_mem_wbuff(mem, data)
|
|
@@ -258,10 +246,13 @@ module Girl
|
|
|
258
246
|
end
|
|
259
247
|
|
|
260
248
|
if !p1_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
261
|
-
puts "
|
|
262
|
-
msg = "#{@h_p1_overflow}#{[p2_id].pack('Q>')}"
|
|
263
|
-
add_proxy_wbuff(pack_a_chunk(msg))
|
|
249
|
+
puts "p1 overflow #{p2_id}"
|
|
264
250
|
p1_info[:overflowing] = true
|
|
251
|
+
|
|
252
|
+
if @big
|
|
253
|
+
puts 'pause big'
|
|
254
|
+
@reads.delete(@big)
|
|
255
|
+
end
|
|
265
256
|
end
|
|
266
257
|
|
|
267
258
|
add_write(p1)
|
|
@@ -295,27 +286,6 @@ module Girl
|
|
|
295
286
|
set_update(sock) if @update_roles.include?(role)
|
|
296
287
|
end
|
|
297
288
|
|
|
298
|
-
def add_relay_wbuff(relay, data)
|
|
299
|
-
return if relay.nil? || relay.closed? || data.nil? || data.empty?
|
|
300
|
-
relay_info = @relay_infos[relay]
|
|
301
|
-
relay_info[:wbuff] << data
|
|
302
|
-
bytesize = relay_info[:wbuff].bytesize
|
|
303
|
-
|
|
304
|
-
if bytesize >= CLOSE_ABOVE
|
|
305
|
-
puts "close overflow relay #{relay_info[:addrinfo].ip_unpack.inspect}"
|
|
306
|
-
close_relay(relay)
|
|
307
|
-
return
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
if !relay_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
311
|
-
puts "relay overflow pause girl #{relay_info[:addrinfo].ip_unpack.inspect}"
|
|
312
|
-
@reads.delete(relay_info[:girl])
|
|
313
|
-
relay_info[:overflowing] = true
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
add_write(relay)
|
|
317
|
-
end
|
|
318
|
-
|
|
319
289
|
def add_socks5_conn_reply(src)
|
|
320
290
|
# +----+-----+-------+------+----------+----------+
|
|
321
291
|
# |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
|
|
@@ -354,16 +324,16 @@ module Girl
|
|
|
354
324
|
end
|
|
355
325
|
|
|
356
326
|
if !src_info[:overflowing] && (bytesize >= WBUFF_LIMIT)
|
|
327
|
+
puts "src overflow #{src_id} #{domain}"
|
|
328
|
+
src_info[:overflowing] = true
|
|
329
|
+
|
|
357
330
|
if src_info[:proxy_type] == :direct
|
|
358
|
-
puts "
|
|
331
|
+
puts "pause dst"
|
|
359
332
|
@reads.delete(src_info[:dst])
|
|
360
333
|
elsif src_info[:proxy_type] == :remote
|
|
361
|
-
puts "
|
|
362
|
-
|
|
363
|
-
add_proxy_wbuff(pack_a_chunk(msg))
|
|
334
|
+
puts "pause big"
|
|
335
|
+
@reads.delete(@big)
|
|
364
336
|
end
|
|
365
|
-
|
|
366
|
-
src_info[:overflowing] = true
|
|
367
337
|
end
|
|
368
338
|
|
|
369
339
|
add_write(src)
|
|
@@ -394,15 +364,6 @@ module Girl
|
|
|
394
364
|
end
|
|
395
365
|
end
|
|
396
366
|
|
|
397
|
-
def check_expire_girls
|
|
398
|
-
now = Time.new
|
|
399
|
-
|
|
400
|
-
@girl_infos.select{|girl, info| info[:connected] ? (now.to_i - @updates[girl].to_i >= @expire_long_after) : (now.to_i - @updates[girl].to_i >= @expire_connecting)}.each do |girl, _|
|
|
401
|
-
puts "expire girl" if @is_debug
|
|
402
|
-
close_girl(girl)
|
|
403
|
-
end
|
|
404
|
-
end
|
|
405
|
-
|
|
406
367
|
def check_expire_mems
|
|
407
368
|
now = Time.new
|
|
408
369
|
|
|
@@ -430,15 +391,6 @@ module Girl
|
|
|
430
391
|
end
|
|
431
392
|
end
|
|
432
393
|
|
|
433
|
-
def check_expire_relays
|
|
434
|
-
now = Time.new
|
|
435
|
-
|
|
436
|
-
@relay_infos.select{|relay, _| now.to_i - @updates[relay].to_i >= @expire_long_after}.each do |relay, info|
|
|
437
|
-
puts "expire relay #{info[:addrinfo].ip_unpack.inspect}" if @is_debug
|
|
438
|
-
close_relay(relay)
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
|
|
442
394
|
def check_expire_rsvs
|
|
443
395
|
now = Time.new
|
|
444
396
|
|
|
@@ -457,11 +409,24 @@ module Girl
|
|
|
457
409
|
end
|
|
458
410
|
end
|
|
459
411
|
|
|
412
|
+
def close_big(big)
|
|
413
|
+
return if big.nil? || big.closed?
|
|
414
|
+
close_sock(big)
|
|
415
|
+
big_info = @big_infos.delete(big)
|
|
416
|
+
puts "close big"
|
|
417
|
+
big_info
|
|
418
|
+
end
|
|
419
|
+
|
|
460
420
|
def close_dns(dns)
|
|
461
421
|
return nil if dns.nil? || dns.closed?
|
|
462
422
|
close_sock(dns)
|
|
463
423
|
dns_info = @dns_infos.delete(dns)
|
|
464
|
-
|
|
424
|
+
|
|
425
|
+
if dns_info
|
|
426
|
+
domain = dns_info[:domain]
|
|
427
|
+
puts "close dns #{domain}" if @is_debug
|
|
428
|
+
end
|
|
429
|
+
|
|
465
430
|
dns_info
|
|
466
431
|
end
|
|
467
432
|
|
|
@@ -469,18 +434,14 @@ module Girl
|
|
|
469
434
|
return nil if dst.nil? || dst.closed?
|
|
470
435
|
close_sock(dst)
|
|
471
436
|
dst_info = @dst_infos.delete(dst)
|
|
472
|
-
puts "close dst #{dst_info[:domain]}" if @is_debug
|
|
473
|
-
set_src_closing(dst_info[:src]) if dst_info
|
|
474
|
-
dst_info
|
|
475
|
-
end
|
|
476
437
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
438
|
+
if dst_info
|
|
439
|
+
domain = dst_info[:domain]
|
|
440
|
+
puts "close dst #{domain}" if @is_debug
|
|
441
|
+
set_src_closing(dst_info[:src])
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
dst_info
|
|
484
445
|
end
|
|
485
446
|
|
|
486
447
|
def close_mem(mem)
|
|
@@ -494,9 +455,7 @@ module Girl
|
|
|
494
455
|
close_sock(p1)
|
|
495
456
|
p1_info = @p1_infos.delete(p1)
|
|
496
457
|
|
|
497
|
-
|
|
498
|
-
proxy_info = @proxy_infos[@proxy]
|
|
499
|
-
proxy_info[:paused_p1s].delete(p1)
|
|
458
|
+
if p1_info
|
|
500
459
|
p2_id = p1_info[:p2_id]
|
|
501
460
|
puts "add h_p1_close #{p2_id}"
|
|
502
461
|
msg = "#{@h_p1_close}#{[p2_id].pack('Q>')}"
|
|
@@ -516,20 +475,16 @@ module Girl
|
|
|
516
475
|
proxy_info
|
|
517
476
|
end
|
|
518
477
|
|
|
519
|
-
def close_relay(relay)
|
|
520
|
-
return nil if relay.nil? || relay.closed?
|
|
521
|
-
close_sock(relay)
|
|
522
|
-
relay_info = @relay_infos.delete(relay)
|
|
523
|
-
puts "close relay" if @is_debug
|
|
524
|
-
set_girl_closing(relay_info[:girl]) if relay_info
|
|
525
|
-
relay_info
|
|
526
|
-
end
|
|
527
|
-
|
|
528
478
|
def close_rsv(rsv)
|
|
529
479
|
return nil if rsv.nil? || rsv.closed?
|
|
530
480
|
close_sock(rsv)
|
|
531
481
|
rsv_info = @rsv_infos.delete(rsv)
|
|
532
|
-
|
|
482
|
+
|
|
483
|
+
if rsv_info
|
|
484
|
+
domain = rsv_info[:domain]
|
|
485
|
+
puts "close rsv #{domain}" if @is_debug
|
|
486
|
+
end
|
|
487
|
+
|
|
533
488
|
rsv_info
|
|
534
489
|
end
|
|
535
490
|
|
|
@@ -546,23 +501,50 @@ module Girl
|
|
|
546
501
|
return nil if src.nil? || src.closed?
|
|
547
502
|
close_sock(src)
|
|
548
503
|
src_info = @src_infos.delete(src)
|
|
549
|
-
src_id = src_info[:src_id]
|
|
550
|
-
domain = src_info[:destination_domain]
|
|
551
|
-
puts "close src #{domain}" if @is_debug
|
|
552
504
|
|
|
553
|
-
if src_info
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
505
|
+
if src_info
|
|
506
|
+
src_id = src_info[:src_id]
|
|
507
|
+
domain = src_info[:destination_domain]
|
|
508
|
+
proxy_type = src_info[:proxy_type]
|
|
509
|
+
puts "close src #{domain}" if @is_debug
|
|
510
|
+
|
|
511
|
+
if proxy_type == :direct
|
|
512
|
+
set_dst_closing(src_info[:dst])
|
|
513
|
+
elsif proxy_type == :remote
|
|
514
|
+
puts "add h_src_close #{src_id}" if @is_debug
|
|
515
|
+
msg = "#{@h_src_close}#{[src_id].pack('Q>')}"
|
|
516
|
+
add_proxy_wbuff(pack_a_chunk(msg))
|
|
517
|
+
end
|
|
561
518
|
end
|
|
562
519
|
|
|
563
520
|
src_info
|
|
564
521
|
end
|
|
565
522
|
|
|
523
|
+
def deal_big_msg(data)
|
|
524
|
+
return if data.nil? || data.empty? || @big.closed?
|
|
525
|
+
big_info = @big_infos[@big]
|
|
526
|
+
now = Time.new
|
|
527
|
+
big_info[:recv_at] = now
|
|
528
|
+
h = data[0]
|
|
529
|
+
|
|
530
|
+
case h
|
|
531
|
+
when @h_p2_traffic
|
|
532
|
+
return if data.bytesize < 9
|
|
533
|
+
p2_id = data[1, 8].unpack('Q>').first
|
|
534
|
+
data = data[9..-1]
|
|
535
|
+
# puts "big got h_p2_traffic #{p2_id} #{data.bytesize}" if @is_debug
|
|
536
|
+
p1, _ = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
537
|
+
add_p1_wbuff(p1, data)
|
|
538
|
+
when @h_traffic
|
|
539
|
+
return if data.bytesize < 9
|
|
540
|
+
src_id = data[1, 8].unpack('Q>').first
|
|
541
|
+
data = data[9..-1]
|
|
542
|
+
# puts "big got h_traffic #{src_id} #{data.bytesize}" if @is_debug
|
|
543
|
+
src, _ = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
544
|
+
add_src_wbuff(src, data)
|
|
545
|
+
end
|
|
546
|
+
end
|
|
547
|
+
|
|
566
548
|
def deal_msg(data)
|
|
567
549
|
return if data.nil? || data.empty? || @proxy.closed?
|
|
568
550
|
proxy_info = @proxy_infos[@proxy]
|
|
@@ -582,8 +564,6 @@ module Girl
|
|
|
582
564
|
puts "got h_dst_close #{src_id}" if @is_debug
|
|
583
565
|
src, _ = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
584
566
|
set_src_closing(src)
|
|
585
|
-
when @h_heartbeat
|
|
586
|
-
puts "got h_heartbeat" if @is_debug
|
|
587
567
|
when @h_p2_close
|
|
588
568
|
return if data.bytesize < 9
|
|
589
569
|
p2_id = data[1, 8].unpack('Q>').first
|
|
@@ -594,22 +574,8 @@ module Girl
|
|
|
594
574
|
return if data.bytesize < 9
|
|
595
575
|
p2_id = data[1, 8].unpack('Q>').first
|
|
596
576
|
data = data[9..-1]
|
|
597
|
-
# puts "got h_p2_traffic #{p2_id} #{data.bytesize}" if @is_debug
|
|
598
577
|
p1, _ = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
599
578
|
add_p1_wbuff(p1, data)
|
|
600
|
-
when @h_p2_overflow
|
|
601
|
-
return if data.bytesize < 9
|
|
602
|
-
p2_id = data[1, 8].unpack('Q>').first
|
|
603
|
-
puts "got h_p2_overflow pause p1 #{p2_id}"
|
|
604
|
-
p1, _ = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
605
|
-
@reads.delete(p1)
|
|
606
|
-
proxy_info[:paused_p1s].delete(p1)
|
|
607
|
-
when @h_p2_underhalf
|
|
608
|
-
return if data.bytesize < 9
|
|
609
|
-
p2_id = data[1, 8].unpack('Q>').first
|
|
610
|
-
puts "got h_p2_underhalf #{p2_id}"
|
|
611
|
-
p1, _ = @p1_infos.find{|_, info| info[:p2_id] == p2_id}
|
|
612
|
-
add_read(p1)
|
|
613
579
|
when @h_response
|
|
614
580
|
return if data.bytesize < 3
|
|
615
581
|
near_id = data[1, 8].unpack('Q>').first
|
|
@@ -643,22 +609,8 @@ module Girl
|
|
|
643
609
|
return if data.bytesize < 9
|
|
644
610
|
src_id = data[1, 8].unpack('Q>').first
|
|
645
611
|
data = data[9..-1]
|
|
646
|
-
# puts "got h_traffic #{src_id} #{data.bytesize}" if @is_debug
|
|
647
612
|
src, _ = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
648
613
|
add_src_wbuff(src, data)
|
|
649
|
-
when @h_dst_overflow
|
|
650
|
-
return if data.bytesize < 9
|
|
651
|
-
src_id = data[1, 8].unpack('Q>').first
|
|
652
|
-
puts "got h_dst_overflow pause src #{src_id}"
|
|
653
|
-
src, _ = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
654
|
-
@reads.delete(src)
|
|
655
|
-
proxy_info[:paused_srcs].delete(src)
|
|
656
|
-
when @h_dst_underhalf
|
|
657
|
-
return if data.bytesize < 9
|
|
658
|
-
src_id = data[1, 8].unpack('Q>').first
|
|
659
|
-
puts "got h_dst_underhalf #{src_id}"
|
|
660
|
-
src, _ = @src_infos.find{|_, info| info[:src_id] == src_id}
|
|
661
|
-
add_read(src)
|
|
662
614
|
end
|
|
663
615
|
end
|
|
664
616
|
|
|
@@ -708,7 +660,7 @@ module Girl
|
|
|
708
660
|
domain = src_info[:destination_domain]
|
|
709
661
|
port = src_info[:destination_port]
|
|
710
662
|
|
|
711
|
-
if @local_ips.include?(ip) && [@redir_port, @
|
|
663
|
+
if @local_ips.include?(ip) && [@redir_port, @tspd_port].include?(port)
|
|
712
664
|
puts "ignore #{ip}:#{port}"
|
|
713
665
|
close_src(src)
|
|
714
666
|
return
|
|
@@ -742,6 +694,39 @@ module Girl
|
|
|
742
694
|
end
|
|
743
695
|
end
|
|
744
696
|
|
|
697
|
+
def new_a_big
|
|
698
|
+
big = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
|
699
|
+
big.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
700
|
+
|
|
701
|
+
if @is_client_fastopen
|
|
702
|
+
big.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_FASTOPEN, 5)
|
|
703
|
+
else
|
|
704
|
+
begin
|
|
705
|
+
big.connect_nonblock(@bigd_addr)
|
|
706
|
+
rescue IO::WaitWritable
|
|
707
|
+
rescue Exception => e
|
|
708
|
+
puts "connect bigd #{e.class}"
|
|
709
|
+
big.close
|
|
710
|
+
return
|
|
711
|
+
end
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
puts "big im #{@im}"
|
|
715
|
+
chars = []
|
|
716
|
+
@head_len.times{chars << rand(256)}
|
|
717
|
+
head = "#{chars.pack('C*')}#{[@im.bytesize].pack('C')}#{@im}"
|
|
718
|
+
@big = big
|
|
719
|
+
@big_infos[big] = {
|
|
720
|
+
is_syn: @is_client_fastopen,
|
|
721
|
+
overflowing: false,
|
|
722
|
+
rbuff: '',
|
|
723
|
+
recv_at: Time.new,
|
|
724
|
+
wbuff: head
|
|
725
|
+
}
|
|
726
|
+
add_read(big, :big)
|
|
727
|
+
add_write(big)
|
|
728
|
+
end
|
|
729
|
+
|
|
745
730
|
def new_a_dst(ip, src)
|
|
746
731
|
return if src.nil? || src.closed?
|
|
747
732
|
src_info = @src_infos[src]
|
|
@@ -770,7 +755,7 @@ module Girl
|
|
|
770
755
|
return
|
|
771
756
|
end
|
|
772
757
|
|
|
773
|
-
|
|
758
|
+
@dst_infos[dst] = {
|
|
774
759
|
closing: false,
|
|
775
760
|
connected: false,
|
|
776
761
|
domain: domain,
|
|
@@ -780,8 +765,6 @@ module Girl
|
|
|
780
765
|
src: src,
|
|
781
766
|
wbuff: ''
|
|
782
767
|
}
|
|
783
|
-
|
|
784
|
-
@dst_infos[dst] = dst_info
|
|
785
768
|
src_info[:proxy_type] = :direct
|
|
786
769
|
src_info[:dst] = dst
|
|
787
770
|
|
|
@@ -805,45 +788,6 @@ module Girl
|
|
|
805
788
|
end
|
|
806
789
|
end
|
|
807
790
|
|
|
808
|
-
def new_a_girl(relay)
|
|
809
|
-
return if relay.nil? || relay.closed?
|
|
810
|
-
check_expire_girls
|
|
811
|
-
|
|
812
|
-
begin
|
|
813
|
-
girl = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
|
814
|
-
rescue Exception => e
|
|
815
|
-
puts "new a girl #{e.class}"
|
|
816
|
-
close_girl(girl)
|
|
817
|
-
return
|
|
818
|
-
end
|
|
819
|
-
|
|
820
|
-
girl.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
821
|
-
|
|
822
|
-
begin
|
|
823
|
-
girl.connect_nonblock(@proxyd_addr)
|
|
824
|
-
rescue IO::WaitWritable
|
|
825
|
-
rescue Exception => e
|
|
826
|
-
puts "girl connect proxyd #{e.class}"
|
|
827
|
-
girl.close
|
|
828
|
-
close_girl(girl)
|
|
829
|
-
return
|
|
830
|
-
end
|
|
831
|
-
|
|
832
|
-
girl_info = {
|
|
833
|
-
closing: false,
|
|
834
|
-
connected: false,
|
|
835
|
-
is_syn: @is_client_fastopen,
|
|
836
|
-
overflowing: false,
|
|
837
|
-
relay: relay,
|
|
838
|
-
wbuff: ''
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
@girl_infos[girl] = girl_info
|
|
842
|
-
add_read(girl, :girl)
|
|
843
|
-
add_write(girl)
|
|
844
|
-
girl
|
|
845
|
-
end
|
|
846
|
-
|
|
847
791
|
def new_a_infod(infod_port)
|
|
848
792
|
infod_host = '127.0.0.1'
|
|
849
793
|
infod_addr = Socket.sockaddr_in(infod_port, infod_host)
|
|
@@ -891,15 +835,15 @@ module Girl
|
|
|
891
835
|
return
|
|
892
836
|
end
|
|
893
837
|
|
|
894
|
-
|
|
838
|
+
@p1_infos[p1] = {
|
|
895
839
|
closing: false,
|
|
896
840
|
connected: false,
|
|
841
|
+
in: 0,
|
|
842
|
+
is_big: false,
|
|
897
843
|
overflowing: false,
|
|
898
844
|
p2_id: p2_id,
|
|
899
845
|
wbuff: ''
|
|
900
846
|
}
|
|
901
|
-
|
|
902
|
-
@p1_infos[p1] = p1_info
|
|
903
847
|
add_read(p1, :p1)
|
|
904
848
|
add_write(p1)
|
|
905
849
|
end
|
|
@@ -921,25 +865,19 @@ module Girl
|
|
|
921
865
|
end
|
|
922
866
|
end
|
|
923
867
|
|
|
924
|
-
puts "im #{@im}"
|
|
868
|
+
puts "proxy im #{@im}"
|
|
925
869
|
chars = []
|
|
926
870
|
@head_len.times{chars << rand(256)}
|
|
927
871
|
head = "#{chars.pack('C*')}#{[@im.bytesize].pack('C')}#{@im}"
|
|
928
|
-
|
|
929
|
-
|
|
872
|
+
@proxy = proxy
|
|
873
|
+
@proxy_infos[proxy] = {
|
|
930
874
|
is_syn: @is_client_fastopen,
|
|
931
|
-
paused_p1s: [],
|
|
932
|
-
paused_srcs: [],
|
|
933
875
|
rbuff: '',
|
|
934
|
-
recv_at:
|
|
876
|
+
recv_at: Time.new,
|
|
935
877
|
wbuff: head
|
|
936
878
|
}
|
|
937
|
-
|
|
938
|
-
@proxy = proxy
|
|
939
|
-
@proxy_infos[proxy] = proxy_info
|
|
940
879
|
add_read(proxy, :proxy)
|
|
941
880
|
add_write(proxy)
|
|
942
|
-
proxy_info
|
|
943
881
|
end
|
|
944
882
|
|
|
945
883
|
def new_a_redir(redir_host, redir_port)
|
|
@@ -956,19 +894,6 @@ module Girl
|
|
|
956
894
|
@redir_local_address = redir.local_address
|
|
957
895
|
end
|
|
958
896
|
|
|
959
|
-
def new_a_relayd(relayd_host, relayd_port)
|
|
960
|
-
relayd = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
|
961
|
-
relayd.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
962
|
-
relayd.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
|
|
963
|
-
relayd.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, 1) if RUBY_PLATFORM.include?('linux')
|
|
964
|
-
relayd.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_FASTOPEN, BACKLOG) if @is_server_fastopen
|
|
965
|
-
relayd.bind(Socket.sockaddr_in(relayd_port, relayd_host))
|
|
966
|
-
relayd.listen(BACKLOG)
|
|
967
|
-
puts "relayd listen on #{relayd_host} #{relayd_port}"
|
|
968
|
-
add_read(relayd, :relayd)
|
|
969
|
-
@relayd_port = relayd_port
|
|
970
|
-
end
|
|
971
|
-
|
|
972
897
|
def new_a_rsv(data, addrinfo, domain, type)
|
|
973
898
|
check_expire_rsvs
|
|
974
899
|
rsv = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
|
|
@@ -981,13 +906,11 @@ module Girl
|
|
|
981
906
|
return
|
|
982
907
|
end
|
|
983
908
|
|
|
984
|
-
|
|
909
|
+
@rsv_infos[rsv] = {
|
|
985
910
|
addrinfo: addrinfo,
|
|
986
911
|
domain: domain,
|
|
987
912
|
type: type
|
|
988
913
|
}
|
|
989
|
-
|
|
990
|
-
@rsv_infos[rsv] = rsv_info
|
|
991
914
|
add_read(rsv, :rsv)
|
|
992
915
|
end
|
|
993
916
|
|
|
@@ -1023,7 +946,6 @@ module Girl
|
|
|
1023
946
|
|
|
1024
947
|
loop do
|
|
1025
948
|
part = data[0, 65526]
|
|
1026
|
-
# puts "add h_p2_traffic #{p2_id} #{part.bytesize}" if @is_debug
|
|
1027
949
|
msg = "#{@h_p2_traffic}#{[p2_id].pack('Q>')}#{part}"
|
|
1028
950
|
chunks << pack_a_chunk(msg)
|
|
1029
951
|
data = data[part.bytesize..-1]
|
|
@@ -1038,7 +960,6 @@ module Girl
|
|
|
1038
960
|
|
|
1039
961
|
loop do
|
|
1040
962
|
part = data[0, 65526]
|
|
1041
|
-
# puts "add h_traffic #{src_id} #{part.bytesize}" if @is_debug
|
|
1042
963
|
msg = "#{@h_traffic}#{[src_id].pack('Q>')}#{part}"
|
|
1043
964
|
chunks << pack_a_chunk(msg)
|
|
1044
965
|
data = data[part.bytesize..-1]
|
|
@@ -1048,6 +969,25 @@ module Girl
|
|
|
1048
969
|
chunks
|
|
1049
970
|
end
|
|
1050
971
|
|
|
972
|
+
def read_big(big)
|
|
973
|
+
begin
|
|
974
|
+
data = big.read_nonblock(READ_SIZE)
|
|
975
|
+
rescue Errno::ENOTCONN => e
|
|
976
|
+
return
|
|
977
|
+
rescue Exception => e
|
|
978
|
+
puts "read big #{e.class}" if @is_debug
|
|
979
|
+
close_big(big)
|
|
980
|
+
return
|
|
981
|
+
end
|
|
982
|
+
|
|
983
|
+
set_update(big)
|
|
984
|
+
big_info = @big_infos[big]
|
|
985
|
+
data = "#{big_info[:rbuff]}#{data}"
|
|
986
|
+
msgs, part = decode_to_msgs(data)
|
|
987
|
+
msgs.each{|msg| deal_big_msg(msg)}
|
|
988
|
+
big_info[:rbuff] = part
|
|
989
|
+
end
|
|
990
|
+
|
|
1051
991
|
def read_dns(dns)
|
|
1052
992
|
begin
|
|
1053
993
|
data, addrinfo, rflags, *controls = dns.recvmsg
|
|
@@ -1089,33 +1029,17 @@ module Girl
|
|
|
1089
1029
|
rescue Errno::ENOTCONN => e
|
|
1090
1030
|
return
|
|
1091
1031
|
rescue Exception => e
|
|
1032
|
+
puts "read dst #{e.class}" if @is_debug
|
|
1092
1033
|
close_dst(dst)
|
|
1093
1034
|
return
|
|
1094
1035
|
end
|
|
1095
1036
|
|
|
1096
1037
|
set_update(dst)
|
|
1097
1038
|
dst_info = @dst_infos[dst]
|
|
1098
|
-
# puts "read dst #{dst_info[:domain]} #{data.bytesize}" if @is_debug
|
|
1099
1039
|
src = dst_info[:src]
|
|
1100
1040
|
add_src_wbuff(src, data)
|
|
1101
1041
|
end
|
|
1102
1042
|
|
|
1103
|
-
def read_girl(girl)
|
|
1104
|
-
begin
|
|
1105
|
-
data = girl.read_nonblock(READ_SIZE)
|
|
1106
|
-
rescue Errno::ENOTCONN => e
|
|
1107
|
-
return
|
|
1108
|
-
rescue Exception => e
|
|
1109
|
-
close_girl(girl)
|
|
1110
|
-
return
|
|
1111
|
-
end
|
|
1112
|
-
|
|
1113
|
-
set_update(girl)
|
|
1114
|
-
girl_info = @girl_infos[girl]
|
|
1115
|
-
relay = girl_info[:relay]
|
|
1116
|
-
add_relay_wbuff(relay, data)
|
|
1117
|
-
end
|
|
1118
|
-
|
|
1119
1043
|
def read_infod(infod)
|
|
1120
1044
|
begin
|
|
1121
1045
|
data, addrinfo, rflags, *controls = infod.recvmsg
|
|
@@ -1137,18 +1061,26 @@ module Girl
|
|
|
1137
1061
|
|
|
1138
1062
|
case message_type
|
|
1139
1063
|
when 'heartbeat'
|
|
1140
|
-
if @proxy.closed?
|
|
1064
|
+
new_a_proxy if @proxy.closed?
|
|
1065
|
+
new_a_big if @big.closed?
|
|
1066
|
+
proxy_info = @proxy_infos[@proxy]
|
|
1067
|
+
|
|
1068
|
+
if Time.new.to_i - proxy_info[:recv_at].to_i >= @expire_proxy_after
|
|
1069
|
+
puts "renew proxy"
|
|
1070
|
+
close_proxy(@proxy)
|
|
1141
1071
|
new_a_proxy
|
|
1142
1072
|
else
|
|
1143
|
-
|
|
1073
|
+
add_proxy_wbuff(pack_a_chunk(@h_heartbeat))
|
|
1074
|
+
end
|
|
1144
1075
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1076
|
+
big_info = @big_infos[@big]
|
|
1077
|
+
|
|
1078
|
+
if Time.new.to_i - big_info[:recv_at].to_i >= @expire_proxy_after
|
|
1079
|
+
puts "renew big"
|
|
1080
|
+
close_big(@big)
|
|
1081
|
+
new_a_big
|
|
1082
|
+
else
|
|
1083
|
+
add_big_wbuff(pack_a_chunk(@h_heartbeat))
|
|
1152
1084
|
end
|
|
1153
1085
|
end
|
|
1154
1086
|
end
|
|
@@ -1186,9 +1118,8 @@ module Girl
|
|
|
1186
1118
|
roles: @roles.size,
|
|
1187
1119
|
updates: @updates.size,
|
|
1188
1120
|
proxy_infos: @proxy_infos.size,
|
|
1121
|
+
big_infos: @big_infos.size,
|
|
1189
1122
|
mem_infos: @mem_infos.size,
|
|
1190
|
-
relay_infos: @relay_infos.size,
|
|
1191
|
-
girl_infos: @girl_infos.size,
|
|
1192
1123
|
src_infos: @src_infos.size,
|
|
1193
1124
|
dst_infos: @dst_infos.size,
|
|
1194
1125
|
dns_infos: @dns_infos.size,
|
|
@@ -1232,6 +1163,7 @@ module Girl
|
|
|
1232
1163
|
rescue Errno::ENOTCONN => e
|
|
1233
1164
|
return
|
|
1234
1165
|
rescue Exception => e
|
|
1166
|
+
puts "read p1 #{e.class}" if @is_debug
|
|
1235
1167
|
close_p1(p1)
|
|
1236
1168
|
return
|
|
1237
1169
|
end
|
|
@@ -1244,19 +1176,20 @@ module Girl
|
|
|
1244
1176
|
end
|
|
1245
1177
|
|
|
1246
1178
|
p1_info = @p1_infos[p1]
|
|
1179
|
+
p1_info[:in] += data.bytesize
|
|
1247
1180
|
p2_id = p1_info[:p2_id]
|
|
1248
|
-
# puts "read p1 #{p2_id} #{data.bytesize}" if @is_debug
|
|
1249
|
-
add_proxy_wbuff(pack_p2_traffic(p2_id, data))
|
|
1250
1181
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1182
|
+
if !p1_info[:is_big] && (p1_info[:in] >= READ_SIZE)
|
|
1183
|
+
puts "set p1 is big #{p2_id}"
|
|
1184
|
+
p1_info[:is_big] = true
|
|
1185
|
+
end
|
|
1254
1186
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1187
|
+
data = pack_p2_traffic(p2_id, data)
|
|
1188
|
+
|
|
1189
|
+
if p1_info[:is_big]
|
|
1190
|
+
add_big_wbuff(data)
|
|
1191
|
+
else
|
|
1192
|
+
add_proxy_wbuff(data)
|
|
1260
1193
|
end
|
|
1261
1194
|
end
|
|
1262
1195
|
|
|
@@ -1266,6 +1199,7 @@ module Girl
|
|
|
1266
1199
|
rescue Errno::ENOTCONN => e
|
|
1267
1200
|
return
|
|
1268
1201
|
rescue Exception => e
|
|
1202
|
+
puts "read proxy #{e.class}" if @is_debug
|
|
1269
1203
|
close_proxy(proxy)
|
|
1270
1204
|
return
|
|
1271
1205
|
end
|
|
@@ -1273,7 +1207,6 @@ module Girl
|
|
|
1273
1207
|
set_update(proxy)
|
|
1274
1208
|
proxy_info = @proxy_infos[proxy]
|
|
1275
1209
|
data = "#{proxy_info[:rbuff]}#{data}"
|
|
1276
|
-
|
|
1277
1210
|
msgs, part = decode_to_msgs(data)
|
|
1278
1211
|
msgs.each{|msg| deal_msg(msg)}
|
|
1279
1212
|
proxy_info[:rbuff] = part
|
|
@@ -1291,13 +1224,14 @@ module Girl
|
|
|
1291
1224
|
|
|
1292
1225
|
puts "redir accept a src #{addrinfo.ip_unpack.inspect}" if @is_debug
|
|
1293
1226
|
src_id = rand((2 ** 64) - 2) + 1
|
|
1294
|
-
|
|
1295
|
-
src_info = {
|
|
1227
|
+
@src_infos[src] = {
|
|
1296
1228
|
addrinfo: addrinfo,
|
|
1297
1229
|
closing: false,
|
|
1298
1230
|
destination_domain: nil,
|
|
1299
1231
|
destination_port: nil,
|
|
1300
1232
|
dst: nil,
|
|
1233
|
+
in: 0,
|
|
1234
|
+
is_big: false,
|
|
1301
1235
|
is_connect: true,
|
|
1302
1236
|
overflowing: false,
|
|
1303
1237
|
proxy_proto: :uncheck, # :uncheck / :http / :socks5
|
|
@@ -1306,52 +1240,9 @@ module Girl
|
|
|
1306
1240
|
src_id: src_id,
|
|
1307
1241
|
wbuff: ''
|
|
1308
1242
|
}
|
|
1309
|
-
|
|
1310
|
-
@src_infos[src] = src_info
|
|
1311
1243
|
add_read(src, :src)
|
|
1312
1244
|
end
|
|
1313
1245
|
|
|
1314
|
-
def read_relay(relay)
|
|
1315
|
-
begin
|
|
1316
|
-
data = relay.read_nonblock(READ_SIZE)
|
|
1317
|
-
rescue Errno::ENOTCONN => e
|
|
1318
|
-
return
|
|
1319
|
-
rescue Exception => e
|
|
1320
|
-
close_relay(relay)
|
|
1321
|
-
return
|
|
1322
|
-
end
|
|
1323
|
-
|
|
1324
|
-
set_update(relay)
|
|
1325
|
-
relay_info = @relay_infos[relay]
|
|
1326
|
-
girl = relay_info[:girl]
|
|
1327
|
-
add_girl_wbuff(girl, data)
|
|
1328
|
-
end
|
|
1329
|
-
|
|
1330
|
-
def read_relayd(relayd)
|
|
1331
|
-
check_expire_relays
|
|
1332
|
-
|
|
1333
|
-
begin
|
|
1334
|
-
relay, addrinfo = relayd.accept_nonblock
|
|
1335
|
-
rescue IO::WaitReadable, Errno::EINTR => e
|
|
1336
|
-
puts "relayd accept #{e.class}"
|
|
1337
|
-
return
|
|
1338
|
-
end
|
|
1339
|
-
|
|
1340
|
-
puts "relayd accept a relay #{addrinfo.ip_unpack.inspect}"
|
|
1341
|
-
|
|
1342
|
-
relay_info = {
|
|
1343
|
-
addrinfo: addrinfo,
|
|
1344
|
-
closing: false,
|
|
1345
|
-
girl: nil,
|
|
1346
|
-
overflowing: false,
|
|
1347
|
-
wbuff: ''
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
@relay_infos[relay] = relay_info
|
|
1351
|
-
add_read(relay, :relay)
|
|
1352
|
-
relay_info[:girl] = new_a_girl(relay)
|
|
1353
|
-
end
|
|
1354
|
-
|
|
1355
1246
|
def read_rsv(rsv)
|
|
1356
1247
|
begin
|
|
1357
1248
|
data, addrinfo, rflags, *controls = rsv.recvmsg
|
|
@@ -1439,16 +1330,13 @@ module Girl
|
|
|
1439
1330
|
if @remotes.any?{|r| domain.include?(r)}
|
|
1440
1331
|
check_expire_nears
|
|
1441
1332
|
near_id = rand((2 ** 64) - 2) + 1
|
|
1442
|
-
|
|
1443
|
-
near_info = {
|
|
1333
|
+
@near_infos[near_id] = {
|
|
1444
1334
|
addrinfo: addrinfo,
|
|
1445
1335
|
created_at: Time.new,
|
|
1446
1336
|
domain: domain,
|
|
1447
1337
|
id: id,
|
|
1448
1338
|
type: type
|
|
1449
1339
|
}
|
|
1450
|
-
|
|
1451
|
-
@near_infos[near_id] = near_info
|
|
1452
1340
|
puts "add h_query #{near_id} #{type} #{domain}" if @is_debug
|
|
1453
1341
|
msg = "#{@h_query}#{[near_id, type].pack('Q>C')}#{domain}"
|
|
1454
1342
|
add_proxy_wbuff(pack_a_chunk(msg))
|
|
@@ -1464,6 +1352,7 @@ module Girl
|
|
|
1464
1352
|
rescue Errno::ENOTCONN => e
|
|
1465
1353
|
return
|
|
1466
1354
|
rescue Exception => e
|
|
1355
|
+
puts "read src #{e.class}" if @is_debug
|
|
1467
1356
|
close_src(src)
|
|
1468
1357
|
return
|
|
1469
1358
|
end
|
|
@@ -1607,18 +1496,21 @@ module Girl
|
|
|
1607
1496
|
close_src(src)
|
|
1608
1497
|
end
|
|
1609
1498
|
when :remote
|
|
1610
|
-
|
|
1611
|
-
|
|
1499
|
+
src_info[:in] += data.bytesize
|
|
1500
|
+
domain = src_info[:destination_domain]
|
|
1612
1501
|
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1502
|
+
if !src_info[:is_big] && (src_info[:in] >= READ_SIZE)
|
|
1503
|
+
puts "set src is big #{domain}"
|
|
1504
|
+
src_info[:is_big] = true
|
|
1505
|
+
end
|
|
1616
1506
|
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1507
|
+
src_id = src_info[:src_id]
|
|
1508
|
+
data = pack_traffic(src_id, data)
|
|
1509
|
+
|
|
1510
|
+
if src_info[:is_big]
|
|
1511
|
+
add_big_wbuff(data)
|
|
1512
|
+
else
|
|
1513
|
+
add_proxy_wbuff(data)
|
|
1622
1514
|
end
|
|
1623
1515
|
when :direct
|
|
1624
1516
|
dst = src_info[:dst]
|
|
@@ -1657,8 +1549,7 @@ module Girl
|
|
|
1657
1549
|
dest_addrinfo = Addrinfo.new(dest_addr)
|
|
1658
1550
|
dest_ip = dest_addrinfo.ip_address
|
|
1659
1551
|
src_id = rand((2 ** 64) - 2) + 1
|
|
1660
|
-
|
|
1661
|
-
src_info = {
|
|
1552
|
+
@src_infos[src] = {
|
|
1662
1553
|
addrinfo: addrinfo,
|
|
1663
1554
|
closing: false,
|
|
1664
1555
|
destination_domain: dest_ip,
|
|
@@ -1672,8 +1563,6 @@ module Girl
|
|
|
1672
1563
|
src_id: src_id,
|
|
1673
1564
|
wbuff: ''
|
|
1674
1565
|
}
|
|
1675
|
-
|
|
1676
|
-
@src_infos[src] = src_info
|
|
1677
1566
|
add_read(src, :src)
|
|
1678
1567
|
make_tunnel(dest_ip, src)
|
|
1679
1568
|
end
|
|
@@ -1688,7 +1577,7 @@ module Girl
|
|
|
1688
1577
|
return
|
|
1689
1578
|
end
|
|
1690
1579
|
|
|
1691
|
-
domain =
|
|
1580
|
+
domain =' 127.0.0.1' if domain == 'localhost'
|
|
1692
1581
|
|
|
1693
1582
|
if domain =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}$/
|
|
1694
1583
|
# ipv4
|
|
@@ -1734,12 +1623,10 @@ module Girl
|
|
|
1734
1623
|
return
|
|
1735
1624
|
end
|
|
1736
1625
|
|
|
1737
|
-
|
|
1626
|
+
@dns_infos[dns] = {
|
|
1738
1627
|
domain: domain,
|
|
1739
1628
|
src: src
|
|
1740
1629
|
}
|
|
1741
|
-
|
|
1742
|
-
@dns_infos[dns] = dns_info
|
|
1743
1630
|
add_read(dns, :dns)
|
|
1744
1631
|
src_info = @src_infos[src]
|
|
1745
1632
|
src_info[:proxy_type] = :checking
|
|
@@ -1761,14 +1648,6 @@ module Girl
|
|
|
1761
1648
|
add_write(dst)
|
|
1762
1649
|
end
|
|
1763
1650
|
|
|
1764
|
-
def set_girl_closing(girl)
|
|
1765
|
-
return if girl.nil? || girl.closed?
|
|
1766
|
-
girl_info = @girl_infos[girl]
|
|
1767
|
-
return if girl_info.nil? || girl_info[:closing]
|
|
1768
|
-
girl_info[:closing] = true
|
|
1769
|
-
add_write(girl)
|
|
1770
|
-
end
|
|
1771
|
-
|
|
1772
1651
|
def set_p1_closing(p1)
|
|
1773
1652
|
return if p1.nil? || p1.closed?
|
|
1774
1653
|
p1_info = @p1_infos[p1]
|
|
@@ -1777,14 +1656,6 @@ module Girl
|
|
|
1777
1656
|
add_write(p1)
|
|
1778
1657
|
end
|
|
1779
1658
|
|
|
1780
|
-
def set_relay_closing(relay)
|
|
1781
|
-
return if relay.nil? || relay.closed?
|
|
1782
|
-
relay_info = @relay_infos[relay]
|
|
1783
|
-
return if relay_info.nil? || relay_info[:closing]
|
|
1784
|
-
relay_info[:closing] = true
|
|
1785
|
-
add_write(relay)
|
|
1786
|
-
end
|
|
1787
|
-
|
|
1788
1659
|
def set_remote(src)
|
|
1789
1660
|
return if src.nil? || src.closed?
|
|
1790
1661
|
|
|
@@ -1842,14 +1713,10 @@ module Girl
|
|
|
1842
1713
|
close_dns(_sock)
|
|
1843
1714
|
when :dst
|
|
1844
1715
|
close_dst(_sock)
|
|
1845
|
-
when :girl
|
|
1846
|
-
close_girl(_sock)
|
|
1847
1716
|
when :mem
|
|
1848
1717
|
close_mem(_sock)
|
|
1849
1718
|
when :p1
|
|
1850
1719
|
close_p1(_sock)
|
|
1851
|
-
when :relay
|
|
1852
|
-
close_relay(_sock)
|
|
1853
1720
|
when :rsv
|
|
1854
1721
|
close_rsv(_sock)
|
|
1855
1722
|
when :src
|
|
@@ -1863,100 +1730,113 @@ module Girl
|
|
|
1863
1730
|
end
|
|
1864
1731
|
end
|
|
1865
1732
|
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1733
|
+
def write_big(big)
|
|
1734
|
+
big_info = @big_infos[big]
|
|
1735
|
+
|
|
1736
|
+
unless big_info
|
|
1737
|
+
puts "big info not found delete big"
|
|
1738
|
+
@writes.delete(big)
|
|
1869
1739
|
return
|
|
1870
1740
|
end
|
|
1871
1741
|
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
data =
|
|
1742
|
+
return if @writes.include?(@proxy)
|
|
1743
|
+
|
|
1744
|
+
data = big_info[:wbuff]
|
|
1875
1745
|
|
|
1876
1746
|
if data.empty?
|
|
1877
|
-
|
|
1878
|
-
close_dst(dst)
|
|
1879
|
-
else
|
|
1880
|
-
@writes.delete(dst)
|
|
1881
|
-
end
|
|
1882
|
-
|
|
1747
|
+
@writes.delete(big)
|
|
1883
1748
|
return
|
|
1884
1749
|
end
|
|
1885
1750
|
|
|
1886
1751
|
begin
|
|
1887
|
-
|
|
1752
|
+
if big_info[:is_syn]
|
|
1753
|
+
written = big.sendmsg_nonblock(data, 536870912, @bigd_addr)
|
|
1754
|
+
big_info[:is_syn] = false
|
|
1755
|
+
else
|
|
1756
|
+
written = big.write_nonblock(data)
|
|
1757
|
+
end
|
|
1888
1758
|
rescue Errno::EINPROGRESS
|
|
1889
1759
|
return
|
|
1890
1760
|
rescue Exception => e
|
|
1891
|
-
|
|
1761
|
+
puts "write big #{e.class}" if @is_debug
|
|
1762
|
+
close_big(big)
|
|
1892
1763
|
return
|
|
1893
1764
|
end
|
|
1894
1765
|
|
|
1895
|
-
set_update(
|
|
1766
|
+
set_update(big)
|
|
1896
1767
|
data = data[written..-1]
|
|
1897
|
-
|
|
1898
|
-
bytesize = dst_info[:wbuff].bytesize
|
|
1768
|
+
big_info[:wbuff] = data
|
|
1899
1769
|
|
|
1900
|
-
if
|
|
1901
|
-
puts "
|
|
1902
|
-
|
|
1903
|
-
|
|
1770
|
+
if big_info[:wbuff].empty? && big_info[:overflowing]
|
|
1771
|
+
puts "big empty"
|
|
1772
|
+
big_info[:overflowing] = false
|
|
1773
|
+
|
|
1774
|
+
@src_infos.select{|_, info| info[:is_big]}.each do |src, info|
|
|
1775
|
+
puts "resume src #{info[:destination_domain]}"
|
|
1776
|
+
add_read(src)
|
|
1777
|
+
end
|
|
1778
|
+
|
|
1779
|
+
@p1_infos.select{|_, info| info[:is_big]}.each do |p1, info|
|
|
1780
|
+
puts "resume p1 #{info[:p2_id]}"
|
|
1781
|
+
add_read(p1)
|
|
1782
|
+
end
|
|
1904
1783
|
end
|
|
1905
1784
|
end
|
|
1906
1785
|
|
|
1907
|
-
def
|
|
1908
|
-
|
|
1909
|
-
|
|
1786
|
+
def write_dst(dst)
|
|
1787
|
+
dst_info = @dst_infos[dst]
|
|
1788
|
+
|
|
1789
|
+
unless dst_info
|
|
1790
|
+
puts "dst info not found delete dst"
|
|
1791
|
+
@writes.delete(dst)
|
|
1910
1792
|
return
|
|
1911
1793
|
end
|
|
1912
1794
|
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
data = girl_info[:wbuff]
|
|
1795
|
+
dst_info[:connected] = true
|
|
1796
|
+
data = dst_info[:wbuff]
|
|
1916
1797
|
|
|
1917
1798
|
if data.empty?
|
|
1918
|
-
if
|
|
1919
|
-
|
|
1799
|
+
if dst_info[:closing]
|
|
1800
|
+
close_dst(dst)
|
|
1920
1801
|
else
|
|
1921
|
-
@writes.delete(
|
|
1802
|
+
@writes.delete(dst)
|
|
1922
1803
|
end
|
|
1923
1804
|
|
|
1924
1805
|
return
|
|
1925
1806
|
end
|
|
1926
1807
|
|
|
1927
1808
|
begin
|
|
1928
|
-
|
|
1929
|
-
written = girl.sendmsg_nonblock(data, 536870912, @proxyd_addr)
|
|
1930
|
-
girl_info[:is_syn] = false
|
|
1931
|
-
else
|
|
1932
|
-
written = girl.write_nonblock(data)
|
|
1933
|
-
end
|
|
1809
|
+
written = dst.write_nonblock(data)
|
|
1934
1810
|
rescue Errno::EINPROGRESS
|
|
1935
1811
|
return
|
|
1936
1812
|
rescue Exception => e
|
|
1937
|
-
|
|
1813
|
+
puts "write dst #{e.class}" if @is_debug
|
|
1814
|
+
close_dst(dst)
|
|
1938
1815
|
return
|
|
1939
1816
|
end
|
|
1940
1817
|
|
|
1941
|
-
set_update(
|
|
1818
|
+
set_update(dst)
|
|
1942
1819
|
data = data[written..-1]
|
|
1943
|
-
|
|
1944
|
-
|
|
1820
|
+
dst_info[:wbuff] = data
|
|
1821
|
+
domain = dst_info[:domain]
|
|
1945
1822
|
|
|
1946
|
-
if
|
|
1947
|
-
puts "
|
|
1948
|
-
|
|
1949
|
-
|
|
1823
|
+
if dst_info[:overflowing] && dst_info[:wbuff].empty?
|
|
1824
|
+
puts "dst empty #{domain}"
|
|
1825
|
+
dst_info[:overflowing] = false
|
|
1826
|
+
puts "resume src"
|
|
1827
|
+
add_read(dst_info[:src])
|
|
1950
1828
|
end
|
|
1951
1829
|
end
|
|
1952
1830
|
|
|
1953
1831
|
def write_mem(mem)
|
|
1954
|
-
|
|
1955
|
-
|
|
1832
|
+
mem_info = @mem_infos[mem]
|
|
1833
|
+
|
|
1834
|
+
unless mem_info
|
|
1835
|
+
puts "mem info not found delete mem"
|
|
1836
|
+
@writes.delete(mem)
|
|
1956
1837
|
return
|
|
1957
1838
|
end
|
|
1958
1839
|
|
|
1959
|
-
mem_info = @mem_infos[mem]
|
|
1960
1840
|
data = mem_info[:wbuff]
|
|
1961
1841
|
|
|
1962
1842
|
if data.empty?
|
|
@@ -1980,12 +1860,14 @@ module Girl
|
|
|
1980
1860
|
end
|
|
1981
1861
|
|
|
1982
1862
|
def write_p1(p1)
|
|
1983
|
-
|
|
1984
|
-
|
|
1863
|
+
p1_info = @p1_infos[p1]
|
|
1864
|
+
|
|
1865
|
+
unless p1_info
|
|
1866
|
+
puts "p1 info not found delete p1"
|
|
1867
|
+
@writes.delete(p1)
|
|
1985
1868
|
return
|
|
1986
1869
|
end
|
|
1987
1870
|
|
|
1988
|
-
p1_info = @p1_infos[p1]
|
|
1989
1871
|
p1_info[:connected] = true
|
|
1990
1872
|
data = p1_info[:wbuff]
|
|
1991
1873
|
|
|
@@ -2004,6 +1886,7 @@ module Girl
|
|
|
2004
1886
|
rescue Errno::EINPROGRESS
|
|
2005
1887
|
return
|
|
2006
1888
|
rescue Exception => e
|
|
1889
|
+
puts "write p1 #{e.class}" if @is_debug
|
|
2007
1890
|
close_p1(p1)
|
|
2008
1891
|
return
|
|
2009
1892
|
end
|
|
@@ -2011,24 +1894,25 @@ module Girl
|
|
|
2011
1894
|
set_update(p1)
|
|
2012
1895
|
data = data[written..-1]
|
|
2013
1896
|
p1_info[:wbuff] = data
|
|
2014
|
-
|
|
1897
|
+
p2_id = p1_info[:p2_id]
|
|
2015
1898
|
|
|
2016
|
-
if p1_info[:overflowing] &&
|
|
2017
|
-
|
|
2018
|
-
puts "add h_p1_underhalf #{p2_id}"
|
|
2019
|
-
msg = "#{@h_p1_underhalf}#{[p2_id].pack('Q>')}"
|
|
2020
|
-
add_proxy_wbuff(pack_a_chunk(msg))
|
|
1899
|
+
if p1_info[:overflowing] && p1_info[:wbuff].empty?
|
|
1900
|
+
puts "p1 empty #{p2_id}"
|
|
2021
1901
|
p1_info[:overflowing] = false
|
|
1902
|
+
puts "resume big"
|
|
1903
|
+
add_read(@big)
|
|
2022
1904
|
end
|
|
2023
1905
|
end
|
|
2024
1906
|
|
|
2025
1907
|
def write_proxy(proxy)
|
|
2026
|
-
|
|
2027
|
-
|
|
1908
|
+
proxy_info = @proxy_infos[proxy]
|
|
1909
|
+
|
|
1910
|
+
unless proxy_info
|
|
1911
|
+
puts "proxy info not found delete proxy"
|
|
1912
|
+
@writes.delete(proxy)
|
|
2028
1913
|
return
|
|
2029
1914
|
end
|
|
2030
1915
|
|
|
2031
|
-
proxy_info = @proxy_infos[proxy]
|
|
2032
1916
|
data = proxy_info[:wbuff]
|
|
2033
1917
|
|
|
2034
1918
|
if data.empty?
|
|
@@ -2054,30 +1938,17 @@ module Girl
|
|
|
2054
1938
|
set_update(proxy)
|
|
2055
1939
|
data = data[written..-1]
|
|
2056
1940
|
proxy_info[:wbuff] = data
|
|
2057
|
-
bytesize = proxy_info[:wbuff].bytesize
|
|
2058
|
-
|
|
2059
|
-
if bytesize < RESUME_BELOW
|
|
2060
|
-
if proxy_info[:paused_srcs].any?
|
|
2061
|
-
puts "proxy underhalf resume srcs #{proxy_info[:paused_srcs].size}"
|
|
2062
|
-
proxy_info[:paused_srcs].each{|src| add_read(src)}
|
|
2063
|
-
proxy_info[:paused_srcs].clear
|
|
2064
|
-
end
|
|
2065
|
-
|
|
2066
|
-
if proxy_info[:paused_p1s].any?
|
|
2067
|
-
puts "proxy underhalf resume p1s #{proxy_info[:paused_p1s].size}"
|
|
2068
|
-
proxy_info[:paused_p1s].each{|p1| add_read(p1)}
|
|
2069
|
-
proxy_info[:paused_p1s].clear
|
|
2070
|
-
end
|
|
2071
|
-
end
|
|
2072
1941
|
end
|
|
2073
1942
|
|
|
2074
1943
|
def write_src(src)
|
|
2075
|
-
|
|
2076
|
-
|
|
1944
|
+
src_info = @src_infos[src]
|
|
1945
|
+
|
|
1946
|
+
unless src_info
|
|
1947
|
+
puts "src info not found delete src"
|
|
1948
|
+
@writes.delete(src)
|
|
2077
1949
|
return
|
|
2078
1950
|
end
|
|
2079
1951
|
|
|
2080
|
-
src_info = @src_infos[src]
|
|
2081
1952
|
data = src_info[:wbuff]
|
|
2082
1953
|
|
|
2083
1954
|
if data.empty?
|
|
@@ -2095,6 +1966,7 @@ module Girl
|
|
|
2095
1966
|
rescue Errno::EINPROGRESS
|
|
2096
1967
|
return
|
|
2097
1968
|
rescue Exception => e
|
|
1969
|
+
puts "write src #{e.class}" if @is_debug
|
|
2098
1970
|
close_src(src)
|
|
2099
1971
|
return
|
|
2100
1972
|
end
|
|
@@ -2102,62 +1974,19 @@ module Girl
|
|
|
2102
1974
|
set_update(src)
|
|
2103
1975
|
data = data[written..-1]
|
|
2104
1976
|
src_info[:wbuff] = data
|
|
2105
|
-
bytesize = src_info[:wbuff].bytesize
|
|
2106
1977
|
|
|
2107
|
-
if src_info[:
|
|
2108
|
-
src_id = src_info[:src_id]
|
|
1978
|
+
if src_info[:wbuff].empty? && src_info[:overflowing]
|
|
2109
1979
|
domain = src_info[:destination_domain]
|
|
1980
|
+
puts "src empty #{domain}"
|
|
1981
|
+
src_info[:overflowing] = false
|
|
2110
1982
|
|
|
2111
1983
|
if src_info[:proxy_type] == :direct
|
|
2112
|
-
puts "
|
|
1984
|
+
puts "resume dst"
|
|
2113
1985
|
add_read(src_info[:dst])
|
|
2114
1986
|
else
|
|
2115
|
-
puts "
|
|
2116
|
-
|
|
2117
|
-
add_proxy_wbuff(pack_a_chunk(msg))
|
|
2118
|
-
end
|
|
2119
|
-
|
|
2120
|
-
src_info[:overflowing] = false
|
|
2121
|
-
end
|
|
2122
|
-
end
|
|
2123
|
-
|
|
2124
|
-
def write_relay(relay)
|
|
2125
|
-
if relay.closed?
|
|
2126
|
-
puts "write closed relay?"
|
|
2127
|
-
return
|
|
2128
|
-
end
|
|
2129
|
-
|
|
2130
|
-
relay_info = @relay_infos[relay]
|
|
2131
|
-
data = relay_info[:wbuff]
|
|
2132
|
-
|
|
2133
|
-
if data.empty?
|
|
2134
|
-
if relay_info[:closing]
|
|
2135
|
-
close_relay(relay)
|
|
2136
|
-
else
|
|
2137
|
-
@writes.delete(relay)
|
|
1987
|
+
puts "resume big"
|
|
1988
|
+
add_read(@big)
|
|
2138
1989
|
end
|
|
2139
|
-
|
|
2140
|
-
return
|
|
2141
|
-
end
|
|
2142
|
-
|
|
2143
|
-
begin
|
|
2144
|
-
written = relay.write_nonblock(data)
|
|
2145
|
-
rescue Errno::EINPROGRESS
|
|
2146
|
-
return
|
|
2147
|
-
rescue Exception => e
|
|
2148
|
-
close_relay(relay)
|
|
2149
|
-
return
|
|
2150
|
-
end
|
|
2151
|
-
|
|
2152
|
-
set_update(relay)
|
|
2153
|
-
data = data[written..-1]
|
|
2154
|
-
relay_info[:wbuff] = data
|
|
2155
|
-
bytesize = relay_info[:wbuff].bytesize
|
|
2156
|
-
|
|
2157
|
-
if relay_info[:overflowing] && (bytesize < RESUME_BELOW)
|
|
2158
|
-
puts "relay underhalf"
|
|
2159
|
-
add_read(relay_info[:girl])
|
|
2160
|
-
relay_info[:overflowing] = false
|
|
2161
1990
|
end
|
|
2162
1991
|
end
|
|
2163
1992
|
|