Sha256: 8a0f7279c75dea8f339694ef8233abf890de9283f644e64d7a7f230483f00402

Contents?: true

Size: 1.04 KB

Versions: 281

Compression:

Stored size: 1.04 KB

Contents

require 'net/ssh/verifiers/strict'

module Net; module SSH; module Verifiers

  # Basically the same as the Strict verifier, but does not try to actually
  # verify a connection if the server is the localhost and the port is a
  # nonstandard port number. Those two conditions will typically mean the
  # connection is being tunnelled through a forwarded port, so the known-hosts
  # file will not be helpful (in general).
  class Lenient < Strict
    # Tries to determine if the connection is being tunnelled, and if so,
    # returns true. Otherwise, performs the standard strict verification.
    def verify(arguments)
      return true if tunnelled?(arguments)
      super
    end

    private

      # A connection is potentially being tunnelled if the port is not 22,
      # and the ip refers to the localhost.
      def tunnelled?(args)
        return false if args[:session].port == Net::SSH::Transport::Session::DEFAULT_PORT
        
        ip = args[:session].peer[:ip]
        return ip == "127.0.0.1" || ip == "::1"
      end
  end

end; end; end

Version data entries

281 entries across 238 versions & 30 rubygems

Version Path
savant-echo-1.0.4 bin/packaging/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
net-ssh-4.1.0 lib/net/ssh/verifiers/lenient.rb
net-ssh-4.1.0.rc1 lib/net/ssh/verifiers/lenient.rb
net-ssh-4.1.0.beta1 lib/net/ssh/verifiers/lenient.rb
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/net-ssh-3.0.2/lib/net/ssh/verifiers/lenient.rb
savant-echo-1.0.1 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
savant-echo-1.0.1 bin/packaging/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
net-ssh-4.0.1 lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.91 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.91 bin/packaging/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
net-ssh-4.0.1.rc2 lib/net/ssh/verifiers/lenient.rb
net-ssh-4.0.1.rc1 lib/net/ssh/verifiers/lenient.rb
net-ssh-4.0.0 lib/net/ssh/verifiers/lenient.rb
net-ssh-4.0.0.rc3 lib/net/ssh/verifiers/lenient.rb
net-ssh-4.0.0.rc2 lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.9 bin/packaging/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.9 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.6 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.6 bin/packaging/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb
savant-echo-0.1.5 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/net-ssh-3.2.0/lib/net/ssh/verifiers/lenient.rb