girl 0.75.0 → 0.80.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac2f8ddb303a57e5c898754c88710847686e84b3ef406c053ef926424da78e2b
4
- data.tar.gz: 4506688a3176c9effe1804e3d247379a79d96906e4c8417d6f0660ecaa082141
3
+ metadata.gz: 7758f3ee995f864831703ae7f9615dba9f0280ebcb10130f29c24f8f862c43c8
4
+ data.tar.gz: 3758aaac1ded47dfa0d2336332679de27d3ed711593bb7f7e6e48b5225eaaee8
5
5
  SHA512:
6
- metadata.gz: 34559a0ab1375eb9b07bab0fbea3d762e94ac7282ed8868e3ab672aa816f87f6edc3273b1204c565c189201bd2a49e993477a6da525b472e95c18b804526323e
7
- data.tar.gz: d7580c92099e6974287fbc8384010d3b5ed34966832ff9c1a0bda42cdeac923768fa431b84c83dee8926c3b4bc8f2b0761bdb9a4a14212870a2dde3abb89f338
6
+ metadata.gz: 66f0915bb0dd5ebfaab7e6f5e8b22e8b21fdfdbe0ec884afc75523340d718c34d64fcb4276ef05abab9e06d80d77c927929bfd043fb6c21c61f2d5cd39b33754
7
+ data.tar.gz: 296db9cf2d234aa7bb6affd3ff018f28e69ef9d38bf54b7ca5c78f6dade85f046cf63e42e15ef3b98752ff43ea99ea4e2f7bf779e38e61f5c79e6ca542bbdffb
@@ -30,21 +30,10 @@ module Girl
30
30
  RESERVED_ROUTE = <<EOF
31
31
  0.0.0.0/8
32
32
  10.0.0.0/8
33
- 100.64.0.0/10
34
33
  127.0.0.0/8
35
34
  169.254.0.0/16
36
35
  172.16.0.0/12
37
- 192.0.0.0/24
38
- 192.0.2.0/24
39
- 192.31.196.0/24
40
- 192.52.193.0/24
41
- 192.88.99.0/24
42
36
  192.168.0.0/16
43
- 192.175.48.0/24
44
- 198.18.0.0/15
45
- 198.51.100.0/24
46
- 203.0.113.0/24
47
- 240.0.0.0/4
48
37
  255.255.255.255/32
49
38
  EOF
50
39
  end
@@ -741,15 +741,14 @@ module Girl
741
741
  #
742
742
  def write_src( src )
743
743
  src_info = @src_infos[ src ]
744
- data = src_info[ :cache ]
745
- from = :cache
744
+ from, data = :cache, src_info[ :cache ]
746
745
 
747
746
  if data.empty?
748
747
  if src_info[ :chunks ].any?
749
748
  path = File.join( @src_chunk_dir, src_info[ :chunks ].shift )
750
749
 
751
750
  begin
752
- src_info[ :cache ] = data = IO.binread( path )
751
+ data = src_info[ :cache ] = IO.binread( path )
753
752
  File.delete( path )
754
753
  rescue Errno::ENOENT => e
755
754
  puts "p#{ Process.pid } #{ Time.new } read #{ path } #{ e.class }"
@@ -757,8 +756,7 @@ module Girl
757
756
  return
758
757
  end
759
758
  else
760
- data = src_info[ :wbuff ]
761
- from = :wbuff
759
+ from, data = :wbuff, src_info[ :wbuff ]
762
760
  end
763
761
  end
764
762
 
@@ -792,15 +790,14 @@ module Girl
792
790
  #
793
791
  def write_dst( dst )
794
792
  dst_info = @dst_infos[ dst ]
795
- data = dst_info[ :cache ]
796
- from = :cache
793
+ from, data = :cache, dst_info[ :cache ]
797
794
 
798
795
  if data.empty?
799
796
  if dst_info[ :chunks ].any?
800
797
  path = File.join( @dst_chunk_dir, dst_info[ :chunks ].shift )
801
798
 
802
799
  begin
803
- dst_info[ :cache ] = data = IO.binread( path )
800
+ data = dst_info[ :cache ] = IO.binread( path )
804
801
  File.delete( path )
805
802
  rescue Errno::ENOENT => e
806
803
  puts "p#{ Process.pid } #{ Time.new } read #{ path } #{ e.class }"
@@ -808,8 +805,7 @@ module Girl
808
805
  return
809
806
  end
810
807
  else
811
- data = dst_info[ :wbuff ]
812
- from = :wbuff
808
+ from, data = :wbuff, dst_info[ :wbuff ]
813
809
  end
814
810
  end
815
811
 
@@ -873,11 +869,12 @@ module Girl
873
869
  unless send_data( tun, data, @tun_info[ :tund_addr ] )
874
870
  return
875
871
  end
872
+
873
+ src_ext[ :last_continue_at ] = now
876
874
  end
877
875
  end
878
876
 
879
877
  @tun_info[ :resendings ].shift
880
- return
881
878
  end
882
879
 
883
880
  # 若写后达到上限,暂停取写前
@@ -893,8 +890,7 @@ module Girl
893
890
 
894
891
  # 取写前
895
892
  if @tun_info[ :caches ].any?
896
- src_id, pack_id, data = @tun_info[ :caches ].first
897
- from = :caches
893
+ datas = @tun_info[ :caches ]
898
894
  elsif @tun_info[ :chunks ].any?
899
895
  path = File.join( @tun_chunk_dir, @tun_info[ :chunks ].shift )
900
896
 
@@ -915,39 +911,39 @@ module Girl
915
911
  data = data[ ( 18 + pack_size )..-1 ]
916
912
  end
917
913
 
918
- @tun_info[ :caches ] = caches
919
- src_id, pack_id, data = caches.first
920
- from = :caches
914
+ datas = @tun_info[ :caches ] = caches
921
915
  elsif @tun_info[ :wbuffs ].any?
922
- src_id, pack_id, data = @tun_info[ :wbuffs ].first
923
- from = :wbuffs
916
+ datas = @tun_info[ :wbuffs ]
924
917
  else
925
918
  @writes.delete( tun )
926
919
  return
927
920
  end
928
921
 
929
- src_ext = @tun_info[ :src_exts ][ src_id ]
922
+ while datas.any?
923
+ src_id, pack_id, data = datas.first
924
+ src_ext = @tun_info[ :src_exts ][ src_id ]
930
925
 
931
- if src_ext
932
- if pack_id <= CONFUSE_UNTIL
933
- data = @custom.encode( data )
934
- # puts "debug1 encoded pack #{ pack_id }"
935
- end
926
+ if src_ext
927
+ if pack_id <= CONFUSE_UNTIL
928
+ data = @custom.encode( data )
929
+ # puts "debug1 encoded pack #{ pack_id }"
930
+ end
936
931
 
937
- data = [ [ pack_id, src_id ].pack( 'Q>Q>' ), data ].join
932
+ data = [ [ pack_id, src_id ].pack( 'Q>Q>' ), data ].join
938
933
 
939
- unless send_data( tun, data, @tun_info[ :tund_addr ] )
940
- return
934
+ unless send_data( tun, data, @tun_info[ :tund_addr ] )
935
+ return
936
+ end
937
+
938
+ # puts "debug2 written pack #{ pack_id }"
939
+ src_ext[ :relay_pack_id ] = pack_id
940
+ src_ext[ :wmems ][ pack_id ] = data
941
+ src_ext[ :send_ats ][ pack_id ] = now
942
+ src_ext[ :last_continue_at ] = now
941
943
  end
942
944
 
943
- # puts "debug2 written pack #{ pack_id }"
944
- src_ext[ :relay_pack_id ] = pack_id
945
- src_ext[ :wmems ][ pack_id ] = data
946
- src_ext[ :send_ats ][ pack_id ] = now
947
- src_ext[ :last_continue_at ] = now
945
+ datas.shift
948
946
  end
949
-
950
- @tun_info[ from ].shift
951
947
  end
952
948
 
953
949
  ##
@@ -967,7 +963,7 @@ module Girl
967
963
  return
968
964
  end
969
965
 
970
- id = rand( ( 2 ** 64 ) - 1 ) + 1
966
+ id = rand( ( 2 ** 64 ) - 2 ) + 1
971
967
  # puts "debug1 accept a src #{ addrinfo.inspect } #{ id }"
972
968
 
973
969
  @src_infos[ src ] = {
@@ -558,15 +558,14 @@ module Girl
558
558
  #
559
559
  def write_dst( dst )
560
560
  dst_info = @dst_infos[ dst ]
561
- data = dst_info[ :cache ]
562
- from = :cache
561
+ from, data = :cache, dst_info[ :cache ]
563
562
 
564
563
  if data.empty?
565
564
  if dst_info[ :chunks ].any?
566
565
  path = File.join( @dst_chunk_dir, dst_info[ :chunks ].shift )
567
566
 
568
567
  begin
569
- dst_info[ :cache ] = data = IO.binread( path )
568
+ data = dst_info[ :cache ] = IO.binread( path )
570
569
  File.delete( path )
571
570
  rescue Errno::ENOENT => e
572
571
  puts "p#{ Process.pid } #{ Time.new } read #{ path } #{ e.class }"
@@ -574,8 +573,7 @@ module Girl
574
573
  return
575
574
  end
576
575
  else
577
- data = dst_info[ :wbuff ]
578
- from = :wbuff
576
+ from, data = :wbuff, dst_info[ :wbuff ]
579
577
  end
580
578
  end
581
579
 
@@ -609,6 +607,7 @@ module Girl
609
607
  # write tund
610
608
  #
611
609
  def write_tund( tund )
610
+ now = Time.new
612
611
  tund_info = @tund_infos[ tund ]
613
612
 
614
613
  if tund_info[ :is_closing ]
@@ -639,11 +638,12 @@ module Girl
639
638
  unless send_data( tund, data, tund_info[ :tun_addr ] )
640
639
  return
641
640
  end
641
+
642
+ dst_ext[ :last_continue_at ] = now
642
643
  end
643
644
  end
644
645
 
645
646
  tund_info[ :resendings ].shift
646
- return
647
647
  end
648
648
 
649
649
  # 若写后达到上限,暂停取写前
@@ -659,8 +659,7 @@ module Girl
659
659
 
660
660
  # 取写前
661
661
  if tund_info[ :caches ].any?
662
- dst_local_port, pack_id, data = tund_info[ :caches ].first
663
- from = :caches
662
+ datas = tund_info[ :caches ]
664
663
  elsif tund_info[ :chunks ].any?
665
664
  path = File.join( @tund_chunk_dir, tund_info[ :chunks ].shift )
666
665
 
@@ -681,40 +680,39 @@ module Girl
681
680
  data = data[ ( 12 + pack_size )..-1 ]
682
681
  end
683
682
 
684
- tund_info[ :caches ] = caches
685
- dst_local_port, pack_id, data = caches.first
686
- from = :caches
683
+ datas = tund_info[ :caches ] = caches
687
684
  elsif tund_info[ :wbuffs ].any?
688
- dst_local_port, pack_id, data = tund_info[ :wbuffs ].first
689
- from = :wbuffs
685
+ datas = tund_info[ :wbuffs ]
690
686
  else
691
687
  @writes.delete( tund )
692
688
  return
693
689
  end
694
690
 
695
- dst_ext = tund_info[ :dst_exts ][ dst_local_port ]
691
+ while datas.any?
692
+ dst_local_port, pack_id, data = datas.first
693
+ dst_ext = tund_info[ :dst_exts ][ dst_local_port ]
696
694
 
697
- if dst_ext
698
- if pack_id <= CONFUSE_UNTIL
699
- data = @custom.encode( data )
700
- # puts "debug1 encoded pack #{ pack_id }"
701
- end
695
+ if dst_ext
696
+ if pack_id <= CONFUSE_UNTIL
697
+ data = @custom.encode( data )
698
+ # puts "debug1 encoded pack #{ pack_id }"
699
+ end
702
700
 
703
- data = [ [ pack_id, dst_local_port ].pack( 'Q>n' ), data ].join
701
+ data = [ [ pack_id, dst_local_port ].pack( 'Q>n' ), data ].join
704
702
 
705
- unless send_data( tund, data, tund_info[ :tun_addr ] )
706
- return
703
+ unless send_data( tund, data, tund_info[ :tun_addr ] )
704
+ return
705
+ end
706
+
707
+ # puts "debug2 written pack #{ pack_id }"
708
+ dst_ext[ :relay_pack_id ] = pack_id
709
+ dst_ext[ :wmems ][ pack_id ] = data
710
+ dst_ext[ :send_ats ][ pack_id ] = now
711
+ dst_ext[ :last_continue_at ] = now
707
712
  end
708
713
 
709
- # puts "debug2 written pack #{ pack_id }"
710
- now = Time.new
711
- dst_ext[ :relay_pack_id ] = pack_id
712
- dst_ext[ :wmems ][ pack_id ] = data
713
- dst_ext[ :send_ats ][ pack_id ] = now
714
- dst_ext[ :last_continue_at ] = now
714
+ datas.shift
715
715
  end
716
-
717
- tund_info[ from ].shift
718
716
  end
719
717
 
720
718
  ##
@@ -810,13 +808,10 @@ module Girl
810
808
  tund_info = @tund_infos[ tund ]
811
809
 
812
810
  if from_addr != tund_info[ :tun_addr ]
813
- if addrinfo.ip_port == Addrinfo.new( tund_info[ :tun_addr ] ).ip_port
814
- puts "p#{ Process.pid } #{ Time.new } tun ip changed #{ addrinfo.inspect }"
815
- tund_info[ :tun_addr ] = from_addr
816
- else
817
- puts "p#{ Process.pid } #{ Time.new } #{ addrinfo.inspect } not match #{ Addrinfo.new( tund_info[ :tun_addr ] ).inspect }"
818
- return
819
- end
811
+ # 通常是光猫刷新ip(端口也会变),但万一不是,为了避免脏数据注入,关闭tund
812
+ puts "p#{ Process.pid } #{ Time.new } from #{ addrinfo.inspect } not match tun addr #{ Addrinfo.new( tund_info[ :tun_addr ] ).inspect }"
813
+ set_is_closing( tund )
814
+ return
820
815
  end
821
816
 
822
817
  tund_info[ :last_recv_at ] = now
@@ -1,3 +1,3 @@
1
1
  module Girl
2
- VERSION = '0.75.0'.freeze
2
+ VERSION = '0.80.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.75.0
4
+ version: 0.80.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-22 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: while internet is evil, here's a girl.
14
14
  email:
@@ -49,8 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubyforge_project:
53
- rubygems_version: 2.7.6.2
52
+ rubygems_version: 3.1.2
54
53
  signing_key:
55
54
  specification_version: 4
56
55
  summary: 妹子