Class: Ident
Attributes
Instance Attributes
inbound | [RW] | public |
Returns the value of attribute inbound. |
---|---|---|---|
ip | [RW] | public |
Returns the value of attribute ip. |
outbound | [RW] | public |
Returns the value of attribute outbound. |
response | [R] | public |
Returns the value of attribute response. |
timeout | [RW] | public |
Returns the value of attribute timeout. |
Constants
- KNOWN_ERRORS
- ["INVALID-PORT" "NO-USER" "HIDDEN-USER" "UNKNOWN-ERROR"]
Constructor Summary
86 87 88 89 |
# File 'lib/ident.rb', line 86 def initialize(ip = nil, outbound = nil, inbound = nil, timeout = 10) @ip, @outbound, @inbound, @timeout = ip, outbound, inbound, timeout @response = nil end |
Public Visibility
Public Class Method Summary
request(ip, outbound, inbound, timeout_after = 10) |
This method connects to an identd at `ip` and queries information for the connection `outbound`->`inbound` where `outbound` is the port a connection is coming from (usually anything >1024) and `inbound` is the port connected to, the port your service is listening on (e. Returns: Response::USERID |
---|
Public Instance Method Summary
#request |
---|
Public Class Method Details
request
This method connects to an identd at `ip` and queries information for the connection `outbound`->`inbound` where `outbound` is the port a connection is coming from (usually anything >1024) and `inbound` is the port connected to, the port your service is listening on (e.g. 6667 in the case of an IRCd)
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/ident.rb', line 116 def self.request(ip, outbound, inbound, timeout_after = 10) r = nil timeout(timeout_after) do t = TCPSocket.new(ip, 113) t.puts [outbound, inbound].join(', ') r = t.gets t.close end # in case the identd just kills our connection r ||= "#{outbound}, #{inbound}:ERROR:UNKNOWN-ERROR" r.chomp! Response.from(r) end |
Public Instance Method Details
request
92 93 94 |
# File 'lib/ident.rb', line 92 def request @response = self.class.request(@ip, @outbound, @inbound, @timeout) end |