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
88 89 90 91 |
# File 'lib/ident.rb', line 88 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)
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ident.rb', line 118 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
94 95 96 |
# File 'lib/ident.rb', line 94 def request @response = self.class.request(@ip, @outbound, @inbound, @timeout) end |