girl 0.96.0 → 0.97.0

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 141ddfd9fd89d13f02f9ea69e9880d39620460ae1ff5155276c1b4bcb2b3ed83
4
- data.tar.gz: f72985c0577b97927e73c6943f268df9ca92702eb2d84f5f5a4400e4bf93dee3
3
+ metadata.gz: 1488058f7502fb83ee815a38ba4b11276a2bd5732bfadf596f5f42fbbb6bae53
4
+ data.tar.gz: 1ac6377572a1ff976f4626127e78f76e7c949683b035c2df7426acac70b3ac86
5
5
  SHA512:
6
- metadata.gz: 67dc320dc6ef439a146c7396f9a80d6031c5a6cad3d4f36fb23063898fd68c6c6f2a0789cbd51d553a2fcb856d52da826d37f6470f1b5ac83703147809d30341
7
- data.tar.gz: 25189cbab69f1d2345a62efb8898f2410c7de3210a06d04547e2cb01decdc31afc3ff56e5ab98356fdb378d1d5afb95f40792fd96e02c05bf8ff0431ea32d18d
6
+ metadata.gz: 27bc728548949021b2f477ede35b85ff3888ba3371824d32458a390fe9040a10ac0fd11483f25426cda27b95784a2f71b3837fed6b264583ced0378ef6c1b2ee
7
+ data.tar.gz: d07a0a982e4ecbaf4c798163027bbdd68c7cd3510280e5f904a079aa6796aa57f5b0c96067c86ee71630409e92eb923050b132974496bfdbfed71154e61e2a60
@@ -107,7 +107,7 @@ module Girl
107
107
  # add read
108
108
  #
109
109
  def add_read( sock, role = nil )
110
- unless @reads.include?( sock ) then
110
+ if !sock.closed? && !@reads.include?( sock ) then
111
111
  @reads << sock
112
112
 
113
113
  if role then
@@ -757,12 +757,12 @@ module Girl
757
757
  unless src.closed? then
758
758
  puts "p#{ Process.pid } #{ Time.new } resolved #{ domain } #{ ip_info.ip_address }"
759
759
  deal_with_destination_ip( src, ip_info )
760
+ next_tick
760
761
  end
761
762
  else
762
763
  set_src_closing( src )
764
+ next_tick
763
765
  end
764
-
765
- next_tick
766
766
  end
767
767
  end
768
768
  end
@@ -782,7 +782,7 @@ module Girl
782
782
  def set_dst_closing( dst )
783
783
  return if dst.closed?
784
784
  dst_info = @dst_infos[ dst ]
785
-
785
+
786
786
  if dst_info[ :closed_write ] then
787
787
  close_dst( dst )
788
788
  else
@@ -838,10 +838,6 @@ module Girl
838
838
  # set src proxy type tunnel
839
839
  #
840
840
  def set_src_proxy_type_tunnel( src )
841
- if @tun.nil? || @tun.closed? then
842
- new_a_tun
843
- end
844
-
845
841
  src_info = @src_infos[ src ]
846
842
  src_info[ :proxy_type ] = :tunnel
847
843
  src_id = src_info[ :id ]
@@ -939,6 +935,10 @@ module Girl
939
935
  }
940
936
 
941
937
  add_read( src, :src )
938
+
939
+ if @tun.nil? || @tun.closed? then
940
+ new_a_tun
941
+ end
942
942
  end
943
943
 
944
944
  ##
@@ -1025,13 +1025,6 @@ module Girl
1025
1025
  end
1026
1026
 
1027
1027
  src_info = @src_infos[ src ]
1028
-
1029
- # 处理关闭
1030
- if src_info[ :closing ] then
1031
- close_src( src )
1032
- return
1033
- end
1034
-
1035
1028
  proxy_type = src_info[ :proxy_type ]
1036
1029
 
1037
1030
  case proxy_type
@@ -1230,13 +1223,6 @@ module Girl
1230
1223
  end
1231
1224
 
1232
1225
  dst_info = @dst_infos[ dst ]
1233
-
1234
- # 处理关闭
1235
- if dst_info[ :closing ] then
1236
- close_dst( dst )
1237
- return
1238
- end
1239
-
1240
1226
  src = dst_info[ :src ]
1241
1227
  add_src_wbuff( src, data )
1242
1228
  end
@@ -118,7 +118,7 @@ module Girl
118
118
  # add read
119
119
  #
120
120
  def add_read( sock, role = nil )
121
- unless @reads.include?( sock ) then
121
+ if !sock.closed? && !@reads.include?( sock ) then
122
122
  @reads << sock
123
123
 
124
124
  if role then
@@ -127,6 +127,27 @@ module Girl
127
127
  end
128
128
  end
129
129
 
130
+ ##
131
+ # add streamd wbuff
132
+ #
133
+ def add_streamd_wbuff( streamd, data )
134
+ return if streamd.closed?
135
+ streamd_info = @streamd_infos[ streamd ]
136
+ streamd_info[ :wbuff ] << data
137
+ add_write( streamd )
138
+
139
+ if streamd_info[ :wbuff ].bytesize >= WBUFF_LIMIT then
140
+ dst = streamd_info[ :dst ]
141
+ dst_info = @dst_infos[ dst ]
142
+
143
+ unless dst_info[ :paused ] then
144
+ puts "p#{ Process.pid } #{ Time.new } pause dst #{ dst_info[ :domain_port ] }"
145
+ dst_info[ :paused ] = true
146
+ @reads.delete( dst )
147
+ end
148
+ end
149
+ end
150
+
130
151
  ##
131
152
  # add write
132
153
  #
@@ -809,13 +830,6 @@ module Girl
809
830
  end
810
831
 
811
832
  dst_info = @dst_infos[ dst ]
812
-
813
- # 处理关闭
814
- if dst_info[ :closing ] then
815
- close_dst( dst )
816
- return
817
- end
818
-
819
833
  @traff_ins[ dst_info[ :im ] ] += data.bytesize
820
834
  streamd = dst_info[ :streamd ]
821
835
 
@@ -824,14 +838,7 @@ module Girl
824
838
  streamd_info = @streamd_infos[ streamd ]
825
839
  data = @custom.encode( data )
826
840
  # puts "debug2 add streamd.wbuff encoded #{ data.bytesize }"
827
- streamd_info[ :wbuff ] << data
828
- add_write( streamd )
829
-
830
- if streamd_info[ :wbuff ].bytesize >= WBUFF_LIMIT then
831
- puts "p#{ Process.pid } #{ Time.new } pause dst #{ dst_info[ :domain_port ] }"
832
- dst_info[ :paused ] = true
833
- @reads.delete( dst )
834
- end
841
+ add_streamd_wbuff( streamd, data )
835
842
  end
836
843
  else
837
844
  dst_info[ :rbuff ] << data
@@ -863,13 +870,6 @@ module Girl
863
870
  end
864
871
 
865
872
  streamd_info = @streamd_infos[ streamd ]
866
-
867
- # 处理关闭
868
- if streamd_info[ :closing ] then
869
- close_streamd( streamd )
870
- return
871
- end
872
-
873
873
  @traff_ins[ streamd_info[ :im ] ] += data.bytesize
874
874
  dst = streamd_info[ :dst ]
875
875
 
@@ -897,7 +897,8 @@ module Girl
897
897
 
898
898
  unless dst_info[ :rbuff ].empty? then
899
899
  # puts "debug1 encode and move dst.rbuff to streamd.wbuff"
900
- streamd_info[ :wbuff ] << @custom.encode( dst_info[ :rbuff ] )
900
+ data2 = @custom.encode( dst_info[ :rbuff ] )
901
+ add_streamd_wbuff( streamd, data2 )
901
902
  end
902
903
 
903
904
  dst_info[ :streamd ] = streamd
@@ -1,3 +1,3 @@
1
1
  module Girl
2
- VERSION = '0.96.0'.freeze
2
+ VERSION = '0.97.0'.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.96.0
4
+ version: 0.97.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-10-18 00:00:00.000000000 Z
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: escape evil.
14
14
  email: