girl 0.72.0 → 0.73.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 +14 -21
- data/lib/girl/proxyd_worker.rb +12 -9
- 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: d975dc92620d5ea2c27493ed0fbbb19a145fc7ecda564c2f5609eb710e06912d
|
4
|
+
data.tar.gz: 5c098f6b8aecc89d246e8e4b1c477eb42e86ce695b27d4329962255d380b4f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 326b198254e6508e42b00145e00c56214574510448ba05b852b257b44da2c54b443509d1e2af514a668b1394e27cfff2ae93cf1957526adf9315a73e32a3ebbd
|
7
|
+
data.tar.gz: 21e0cab87ffe323314607d74c3884eb2987208a9375b417c1158d1768e7aafcf536d7370d5fdff58b08d1d7acb95da009eba57ddcc9d9d22702e405078b2c7e5
|
data/lib/girl/proxy_worker.rb
CHANGED
@@ -216,12 +216,6 @@ module Girl
|
|
216
216
|
# resolve domain
|
217
217
|
#
|
218
218
|
def resolve_domain( src, domain )
|
219
|
-
if ( /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z/ =~ domain ) && domain.split( '.' ).all? { | part | part.to_i < 256 }
|
220
|
-
# puts "debug1 #{ domain } is a ip"
|
221
|
-
deal_with_destination_ip( src, domain )
|
222
|
-
return
|
223
|
-
end
|
224
|
-
|
225
219
|
if @remotes.any? { | remote | ( domain.size >= remote.size ) && ( domain[ ( remote.size * -1 )..-1 ] == remote ) }
|
226
220
|
# puts "debug1 #{ domain } hit remotes"
|
227
221
|
new_a_src_ext( src )
|
@@ -231,11 +225,11 @@ module Girl
|
|
231
225
|
resolv_cache = @resolv_caches[ domain ]
|
232
226
|
|
233
227
|
if resolv_cache
|
234
|
-
|
228
|
+
ip_info, created_at = resolv_cache
|
235
229
|
|
236
230
|
if Time.new - created_at < RESOLV_CACHE_EXPIRE
|
237
|
-
# puts "debug1 #{ domain } hit resolv cache #{
|
238
|
-
deal_with_destination_ip( src,
|
231
|
+
# puts "debug1 #{ domain } hit resolv cache #{ ip_info.inspect }"
|
232
|
+
deal_with_destination_ip( src, ip_info )
|
239
233
|
return
|
240
234
|
end
|
241
235
|
|
@@ -255,12 +249,11 @@ module Girl
|
|
255
249
|
|
256
250
|
@mutex.synchronize do
|
257
251
|
if ip_info
|
258
|
-
|
259
|
-
# puts "debug1 resolved #{ domain } #{ destination_ip }"
|
260
|
-
@resolv_caches[ domain ] = [ destination_ip, Time.new ]
|
252
|
+
@resolv_caches[ domain ] = [ ip_info, Time.new ]
|
261
253
|
|
262
254
|
unless src.closed?
|
263
|
-
|
255
|
+
puts "p#{ Process.pid } #{ Time.new } resolved #{ domain } #{ ip_info.ip_address }"
|
256
|
+
deal_with_destination_ip( src, ip_info )
|
264
257
|
end
|
265
258
|
else
|
266
259
|
set_is_closing( src )
|
@@ -274,11 +267,11 @@ module Girl
|
|
274
267
|
##
|
275
268
|
# deal with destination ip
|
276
269
|
#
|
277
|
-
def deal_with_destination_ip( src,
|
278
|
-
if @directs.any? { | direct | direct.include?(
|
270
|
+
def deal_with_destination_ip( src, ip_info )
|
271
|
+
if @directs.any? { | direct | direct.include?( ip_info.ip_address ) }
|
279
272
|
# ip命中直连列表,直连
|
280
|
-
# puts "debug1 #{
|
281
|
-
new_a_dst( src,
|
273
|
+
# puts "debug1 #{ ip_info.inspect } hit directs"
|
274
|
+
new_a_dst( src, ip_info )
|
282
275
|
else
|
283
276
|
# 走远端
|
284
277
|
new_a_src_ext( src )
|
@@ -342,10 +335,10 @@ module Girl
|
|
342
335
|
##
|
343
336
|
# new a dst
|
344
337
|
#
|
345
|
-
def new_a_dst( src,
|
338
|
+
def new_a_dst( src, ip_info )
|
346
339
|
src_info = @src_infos[ src ]
|
347
|
-
destination_addr = Socket.sockaddr_in( src_info[ :destination_port ],
|
348
|
-
dst = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
|
340
|
+
destination_addr = Socket.sockaddr_in( src_info[ :destination_port ], ip_info.ip_address )
|
341
|
+
dst = Socket.new( ip_info.ipv4? ? Socket::AF_INET : Socket::AF_INET6, Socket::SOCK_STREAM, 0 )
|
349
342
|
|
350
343
|
if RUBY_PLATFORM.include?( 'linux' )
|
351
344
|
dst.setsockopt( Socket::SOL_TCP, Socket::TCP_NODELAY, 1 )
|
@@ -1122,7 +1115,7 @@ module Girl
|
|
1122
1115
|
src_info[ :destination_domain ] = destination_ip
|
1123
1116
|
src_info[ :destination_port ] = destination_port
|
1124
1117
|
# puts "debug1 IP V4 address #{ destination_addrinfo.inspect }"
|
1125
|
-
deal_with_destination_ip( src,
|
1118
|
+
deal_with_destination_ip( src, destination_addrinfo )
|
1126
1119
|
elsif atyp == 3
|
1127
1120
|
domain_len = data[ 4 ].unpack( 'C' ).first
|
1128
1121
|
|
data/lib/girl/proxyd_worker.rb
CHANGED
@@ -204,13 +204,17 @@ module Girl
|
|
204
204
|
end
|
205
205
|
|
206
206
|
Thread.new do
|
207
|
-
|
208
|
-
destination_port = destination_port.to_i
|
207
|
+
colon_idx = destination_domain_port.rindex( ':' )
|
209
208
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
209
|
+
if colon_idx
|
210
|
+
destination_domain = destination_domain_port[ 0...colon_idx ]
|
211
|
+
destination_port = destination_domain_port[ ( colon_idx + 1 )..-1 ].to_i
|
212
|
+
|
213
|
+
begin
|
214
|
+
destination_addr = Socket.sockaddr_in( destination_port, destination_domain )
|
215
|
+
rescue Exception => e
|
216
|
+
puts "p#{ Process.pid } #{ Time.new } sockaddr in #{ destination_domain_port } #{ e.class }"
|
217
|
+
end
|
214
218
|
end
|
215
219
|
|
216
220
|
@mutex.synchronize do
|
@@ -232,7 +236,7 @@ module Girl
|
|
232
236
|
# deal with destination addr
|
233
237
|
#
|
234
238
|
def deal_with_destination_addr( tund, src_id, destination_addr )
|
235
|
-
dst = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 )
|
239
|
+
dst = Socket.new( Addrinfo.new( destination_addr ).ipv4? ? Socket::AF_INET : Socket::AF_INET6, Socket::SOCK_STREAM, 0 )
|
236
240
|
dst.setsockopt( Socket::SOL_TCP, Socket::TCP_NODELAY, 1 )
|
237
241
|
|
238
242
|
begin
|
@@ -814,7 +818,6 @@ module Girl
|
|
814
818
|
when A_NEW_SOURCE
|
815
819
|
src_id = data[ 9, 8 ].unpack( 'Q>' ).first
|
816
820
|
dst_local_port = tund_info[ :dst_local_ports ][ src_id ]
|
817
|
-
# puts "debug1 got a new source #{ src_id }"
|
818
821
|
|
819
822
|
if dst_local_port
|
820
823
|
dst_ext = tund_info[ :dst_exts ][ dst_local_port ]
|
@@ -831,8 +834,8 @@ module Girl
|
|
831
834
|
end
|
832
835
|
|
833
836
|
data = data[ 17..-1 ]
|
834
|
-
# puts "debug1 #{ data }"
|
835
837
|
destination_domain_port = @custom.decode( data )
|
838
|
+
puts "p#{ Process.pid } #{ Time.new } a new source #{ src_id } #{ destination_domain_port }"
|
836
839
|
resolve_domain( tund, src_id, destination_domain_port )
|
837
840
|
when SOURCE_STATUS
|
838
841
|
src_id, relay_src_pack_id, continue_dst_pack_id = data[ 9, 24 ].unpack( 'Q>Q>Q>' )
|
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.
|
4
|
+
version: 0.73.0
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: while internet is evil, here's a girl.
|
14
14
|
email:
|