girl 0.60.1 → 0.64.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7ae98a97c1517a3cabb320198b9e0d909b74a6c610f7b6e0109b6248b60b530
4
- data.tar.gz: 8c987e8a39f60fe03261ad1b9caadac7c6b6faf3bdb898866d4c507d3a492571
3
+ metadata.gz: 5f4e1bba2efaa28dcf93f09ed4e913b449165cdd55febb11d5b59d88f374e49f
4
+ data.tar.gz: e23ceb94f65c8edf04b53fb8fd369b47d1aecd602bbdd4057f0498fda63bfeb8
5
5
  SHA512:
6
- metadata.gz: 468a1ae9530407076582f1c6fc92cf56e3d36b87dbfc9805b7b2dd3a6b4f77294dd14e98d097ed2ab5b50203a569bffd8b572df3acd8caa07cc8b5c890721c04
7
- data.tar.gz: c6ef17b8a4dc02a5bd037f4700577c2669d7642b34c51fed9a86ec076e43b7a3810401a24541bd90958a2169406496dbd22a8cf9b1cc062b908a3c95c249ed55
6
+ metadata.gz: d8f9d02746902687b25c2c17346cae8bda8e493c4b7325afa0c64a6417769dd3c39941cf2668b41041ce5f74205399cdc3ce990808602ff6e748012b5462a284
7
+ data.tar.gz: b4b52b30693c3d6afca6bd9fee85ac7782afba4b58f475aa73961d3fc8fb3ba21299c745f827631e732dc9e63b2faca5e506dd9f5201e134edd52d38f5fc6097
@@ -7,7 +7,7 @@ module Girl
7
7
  WMEMS_LIMIT = 100_000 # 写后上限,达到上限暂停写
8
8
  RESUME_BELOW = 50_000 # 降到多少以下恢复写
9
9
  EXPIRE_NEW = 10 # 创建之后多久没有流量进来,过期
10
- EXPIRE_AFTER = 900 # 多久没有新流量进来,过期
10
+ EXPIRE_AFTER = 3600 # 多久没有新流量进来,过期
11
11
  CHECK_EXPIRE_INTERVAL = 30 # 检查过期间隔
12
12
  HEARTBEAT_INTERVAL = 30 # 心跳间隔
13
13
  STATUS_INTERVAL = 0.3 # 发送状态间隔
@@ -102,7 +102,7 @@ module Girl
102
102
  now = Time.new
103
103
 
104
104
  if @tun && !@tun.closed?
105
- is_expired = @tun_info[ :last_recv_at ] ? ( now - @tun_info[ :last_recv_at ] > EXPIRE_AFTER ) : ( now - @tun_info[ :created_at ] > EXPIRE_NEW )
105
+ is_expired = @tun_info[ :last_recv_at ].nil? && ( now - @tun_info[ :created_at ] > EXPIRE_NEW )
106
106
 
107
107
  if is_expired
108
108
  puts "p#{ Process.pid } #{ Time.new } expire tun"
@@ -113,7 +113,7 @@ module Girl
113
113
 
114
114
  @tun_info[ :src_exts ].each do | src_addr, src_ext |
115
115
  if src_ext[ :src ].closed? && ( now - src_ext[ :last_continue_at ] > EXPIRE_AFTER )
116
- puts "p#{ Process.pid } #{ Time.new } expire src_ext"
116
+ puts "p#{ Process.pid } #{ Time.new } expire src ext"
117
117
  del_src_ext( src_addr )
118
118
  end
119
119
  end
@@ -363,7 +363,7 @@ module Girl
363
363
  end
364
364
 
365
365
  # puts "debug1 a new dst #{ dst.local_address.inspect }"
366
- local_port = dst.local_address.ip_unpack
366
+ local_port = dst.local_address.ip_unpack.last
367
367
  @dsts[ local_port ] = dst
368
368
  @dst_infos[ dst ] = {
369
369
  local_port: local_port, # 本地端口
@@ -454,7 +454,13 @@ module Girl
454
454
  # sub http request
455
455
  #
456
456
  def sub_http_request( data )
457
- method, url, proto = data.split( "\r\n" ).first.split( ' ' )
457
+ lines = data.split( "\r\n" )
458
+
459
+ if lines.empty?
460
+ return [ data, nil ]
461
+ end
462
+
463
+ method, url, proto = lines.first.split( ' ' )
458
464
 
459
465
  if proto && url && proto[ 0, 4 ] == 'HTTP' && url[ 0, 7 ] == 'http://'
460
466
  domain_and_port = url.split( '/' )[ 2 ]
@@ -491,7 +497,7 @@ module Girl
491
497
  spring = @tun_info[ :chunks ].size > 0 ? ( @tun_info[ :spring ] + 1 ) : 0
492
498
  filename = "#{ Process.pid }-#{ @tun_info[ :port ] }.#{ spring }"
493
499
  chunk_path = File.join( @tun_chunk_dir, filename )
494
- wbuffs = @tun_info[ :wbuffs ].map{ | _src_addr, _data | [ _src_addr, _data.bytesize.pack( 'n' ), _data ].join }
500
+ wbuffs = @tun_info[ :wbuffs ].map{ | _src_addr, _data | [ _src_addr, [ _data.bytesize ].pack( 'n' ), _data ].join }
495
501
 
496
502
  begin
497
503
  IO.binwrite( chunk_path, wbuffs.join )
@@ -1012,6 +1018,12 @@ module Girl
1012
1018
  if data[ 0, 7 ] == 'CONNECT'
1013
1019
  # puts "debug1 CONNECT"
1014
1020
  domain_and_port = data.split( "\r\n" )[ 0 ].split( ' ' )[ 1 ]
1021
+
1022
+ unless domain_and_port
1023
+ puts "p#{ Process.pid } #{ Time.new } CONNECT miss domain"
1024
+ set_is_closing( src )
1025
+ return
1026
+ end
1015
1027
  elsif data[ 0 ].unpack( 'C' ).first == 5
1016
1028
  # puts "debug1 socks5 #{ data.inspect }"
1017
1029
 
@@ -1058,6 +1070,12 @@ module Girl
1058
1070
  unless domain_and_port
1059
1071
  # puts "debug1 not HTTP"
1060
1072
  domain_and_port = host_line.split( ' ' )[ 1 ]
1073
+
1074
+ unless domain_and_port
1075
+ puts "p#{ Process.pid } #{ Time.new } Host line miss domain"
1076
+ set_is_closing( src )
1077
+ return
1078
+ end
1061
1079
  end
1062
1080
 
1063
1081
  src_info[ :rbuffs ] << data
@@ -109,7 +109,7 @@ module Girl
109
109
  else
110
110
  tund_info[ :dst_exts ].each do | dst_local_port, dst_ext |
111
111
  if dst_ext[ :dst ].closed? && ( now - dst_ext[ :last_continue_at ] > EXPIRE_AFTER )
112
- puts "p#{ Process.pid } #{ Time.new } expire dst_ext #{ dst_local_port }"
112
+ puts "p#{ Process.pid } #{ Time.new } expire dst ext #{ dst_local_port }"
113
113
  del_dst_ext( tund, dst_local_port )
114
114
  need_trigger = true
115
115
  end
@@ -119,7 +119,7 @@ module Girl
119
119
  end
120
120
 
121
121
  @dst_infos.each do | dst, dst_info |
122
- is_expired = dst_info[ :last_recv_at ] ? ( now - dst_info[ :last_recv_at ] > EXPIRE_AFTER ) : ( now - dst_info[ :created_at ] > EXPIRE_NEW )
122
+ is_expired = dst_info[ :last_recv_at ].nil? && ( now - dst_info[ :created_at ] > EXPIRE_NEW )
123
123
 
124
124
  if is_expired
125
125
  puts "p#{ Process.pid } #{ Time.new } expire dst"
@@ -791,8 +791,13 @@ module Girl
791
791
  tund_info = @tund_infos[ tund ]
792
792
 
793
793
  if from_addr != tund_info[ :tun_addr ]
794
- puts "p#{ Process.pid } #{ Time.new } #{ addrinfo.inspect } not match #{ Addrinfo.new( tund_info[ :tun_addr ] ).inspect }"
795
- return
794
+ if addrinfo.ip_port == Addrinfo.new( tund_info[ :tun_addr ] ).ip_port
795
+ puts "p#{ Process.pid } #{ Time.new } tun ip changed #{ addrinfo.inspect }"
796
+ tund_info[ :tun_addr ] = from_addr
797
+ else
798
+ puts "p#{ Process.pid } #{ Time.new } #{ addrinfo.inspect } not match #{ Addrinfo.new( tund_info[ :tun_addr ] ).inspect }"
799
+ return
800
+ end
796
801
  end
797
802
 
798
803
  tund_info[ :is_tunneled ] = true
@@ -1,3 +1,3 @@
1
1
  module Girl
2
- VERSION = '0.60.1'.freeze
2
+ VERSION = '0.64.1'.freeze
3
3
  end
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.60.1
4
+ version: 0.64.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-05-27 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: while internet is evil, here's a girl.
14
14
  email: