girl 0.87.1 → 0.88.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of girl might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/girl/proxy_worker.rb +35 -28
- data/lib/girl/proxyd_worker.rb +18 -19
- 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: b93e96a7869493e3817af21b5a482605adbe9be7a4d4156b14eed2a6b40c25d5
|
4
|
+
data.tar.gz: 4adea82e1e09ce9cb2b1da33f05618d8bd3837bd50bd452b8d99631e523a040b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d15c8e1104feb3079c6ee14af795adb319808c9899c6013b28cf3cf4d082b9c1feca3160d95cbf67beb88343a202a823b2e1b823591fcbc3abb7b040a19839
|
7
|
+
data.tar.gz: 8e1f3255a7c297e33dd0ee6931483584760198ba0559936ac213b62a900451a8658749ded5dc1ebb490ab45958a4e8c7a0bfea6756047955d358b4c4cafa6d6d
|
data/lib/girl/proxy_worker.rb
CHANGED
@@ -95,7 +95,7 @@ module Girl
|
|
95
95
|
sleep CHECK_EXPIRE_INTERVAL
|
96
96
|
|
97
97
|
@mutex.synchronize do
|
98
|
-
|
98
|
+
trigger = false
|
99
99
|
now = Time.new
|
100
100
|
|
101
101
|
if @tun && !@tun.closed?
|
@@ -104,7 +104,7 @@ module Girl
|
|
104
104
|
if is_expired
|
105
105
|
puts "p#{ Process.pid } #{ Time.new } expire tun"
|
106
106
|
set_is_closing( @tun )
|
107
|
-
|
107
|
+
trigger = true
|
108
108
|
else
|
109
109
|
data = [ 0, HEARTBEAT, rand( 128 ) ].pack( 'Q>CC' )
|
110
110
|
# puts "debug1 #{ Time.new } heartbeat"
|
@@ -117,7 +117,7 @@ module Girl
|
|
117
117
|
|
118
118
|
if src_info && ( now - src_info[ :last_continue_at ] > EXPIRE_AFTER )
|
119
119
|
puts "p#{ Process.pid } #{ Time.new } expire src ext #{ src_info[ :destination_domain ] }"
|
120
|
-
@tun_info[ :wmems ].delete_if { |
|
120
|
+
@tun_info[ :wmems ].delete_if { | src_id_pack_id, _ | src_id_pack_id.first == src_id }
|
121
121
|
@tun_info[ :src_ids ].delete( src_info[ :dst_id ] )
|
122
122
|
@src_infos.delete( src )
|
123
123
|
del_src_ids << src_id
|
@@ -135,7 +135,7 @@ module Girl
|
|
135
135
|
if now - src_info[ :last_continue_at ] > EXPIRE_AFTER
|
136
136
|
puts "p#{ Process.pid } #{ Time.new } expire src #{ src_info[ :destination_domain ] }"
|
137
137
|
set_is_closing( src )
|
138
|
-
|
138
|
+
trigger = true
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -143,11 +143,11 @@ module Girl
|
|
143
143
|
if now - dst_info[ :last_continue_at ] > EXPIRE_AFTER
|
144
144
|
puts "p#{ Process.pid } #{ Time.new } expire dst #{ dst_info[ :domain ] }"
|
145
145
|
set_is_closing( dst )
|
146
|
-
|
146
|
+
trigger = true
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
if
|
150
|
+
if trigger
|
151
151
|
next_tick
|
152
152
|
end
|
153
153
|
end
|
@@ -179,17 +179,23 @@ module Girl
|
|
179
179
|
end
|
180
180
|
|
181
181
|
if @pause_srcs.any? && ( @tun_info[ :wmems ].size < RESUME_BELOW )
|
182
|
+
trigger = false
|
183
|
+
|
182
184
|
@pause_srcs.each do | src |
|
183
185
|
src_info = @src_infos[ src ]
|
184
186
|
|
185
187
|
if src_info
|
186
188
|
puts "p#{ Process.pid } #{ Time.new } resume src #{ src_info[ :destination_domain ] }"
|
187
189
|
add_read( src )
|
190
|
+
trigger = true
|
188
191
|
end
|
189
192
|
end
|
190
193
|
|
191
194
|
@pause_srcs.clear
|
192
|
-
|
195
|
+
|
196
|
+
if trigger
|
197
|
+
next_tick
|
198
|
+
end
|
193
199
|
end
|
194
200
|
end
|
195
201
|
end
|
@@ -229,7 +235,7 @@ module Girl
|
|
229
235
|
def loop_send_a_new_source( src )
|
230
236
|
src_info = @src_infos[ src ]
|
231
237
|
|
232
|
-
if src_info
|
238
|
+
if src_info
|
233
239
|
destination_domain = src_info[ :destination_domain ]
|
234
240
|
destination_port = src_info[ :destination_port ]
|
235
241
|
domain_port = [ destination_domain, destination_port ].join( ':' )
|
@@ -237,7 +243,7 @@ module Girl
|
|
237
243
|
|
238
244
|
Thread.new do
|
239
245
|
EXPIRE_NEW.times do | i |
|
240
|
-
if src.closed? || src_info[ :dst_id ]
|
246
|
+
if @tun.nil? || @tun.closed? || src.closed? || src_info[ :dst_id ]
|
241
247
|
# puts "debug1 break loop send a new source #{ src_info[ :dst_port ] }"
|
242
248
|
break
|
243
249
|
end
|
@@ -469,12 +475,12 @@ module Girl
|
|
469
475
|
method, url, proto = lines.first.split( ' ' )
|
470
476
|
|
471
477
|
if proto && url && proto[ 0, 4 ] == 'HTTP' && url[ 0, 7 ] == 'http://'
|
472
|
-
|
473
|
-
data = data.sub( "http://#{
|
474
|
-
# puts "debug1 subed #{ data.inspect } #{
|
478
|
+
domain_port = url.split( '/' )[ 2 ]
|
479
|
+
data = data.sub( "http://#{ domain_port }", '' )
|
480
|
+
# puts "debug1 subed #{ data.inspect } #{ domain_port }"
|
475
481
|
end
|
476
482
|
|
477
|
-
[ data,
|
483
|
+
[ data, domain_port ]
|
478
484
|
end
|
479
485
|
|
480
486
|
##
|
@@ -556,9 +562,9 @@ module Girl
|
|
556
562
|
# tunnel data
|
557
563
|
#
|
558
564
|
def tunnel_data( src, data )
|
565
|
+
now = Time.new
|
559
566
|
src_info = @src_infos[ src ]
|
560
567
|
src_id = src_info[ :id ]
|
561
|
-
now = Time.new
|
562
568
|
pack_id = src_info[ :biggest_pack_id ]
|
563
569
|
idx = 0
|
564
570
|
len = data.bytesize
|
@@ -682,10 +688,11 @@ module Girl
|
|
682
688
|
# del src ext
|
683
689
|
#
|
684
690
|
def del_src_ext( src_id )
|
685
|
-
@tun_info[ :
|
686
|
-
src = @tun_info[ :srcs ].delete( src_id )
|
691
|
+
src = @tun_info[ :srcs ][ src_id ]
|
687
692
|
|
688
|
-
if src
|
693
|
+
if src && src.closed?
|
694
|
+
@tun_info[ :wmems ].delete_if { | src_id_pack_id, _ | src_id_pack_id.first == src_id }
|
695
|
+
@tun_info[ :srcs ].delete( src_id )
|
689
696
|
src_info = @src_infos.delete( src )
|
690
697
|
|
691
698
|
if src_info
|
@@ -865,9 +872,9 @@ module Girl
|
|
865
872
|
when :uncheck
|
866
873
|
if data[ 0, 7 ] == 'CONNECT'
|
867
874
|
# puts "debug1 CONNECT"
|
868
|
-
|
875
|
+
domain_port = data.split( "\r\n" )[ 0 ].split( ' ' )[ 1 ]
|
869
876
|
|
870
|
-
unless
|
877
|
+
unless domain_port
|
871
878
|
puts "p#{ Process.pid } #{ Time.new } CONNECT miss domain"
|
872
879
|
set_is_closing( src )
|
873
880
|
return
|
@@ -913,13 +920,13 @@ module Girl
|
|
913
920
|
return
|
914
921
|
end
|
915
922
|
|
916
|
-
data,
|
923
|
+
data, domain_port = sub_http_request( data )
|
917
924
|
|
918
|
-
unless
|
925
|
+
unless domain_port
|
919
926
|
# puts "debug1 not HTTP"
|
920
|
-
|
927
|
+
domain_port = host_line.split( ' ' )[ 1 ]
|
921
928
|
|
922
|
-
unless
|
929
|
+
unless domain_port
|
923
930
|
puts "p#{ Process.pid } #{ Time.new } Host line miss domain"
|
924
931
|
set_is_closing( src )
|
925
932
|
return
|
@@ -930,7 +937,7 @@ module Girl
|
|
930
937
|
src_info[ :rbuff ] << data
|
931
938
|
end
|
932
939
|
|
933
|
-
domain, port =
|
940
|
+
domain, port = domain_port.split( ':' )
|
934
941
|
port = port ? port.to_i : 80
|
935
942
|
|
936
943
|
src_info[ :proxy_proto ] = :http
|
@@ -1036,7 +1043,7 @@ module Girl
|
|
1036
1043
|
src = dst_info[ :src ]
|
1037
1044
|
|
1038
1045
|
if src.closed?
|
1039
|
-
puts "p#{ Process.pid } #{ Time.new } src closed, close dst"
|
1046
|
+
puts "p#{ Process.pid } #{ Time.new } src closed, close dst #{ dst_info[ :domain ] }"
|
1040
1047
|
set_is_closing( dst )
|
1041
1048
|
return
|
1042
1049
|
end
|
@@ -1082,10 +1089,10 @@ module Girl
|
|
1082
1089
|
src_id, dst_id = data[ 9, 10 ].unpack( 'Q>n' )
|
1083
1090
|
|
1084
1091
|
src = @tun_info[ :srcs ][ src_id ]
|
1085
|
-
return if src.closed?
|
1092
|
+
return if src.nil? || src.closed?
|
1086
1093
|
|
1087
1094
|
src_info = @src_infos[ src ]
|
1088
|
-
return if src_info[ :dst_id ]
|
1095
|
+
return if src_info.nil? || src_info[ :dst_id ]
|
1089
1096
|
|
1090
1097
|
# puts "debug1 got paired #{ src_id } #{ dst_id }"
|
1091
1098
|
|
@@ -1278,7 +1285,7 @@ module Girl
|
|
1278
1285
|
return unless src_id
|
1279
1286
|
|
1280
1287
|
src = @tun_info[ :srcs ][ src_id ]
|
1281
|
-
return
|
1288
|
+
return if src.nil? || src.closed?
|
1282
1289
|
|
1283
1290
|
src_info = @src_infos[ src ]
|
1284
1291
|
return unless src_info
|
data/lib/girl/proxyd_worker.rb
CHANGED
@@ -92,7 +92,7 @@ module Girl
|
|
92
92
|
sleep CHECK_EXPIRE_INTERVAL
|
93
93
|
|
94
94
|
@mutex.synchronize do
|
95
|
-
|
95
|
+
trigger = false
|
96
96
|
now = Time.new
|
97
97
|
|
98
98
|
@tund_infos.each do | tund, tund_info |
|
@@ -102,7 +102,7 @@ module Girl
|
|
102
102
|
if is_expired
|
103
103
|
puts "p#{ Process.pid } #{ Time.new } expire tund #{ tund_info[ :port ] }"
|
104
104
|
set_is_closing( tund )
|
105
|
-
|
105
|
+
trigger = true
|
106
106
|
else
|
107
107
|
data = [ 0, HEARTBEAT, rand( 128 ) ].pack( 'Q>CC' )
|
108
108
|
# puts "debug1 #{ Time.new } #{ tund_info[ :port ] } heartbeat"
|
@@ -115,7 +115,7 @@ module Girl
|
|
115
115
|
|
116
116
|
if dst_info && ( now - dst_info[ :last_continue_at ] > EXPIRE_AFTER )
|
117
117
|
puts "p#{ Process.pid } #{ Time.new } expire dst ext #{ dst_info[ :domain_port ] }"
|
118
|
-
tund_info[ :wmems ].delete_if { |
|
118
|
+
tund_info[ :wmems ].delete_if { | dst_id_pack_id, _ | dst_id_pack_id.first == dst_id }
|
119
119
|
tund_info[ :dst_ids ].delete( dst_info[ :src_id ] )
|
120
120
|
@dst_infos.delete( dst )
|
121
121
|
del_dst_ids << dst_id
|
@@ -134,11 +134,11 @@ module Girl
|
|
134
134
|
if now - dst_info[ :last_continue_at ] > EXPIRE_AFTER
|
135
135
|
puts "p#{ Process.pid } #{ Time.new } expire dst #{ dst_info[ :domain_port ] }"
|
136
136
|
set_is_closing( dst )
|
137
|
-
|
137
|
+
trigger = true
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
if
|
141
|
+
if trigger
|
142
142
|
next_tick
|
143
143
|
end
|
144
144
|
end
|
@@ -155,8 +155,6 @@ module Girl
|
|
155
155
|
sleep CHECK_STATUS_INTERVAL
|
156
156
|
|
157
157
|
@mutex.synchronize do
|
158
|
-
need_trigger = false
|
159
|
-
|
160
158
|
if @tunds.any?
|
161
159
|
@tunds.each do | tund_port, tund |
|
162
160
|
tund_info = @tund_infos[ tund ]
|
@@ -206,18 +204,14 @@ module Girl
|
|
206
204
|
add_read( dst )
|
207
205
|
end
|
208
206
|
|
207
|
+
next_tick
|
209
208
|
@pause_dsts -= resume_dsts
|
210
|
-
need_trigger = true
|
211
209
|
end
|
212
210
|
|
213
211
|
if ignore_dsts.any?
|
214
212
|
@pause_dsts -= ignore_dsts
|
215
213
|
end
|
216
214
|
end
|
217
|
-
|
218
|
-
if need_trigger
|
219
|
-
next_tick
|
220
|
-
end
|
221
215
|
end
|
222
216
|
end
|
223
217
|
end
|
@@ -394,14 +388,14 @@ module Girl
|
|
394
388
|
tund = dst_info[ :tund ]
|
395
389
|
|
396
390
|
if tund.closed?
|
397
|
-
puts "p#{ Process.pid } #{ Time.new } tund closed, close dst"
|
391
|
+
puts "p#{ Process.pid } #{ Time.new } tund closed, close dst #{ dst_info[ :domain_port ] } #{ dst_info[ :biggest_pack_id ] }"
|
398
392
|
set_is_closing( dst )
|
399
393
|
return
|
400
394
|
end
|
401
395
|
|
396
|
+
now = Time.new
|
402
397
|
tund_info = @tund_infos[ tund ]
|
403
398
|
dst_id = dst_info[ :id ]
|
404
|
-
now = Time.new
|
405
399
|
pack_id = dst_info[ :biggest_pack_id ]
|
406
400
|
idx = 0
|
407
401
|
len = data.bytesize
|
@@ -437,6 +431,10 @@ module Girl
|
|
437
431
|
# send data
|
438
432
|
#
|
439
433
|
def send_data( sock, data, to_addr )
|
434
|
+
unless to_addr
|
435
|
+
return false
|
436
|
+
end
|
437
|
+
|
440
438
|
begin
|
441
439
|
sock.sendmsg( data, 0, to_addr )
|
442
440
|
rescue IO::WaitWritable, Errno::EINTR
|
@@ -508,10 +506,11 @@ module Girl
|
|
508
506
|
# del dst ext
|
509
507
|
#
|
510
508
|
def del_dst_ext( tund_info, dst_id )
|
511
|
-
tund_info[ :
|
512
|
-
dst = tund_info[ :dsts ].delete( dst_id )
|
509
|
+
dst = tund_info[ :dsts ][ dst_id ]
|
513
510
|
|
514
|
-
if dst
|
511
|
+
if dst && dst.closed?
|
512
|
+
tund_info[ :wmems ].delete_if { | dst_id_pack_id, _ | dst_id_pack_id.first == dst_id }
|
513
|
+
tund_info[ :dsts ].delete( dst_id )
|
515
514
|
dst_info = @dst_infos.delete( dst )
|
516
515
|
|
517
516
|
if dst_info
|
@@ -716,7 +715,7 @@ module Girl
|
|
716
715
|
|
717
716
|
data = data[ 17..-1 ]
|
718
717
|
domain_port = @custom.decode( data )
|
719
|
-
puts "
|
718
|
+
# puts "debug1 a new source #{ src_id } #{ domain_port }"
|
720
719
|
resolve_domain( tund, src_id, domain_port )
|
721
720
|
when SOURCE_STATUS
|
722
721
|
src_id, relay_src_pack_id, continue_dst_pack_id = data[ 9, 24 ].unpack( 'Q>Q>Q>' )
|
@@ -871,7 +870,7 @@ module Girl
|
|
871
870
|
return unless dst_id
|
872
871
|
|
873
872
|
dst = tund_info[ :dsts ][ dst_id ]
|
874
|
-
return
|
873
|
+
return if dst.nil? || dst.closed?
|
875
874
|
|
876
875
|
dst_info = @dst_infos[ dst ]
|
877
876
|
return unless dst_info
|
data/lib/girl/version.rb
CHANGED