Previous: Writing coservers, Up: Coserver [Contents][Index]
The Identification protocol is briefly documented in RFC1413. It provides a means to determine the identity of a user of a particular TCP connection. Given a TCP port number pair, it returns a character string which identifies the owner of that connection on the server’s (that is the client’s) system.
This is a connection based application on TCP. A server listens for TCP connections on TCP port 113 (decimal). Once a connection is established, the server reads a line of data which specifies the connection of interest. If it exists, the system dependent user identifier of the connection of interest is sent as the reply. The server may then either shut down the connection or it may continue to read/respond to more queries.
The Ident coserver is a client to this kind of service. For every established network connection you can use this service by calling the appropriate macro from coserver.h. But you could also use the Ident coserver as is without this macro. The messages from Serveez to this coserver are formatted this way:
Format: RemoteAddressInDottedDecimals ":" RemotePort ":" LocalPort Macro: svz_coserver_ident (sock, MyIdentCallback, sock->id, sock->version);
In this context sock
is of type svz_socket_t
and
MyIdentCallback
is something like the following example. Both
of the last two (optional) arguments identify a valid socket structure
and user
can be NULL
if there is no ident daemon running on the
foreign machine. The last two argument within the above macro will be the
last two arguments in the callback below. Thus you will know what kind of
data the invocation of the callback is related to.
Callback: int MyIdentCallback (char *user, int id, int version) { printf ("Identified user: %s\n", user); return 0; }
The DNS coserver is using gethostbyname
to translate a given
hostname to the associated IP address. The format of the coserver input
line and the macro from coserver.h is shown below. The IRC server is
currently using this coserver for resolving its ‘?-Lines’.
See Existing servers, for more information. In the example below
realhost
is something like ‘www.lkcc.org’.
Format: RemoteHostname Macro: svz_coserver_dns (realhost, irc_connect_server, ircserver, NULL); Callback: int irc_connect_server (char *ip, irc_server_t *server) { printf ("The ip address is: %s\n", ip); return 0; }
As easily guessed from the name this coserver is just doing the reverse
as the DNS coserver. It translates a given IP address into a hostname
using gethostbyaddr
. In the macro the ip address is given
as an unsigned long
in host byte order. The Reverse DNS
coserver itself takes something like ‘192.168.2.1’.
Format: RemoteAddressInDottedDecimals Macro: svz_coserver_reverse (addr, MyReverseCallback, sock->id, sock->version); Callback: int MyReverseCallback (char *host, int id, int version) { printf ("Hostname is: %s\n", host); return 0; }
Previous: Writing coservers, Up: Coserver [Contents][Index]