girl 0.73.0 → 0.73.1
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 +33 -35
- data/lib/girl/proxyd_worker.rb +18 -19
- data/lib/girl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33af151d416edee9c887ce27984d09f2dd29f9ab73b2f09beac406bdde96eba4
|
4
|
+
data.tar.gz: bd0271ae4f10083e473ec9ec9794becccb2a24f5d2888b94c48e8402ab08f475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 699f24fd304267c96841c882290a47961a3fefcd21bdf8b8bef509b20eaaa7200f5292d58cc10248a251e541cf6a5bb68d43bef1ad7f4d24881b8ef8c994130a
|
7
|
+
data.tar.gz: 7c3e71e1c31c9e61f3584b2b1b0a78b505a7e222c61d6b5edd041f7a25a985267ec13bf1432d6bcdfc46c89d9fb0bf32678fda57b47e8a917c40f4451da93e82
|
data/lib/girl/proxy_worker.rb
CHANGED
@@ -123,9 +123,7 @@ module Girl
|
|
123
123
|
end
|
124
124
|
|
125
125
|
@src_infos.each do | src, src_info |
|
126
|
-
|
127
|
-
|
128
|
-
if is_expired
|
126
|
+
if now - src_info[ :last_continue_at ] > EXPIRE_AFTER
|
129
127
|
puts "p#{ Process.pid } #{ Time.new } expire src"
|
130
128
|
set_is_closing( src )
|
131
129
|
need_trigger = true
|
@@ -133,10 +131,8 @@ module Girl
|
|
133
131
|
end
|
134
132
|
|
135
133
|
@dst_infos.each do | dst, dst_info |
|
136
|
-
|
137
|
-
|
138
|
-
if is_expired
|
139
|
-
puts "p#{ Process.pid } #{ Time.new } expire dst"
|
134
|
+
if now - dst_info[ :last_continue_at ] > EXPIRE_AFTER
|
135
|
+
puts "p#{ Process.pid } #{ Time.new } expire dst #{ dst_info[ :domain ] }"
|
140
136
|
set_is_closing( dst )
|
141
137
|
need_trigger = true
|
142
138
|
end
|
@@ -337,6 +333,7 @@ module Girl
|
|
337
333
|
#
|
338
334
|
def new_a_dst( src, ip_info )
|
339
335
|
src_info = @src_infos[ src ]
|
336
|
+
domain = src_info[ :destination_domain ]
|
340
337
|
destination_addr = Socket.sockaddr_in( src_info[ :destination_port ], ip_info.ip_address )
|
341
338
|
dst = Socket.new( ip_info.ipv4? ? Socket::AF_INET : Socket::AF_INET6, Socket::SOCK_STREAM, 0 )
|
342
339
|
|
@@ -357,15 +354,15 @@ module Girl
|
|
357
354
|
# puts "debug1 a new dst #{ dst.local_address.inspect }"
|
358
355
|
local_port = dst.local_address.ip_port
|
359
356
|
@dst_infos[ dst ] = {
|
360
|
-
local_port: local_port,
|
361
|
-
src: src,
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
is_closing: false
|
357
|
+
local_port: local_port, # 本地端口
|
358
|
+
src: src, # 对应src
|
359
|
+
domain: domain, # 域名
|
360
|
+
wbuff: '', # 写前
|
361
|
+
cache: '', # 块读出缓存
|
362
|
+
chunks: [], # 块队列,写前达到块大小时结一个块 filename
|
363
|
+
spring: 0, # 块后缀,结块时,如果块队列不为空,则自增,为空,则置为0
|
364
|
+
last_continue_at: Time.new, # 上一次发生流量的时间
|
365
|
+
is_closing: false # 是否准备关闭
|
369
366
|
}
|
370
367
|
|
371
368
|
add_read( dst, :dst )
|
@@ -407,7 +404,7 @@ module Girl
|
|
407
404
|
is_dst_closed: false, # dst是否已关闭
|
408
405
|
biggest_dst_pack_id: 0, # dst最大包号码
|
409
406
|
completed_pack_id: 0, # 完成到几(对面收到几)
|
410
|
-
last_continue_at: Time.new #
|
407
|
+
last_continue_at: Time.new # 上一次发生流量的时间
|
411
408
|
}
|
412
409
|
|
413
410
|
src_info = @src_infos[ src ]
|
@@ -768,6 +765,7 @@ module Girl
|
|
768
765
|
# puts "debug2 write src #{ written }"
|
769
766
|
data = data[ written..-1 ]
|
770
767
|
src_info[ from ] = data
|
768
|
+
src_info[ :last_continue_at ] = Time.new
|
771
769
|
end
|
772
770
|
|
773
771
|
##
|
@@ -819,6 +817,7 @@ module Girl
|
|
819
817
|
# puts "debug2 write dst #{ written }"
|
820
818
|
data = data[ written..-1 ]
|
821
819
|
dst_info[ from ] = data
|
820
|
+
dst_info[ :last_continue_at ] = Time.new
|
822
821
|
end
|
823
822
|
|
824
823
|
##
|
@@ -971,22 +970,21 @@ module Girl
|
|
971
970
|
# puts "debug1 accept a src #{ addrinfo.inspect } #{ id }"
|
972
971
|
|
973
972
|
@src_infos[ src ] = {
|
974
|
-
id: id,
|
975
|
-
proxy_proto: :uncheck,
|
976
|
-
proxy_type: :uncheck,
|
977
|
-
dst: nil,
|
978
|
-
destination_domain: nil,
|
979
|
-
destination_port: nil,
|
980
|
-
biggest_pack_id: 0,
|
981
|
-
is_connect: true,
|
982
|
-
rbuffs: [],
|
983
|
-
wbuff: '',
|
984
|
-
cache: '',
|
985
|
-
chunks: [],
|
986
|
-
spring: 0,
|
987
|
-
|
988
|
-
|
989
|
-
is_closing: false # 是否准备关闭
|
973
|
+
id: id, # id
|
974
|
+
proxy_proto: :uncheck, # :uncheck / :http / :socks5
|
975
|
+
proxy_type: :uncheck, # :uncheck / :checking / :direct / :tunnel / :negotiation
|
976
|
+
dst: nil, # :direct的场合,对应的dst
|
977
|
+
destination_domain: nil, # 目的地域名
|
978
|
+
destination_port: nil, # 目的地端口
|
979
|
+
biggest_pack_id: 0, # 最大包号码
|
980
|
+
is_connect: true, # 代理协议是http的场合,是否是CONNECT
|
981
|
+
rbuffs: [], # 非CONNECT,dst或者远端dst未准备好,暂存流量 [ pack_id, data ]
|
982
|
+
wbuff: '', # 写前
|
983
|
+
cache: '', # 块读出缓存
|
984
|
+
chunks: [], # 块队列,写前达到块大小时结一个块 filename
|
985
|
+
spring: 0, # 块后缀,结块时,如果块队列不为空,则自增,为空,则置为0
|
986
|
+
last_continue_at: Time.new, # 上一次发生流量的时间
|
987
|
+
is_closing: false # 是否准备关闭
|
990
988
|
}
|
991
989
|
|
992
990
|
add_read( src, :src )
|
@@ -1008,7 +1006,7 @@ module Girl
|
|
1008
1006
|
|
1009
1007
|
# puts "debug2 read src #{ data.inspect }"
|
1010
1008
|
src_info = @src_infos[ src ]
|
1011
|
-
src_info[ :
|
1009
|
+
src_info[ :last_continue_at ] = Time.new
|
1012
1010
|
proxy_type = src_info[ :proxy_type ]
|
1013
1011
|
|
1014
1012
|
case proxy_type
|
@@ -1198,7 +1196,7 @@ module Girl
|
|
1198
1196
|
|
1199
1197
|
# puts "debug2 read dst #{ data.inspect }"
|
1200
1198
|
dst_info = @dst_infos[ dst ]
|
1201
|
-
dst_info[ :
|
1199
|
+
dst_info[ :last_continue_at ] = Time.new
|
1202
1200
|
src = dst_info[ :src ]
|
1203
1201
|
|
1204
1202
|
if src.closed?
|
data/lib/girl/proxyd_worker.rb
CHANGED
@@ -123,10 +123,8 @@ module Girl
|
|
123
123
|
end
|
124
124
|
|
125
125
|
@dst_infos.each do | dst, dst_info |
|
126
|
-
|
127
|
-
|
128
|
-
if is_expired
|
129
|
-
puts "p#{ Process.pid } #{ Time.new } expire dst"
|
126
|
+
if now - dst_info[ :last_continue_at ] > EXPIRE_AFTER
|
127
|
+
puts "p#{ Process.pid } #{ Time.new } expire dst #{ dst_info[ :domain_port ] }"
|
130
128
|
set_is_closing( dst )
|
131
129
|
need_trigger = true
|
132
130
|
end
|
@@ -195,7 +193,7 @@ module Girl
|
|
195
193
|
|
196
194
|
if Time.new - created_at < RESOLV_CACHE_EXPIRE
|
197
195
|
# puts "debug1 #{ destination_domain_port } hit resolv cache #{ Addrinfo.new( destination_addr ).inspect }"
|
198
|
-
deal_with_destination_addr( tund, src_id, destination_addr )
|
196
|
+
deal_with_destination_addr( tund, src_id, destination_addr, destination_domain_port )
|
199
197
|
return
|
200
198
|
end
|
201
199
|
|
@@ -223,7 +221,7 @@ module Girl
|
|
223
221
|
@resolv_caches[ destination_domain_port ] = [ destination_addr, Time.new ]
|
224
222
|
|
225
223
|
unless tund.closed?
|
226
|
-
if deal_with_destination_addr( tund, src_id, destination_addr )
|
224
|
+
if deal_with_destination_addr( tund, src_id, destination_addr, destination_domain_port )
|
227
225
|
next_tick
|
228
226
|
end
|
229
227
|
end
|
@@ -235,7 +233,7 @@ module Girl
|
|
235
233
|
##
|
236
234
|
# deal with destination addr
|
237
235
|
#
|
238
|
-
def deal_with_destination_addr( tund, src_id, destination_addr )
|
236
|
+
def deal_with_destination_addr( tund, src_id, destination_addr, destination_domain_port )
|
239
237
|
dst = Socket.new( Addrinfo.new( destination_addr ).ipv4? ? Socket::AF_INET : Socket::AF_INET6, Socket::SOCK_STREAM, 0 )
|
240
238
|
dst.setsockopt( Socket::SOL_TCP, Socket::TCP_NODELAY, 1 )
|
241
239
|
|
@@ -250,16 +248,16 @@ module Girl
|
|
250
248
|
local_port = dst.local_address.ip_port
|
251
249
|
|
252
250
|
@dst_infos[ dst ] = {
|
253
|
-
local_port: local_port,
|
254
|
-
tund: tund,
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
is_closing: false
|
251
|
+
local_port: local_port, # 本地端口
|
252
|
+
tund: tund, # 对应tund
|
253
|
+
domain_port: destination_domain_port, # 域名和端口
|
254
|
+
biggest_pack_id: 0, # 最大包号码
|
255
|
+
wbuff: '', # 写前
|
256
|
+
cache: '', # 块读出缓存
|
257
|
+
chunks: [], # 块队列,写前达到块大小时结一个块 filename
|
258
|
+
spring: 0, # 块后缀,结块时,如果块队列不为空,则自增,为空,则置为0
|
259
|
+
last_continue_at: Time.new, # 上一次发生流量的时间
|
260
|
+
is_closing: false # 是否准备关闭
|
263
261
|
}
|
264
262
|
add_read( dst, :dst )
|
265
263
|
|
@@ -276,7 +274,7 @@ module Girl
|
|
276
274
|
is_src_closed: false, # src是否已关闭
|
277
275
|
biggest_src_pack_id: 0, # src最大包号码
|
278
276
|
completed_pack_id: 0, # 完成到几(对面收到几)
|
279
|
-
last_continue_at: Time.new #
|
277
|
+
last_continue_at: Time.new # 上一次发生流量的时间
|
280
278
|
}
|
281
279
|
|
282
280
|
data = [ 0, PAIRED, src_id, local_port ].pack( 'Q>CQ>n' )
|
@@ -586,6 +584,7 @@ module Girl
|
|
586
584
|
# puts "debug2 write dst #{ written }"
|
587
585
|
data = data[ written..-1 ]
|
588
586
|
dst_info[ from ] = data
|
587
|
+
dst_info[ :last_continue_at ] = Time.new
|
589
588
|
end
|
590
589
|
|
591
590
|
##
|
@@ -775,7 +774,7 @@ module Girl
|
|
775
774
|
|
776
775
|
# puts "debug2 read dst #{ data.inspect }"
|
777
776
|
dst_info = @dst_infos[ dst ]
|
778
|
-
dst_info[ :
|
777
|
+
dst_info[ :last_continue_at ] = Time.new
|
779
778
|
tund = dst_info[ :tund ]
|
780
779
|
|
781
780
|
if tund.closed?
|
data/lib/girl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: girl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.73.
|
4
|
+
version: 0.73.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takafan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: while internet is evil, here's a girl.
|
14
14
|
email:
|