rex-socket 0.1.53 → 0.1.54

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: f4e2765900a58243437c2588d16bc2c3fcd65b58f042707a1ebca28d2240786d
4
- data.tar.gz: b7e46d8ab59b275872e48c418de39f07c615a2fdc480ad7ce0a8cf033eb5297f
3
+ metadata.gz: 0d6178ec17a488e30e67e5f38c47a37ef101779a01819acc9fe5f0e77e21137a
4
+ data.tar.gz: 850e34b302ac851ef01ed341fdb361e60c6256a3be7ebec6f52398046884b041
5
5
  SHA512:
6
- metadata.gz: 87cdca34534ff3ba9c085659200b40f71802ea51bc023e82bd918df19c3e5b70b2f9132dd954d121655d21a90e2a32bbea0fbed48543877f22ca404cac4d3ee9
7
- data.tar.gz: 3bb326d55b4b6c3f6741df0bcf6073b329bba6934e5a5ac45cae1a6716b53301f1d8b3bebc80d40de0ed1c55a67e5c6fc37846fe5eb9524f294d373b6fc984c8
6
+ metadata.gz: 0e6be5fbc26e756be673e373c521ddac5b1b98a999ee5c78d9d9d009a68d9de1d5a40f2915ebb226a0349c4dd097d76779c2181396be31756f2a95c77f0fabff
7
+ data.tar.gz: 9bcd47ba675dd95f6eb4d5164e94ed5c82d1ac0f36513a20b2c77a37089f6a3cbe0705027ad363e153a700e45e9493b449e6659dc73e6256d20e83188e15c089
checksums.yaml.gz.sig CHANGED
Binary file
@@ -30,7 +30,7 @@ jobs:
30
30
  timeout-minutes: 40
31
31
 
32
32
  strategy:
33
- fail-fast: true
33
+ fail-fast: false
34
34
  matrix:
35
35
  ruby:
36
36
  - '2.7'
@@ -39,20 +39,20 @@ jobs:
39
39
  - '3.2'
40
40
  os:
41
41
  - ubuntu-20.04
42
+ - windows-2019
43
+ - macos-11
42
44
  - ubuntu-latest
43
45
  exclude:
44
46
  - { os: ubuntu-latest, ruby: '2.7' }
45
47
  - { os: ubuntu-latest, ruby: '3.0' }
46
- test_cmd:
47
- - bundle exec rspec
48
48
 
49
49
  env:
50
50
  RAILS_ENV: test
51
51
 
52
- name: ${{ matrix.os }} - Ruby ${{ matrix.ruby }} - ${{ matrix.test_cmd }}
52
+ name: ${{ matrix.os }} - Ruby ${{ matrix.ruby }}
53
53
  steps:
54
54
  - name: Checkout code
55
- uses: actions/checkout@v2
55
+ uses: actions/checkout@v4
56
56
 
57
57
  - name: Setup Ruby
58
58
  uses: ruby/setup-ruby@v1
@@ -60,9 +60,6 @@ jobs:
60
60
  ruby-version: ${{ matrix.ruby }}
61
61
  bundler-cache: true
62
62
 
63
- - name: ${{ matrix.test_cmd }}
63
+ - name: rspec
64
64
  run: |
65
- echo "${CMD}"
66
- bash -c "${CMD}"
67
- env:
68
- CMD: ${{ matrix.test_cmd }}
65
+ bundle exec rspec
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Socket
3
- VERSION = "0.1.53"
3
+ VERSION = "0.1.54"
4
4
  end
5
5
  end
data/lib/rex/socket.rb CHANGED
@@ -672,37 +672,57 @@ module Socket
672
672
  # is no concurrent use of the same locals and this is safe.
673
673
  def self.tcp_socket_pair
674
674
  lsock = nil
675
+ last_child_error = nil
676
+ accept_timeout = 10
675
677
  rsock = nil
676
678
  laddr = '127.0.0.1'
677
679
  lport = 0
678
680
  threads = []
679
681
  mutex = ::Mutex.new
680
682
 
681
- threads << Rex::ThreadFactory.spawn('TcpSocketPair', false) {
683
+ threads << Rex::ThreadFactory.spawn('TcpSocketPair', false) do
682
684
  server = nil
683
- mutex.synchronize {
684
- threads << Rex::ThreadFactory.spawn('TcpSocketPairClient', false) {
685
- mutex.synchronize {
686
- rsock = ::TCPSocket.new( laddr, lport )
687
- }
688
- }
689
- server = ::TCPServer.new(laddr, 0)
690
- if (server.getsockname =~ /127\.0\.0\.1:/)
691
- # JRuby ridiculousness
692
- caddr, lport = server.getsockname.split(":")
693
- caddr = caddr[1,caddr.length]
694
- lport = lport.to_i
685
+ begin
686
+ mutex.synchronize do
687
+ threads << Rex::ThreadFactory.spawn('TcpSocketPairClient', false) do
688
+ mutex.synchronize do
689
+ begin
690
+ rsock = ::TCPSocket.new( laddr, lport )
691
+ rescue => e
692
+ last_child_error = "#{e.class} - #{e.message}"
693
+ raise
694
+ end
695
+ end
696
+ end
697
+ server = ::TCPServer.new(laddr, 0)
698
+ if (server.getsockname =~ /127\.0\.0\.1:/)
699
+ # JRuby ridiculousness
700
+ caddr, lport = server.getsockname.split(":")
701
+ caddr = caddr[1,caddr.length]
702
+ lport = lport.to_i
703
+ else
704
+ # Sane implementations where Socket#getsockname returns a
705
+ # sockaddr
706
+ lport, caddr = ::Socket.unpack_sockaddr_in( server.getsockname )
707
+ end
708
+ end
709
+
710
+ readable, _writable, _errors = ::IO.select([server], nil, nil, accept_timeout)
711
+ if readable && readable.any?
712
+ lsock, _ = server.accept_nonblock
695
713
  else
696
- # Sane implementations where Socket#getsockname returns a
697
- # sockaddr
698
- lport, caddr = ::Socket.unpack_sockaddr_in( server.getsockname )
714
+ raise RuntimeError, "rsock didn't connect in #{accept_timeout} seconds"
699
715
  end
700
- }
701
- lsock, _ = server.accept
702
- server.close
703
- }
716
+ ensure
717
+ server.close if server
718
+ end
719
+ end
704
720
 
705
- threads.each { |t| t.join }
721
+ threads.each.with_index do |thread, i|
722
+ thread.join
723
+ rescue => e
724
+ raise "Thread #{i} - error #{e} - last child error: #{last_child_error}"
725
+ end
706
726
 
707
727
  return [lsock, rsock]
708
728
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-socket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.53
4
+ version: 0.1.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2023-09-05 00:00:00.000000000 Z
96
+ date: 2023-09-13 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
metadata.gz.sig CHANGED
Binary file