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

public initialize(ip = nil, outbound = nil, inbound = nil, timeout = 10)

Meta Tags

See Also:

Ident.request
[View source]


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

public Response::USERID 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.g. 6667 in the case of an IRCd)

Meta Tags

Example: user A connects to our server on port 23, coming from 123.123.123.123 on port 6789

 Ident.request('123.123.123.123', 6789, 23)

Parameters:

[String] ip

The IP of the ident server

[Integer] outbound

The port from which the connection is coming

[Integer] inbound

The port to which was connected

[Integer] timeout_after

The timeout, defaults to 10 seconds

Returns:

[Response::USERID]

if we successfully queried the ident server

[Response::ERROR]

in case of an error

Raises:

[Timeout::Error]

In case of a timeout

[Errno::ECONNREFUSED]

If no identd was running at the destination host

[View source]


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

public request

Meta Tags

See Also:

Ident.request
[View source]


94
95
96
# File 'lib/ident.rb', line 94

def request
  @response = self.class.request(@ip, @outbound, @inbound, @timeout)
end
Generated on Thursday, October 15 2009 at 12:40:53 AM by YARD 0.2.3.3 (ruby-1.9.1).