Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/net/telnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class Telnet
# host = Net::Telnet::new(
# "Host" => "localhost", # default: "localhost"
# "Port" => 23, # default: 23
# "Source" => 192.168.1.1 # default: nil
# "Binmode" => false, # default: false
# "Output_log" => "output_log", # default: nil (no output)
# "Dump_log" => "dump_log", # default: nil (no output)
Expand All @@ -201,6 +202,10 @@ class Telnet
#
# Port:: the port to connect to. Defaults to 23.
#
# Source:: the local IP address, or hostname from which to connect to
# remote host, as a String.
# Defaults to nil, system will choose best "route".
#
# Binmode:: if false (the default), newline substitution is performed.
# Outgoing LF is
# converted to CRLF, and incoming CRLF is converted to LF. If
Expand Down Expand Up @@ -274,6 +279,7 @@ def initialize(options) # :yield: mesg
@options = options
@options["Host"] = "localhost" unless @options.has_key?("Host")
@options["Port"] = 23 unless @options.has_key?("Port")
@options["Source"] = nil unless @options.has_key?("Source")
@options["Prompt"] = /[$%#>] \z/n unless @options.has_key?("Prompt")
@options["Timeout"] = 10 unless @options.has_key?("Timeout")
@options["Waittime"] = 0 unless @options.has_key?("Waittime")
Expand Down Expand Up @@ -344,10 +350,10 @@ def @dumplog.log_dump(dir, x) # :nodoc:

begin
if @options["Timeout"] == false
@sock = TCPSocket.open(@options["Host"], @options["Port"])
@sock = TCPSocket.new(@options["Host"], @options["Port"], @options["Source"])
else
Timeout.timeout(@options["Timeout"], Net::OpenTimeout) do
@sock = TCPSocket.open(@options["Host"], @options["Port"])
@sock = TCPSocket.new(@options["Host"], @options["Port"], @options["Source"] )
end
end
rescue Net::OpenTimeout
Expand Down