+Sun Dec 17 14:40:08 EET 2000 Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+ * Added `require_reverse_mapping' boolean value to ServerParams
+ structure. If TRUE (not default) the server will require that
+ the connecting host has fully qualified domain name.
+
+ If the reverse mapping is not required and hostname could not be
+ found the IP address is used as hostname.
+
Sat Dec 16 17:39:54 EET 2000 Pekka Riikonen <priikone@poseidon.pspt.fi>
* Implemented version string checking to both client and server.
The check is incomplete currently due to the abnormal version
strings used in development version of SILC.
+ * Changed all command functions in server to use the new
+ CHECK_ARGS macro.
+
Fri Dec 15 15:55:12 EET 2000 Pekka Riikonen <priikone@poseidon.pspt.fi>
* Changed char *data to unsigned char *data in ID Cache system to
if (!strchr(entry->username, '@')) {
strncat(uh, "@", 1);
hsock = (SilcSocketConnection)entry->connection;
- len = hsock->hostname ? strlen(hsock->hostname) : strlen(hsock->ip);
- strncat(uh, hsock->hostname ? hsock->hostname : hsock->ip, len);
+ len = strlen(hsock->hostname);
+ strncat(uh, hsock->hostname, len);
}
SILC_PUT32_MSB((time(NULL) - entry->data.last_receive), idle);
if (!strchr(entry->username, '@')) {
strncat(uh, "@", 1);
hsock = (SilcSocketConnection)entry->connection;
- len = hsock->hostname ? strlen(hsock->hostname) : strlen(hsock->ip);
- strncat(uh, hsock->hostname ? hsock->hostname : hsock->ip, len);
+ len = strlen(hsock->hostname);
+ strncat(uh, hsock->hostname, len);
}
packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY,
sock = (SilcSocketConnection)client->connection;
idata = (SilcIDListData)client;
- SILC_LOG_DEBUG(("Sending packet to client %s",
- sock->hostname ? sock->hostname : sock->ip));
+ SILC_LOG_DEBUG(("Sending packet to client %s (%s)",
+ sock->hostname, sock->ip));
/* Send the packet */
silc_server_packet_send_to_channel_real(server, sock, &packetdata,
unsigned short conn_type;
unsigned char *auth_data;
- SILC_LOG_INFO(("Performing authentication protocol for %s",
- ctx->sock->hostname ? ctx->sock->hostname :
- ctx->sock->ip));
+ SILC_LOG_INFO(("Performing authentication protocol for %s (%s)",
+ ctx->sock->hostname, ctx->sock->ip));
/* Parse the received authentication data packet. The received
payload is Connection Auth Payload. */
if (server->rng)
silc_rng_free(server->rng);
+#ifdef SILC_SIM
while ((sim = silc_dlist_get(server->sim)) != SILC_LIST_END) {
silc_dlist_del(server->sim, sim);
silc_sim_free(sim);
}
silc_dlist_uninit(server->sim);
+#endif
if (server->params)
silc_free(server->params);
server->params->retry_interval_max = SILC_SERVER_RETRY_INTERVAL_MAX;
server->params->retry_keep_trying = FALSE;
server->params->protocol_timeout = 60;
+ server->params->require_reverse_mapping = FALSE;
/* Set log files where log message should be saved. */
server->config->server = server;
server->local_list->servers = silc_idcache_alloc(0);
server->local_list->channels = silc_idcache_alloc(0);
- /* XXX for now these are allocated for normal server as well as these
- hold some global information that the server has fetched from its
- router. For router these are used as they are supposed to be used
- on router. The XXX can be remoevd later if this is the way we are
- going to do this in the normal server as well. */
+ /* These are allocated for normal server as well as these hold some
+ global information that the server has fetched from its router. For
+ router these are used as they are supposed to be used on router. */
server->global_list->clients = silc_idcache_alloc(0);
server->global_list->servers = silc_idcache_alloc(0);
server->global_list->channels = silc_idcache_alloc(0);
SILC_LOG_DEBUG(("Server stopped"));
}
-/* The heart of the server. This runs the scheduler thus runs the server. */
+/* The heart of the server. This runs the scheduler thus runs the server.
+ When this returns the server has been stopped and the program will
+ be terminated. */
void silc_server_run(SilcServer server)
{
/* Add the connected router to local server list */
server->standalone = FALSE;
- id_entry = silc_idlist_add_server(server->local_list,
- sock->hostname ? sock->hostname : sock->ip,
+ id_entry = silc_idlist_add_server(server->local_list, sock->hostname,
SILC_ROUTER, ctx->dest_id, NULL, sock);
if (!id_entry) {
if (ctx->dest_id)
/* XXX This MUST be done async as this will block the entire server
process. Either we have to do our own resolver stuff or in the future
we can use threads. */
- /* Perform mandatory name and address lookups for the remote host. */
+ /* Perform name and address lookups for the remote host. */
silc_net_check_host_by_sock(sock, &newsocket->hostname, &newsocket->ip);
- if (!newsocket->ip || !newsocket->hostname) {
- SILC_LOG_DEBUG(("IP lookup/DNS lookup failed"));
- SILC_LOG_ERROR(("IP lookup/DNS lookup failed"));
+ if ((server->params->require_reverse_mapping && !newsocket->hostname) ||
+ !newsocket->ip) {
+ SILC_LOG_ERROR(("IP/DNS lookup failed"));
return;
}
+ if (!newsocket->hostname)
+ newsocket->hostname = strdup(newsocket->ip);
SILC_LOG_INFO(("Incoming connection from %s (%s)", newsocket->hostname,
newsocket->ip));
unsigned long retry_interval_min;
unsigned long retry_interval_min_usec;
unsigned long retry_interval_max;
- unsigned int retry_keep_trying;
+ char retry_keep_trying;
unsigned long protocol_timeout;
unsigned long protocol_timeout_usec;
+
+ char require_reverse_mapping;
} *SilcServerParams;
/* Macros */
/*
* $Id$
* $Log$
+ * Revision 1.3 2000/12/17 13:07:35 priikone
+ * Added require_reverse_mapping for ServerParams.
+ *
* Revision 1.2 2000/10/31 19:48:32 priikone
* A LOT updates. Cannot separate. :)
*
return inet_aton(addr, &tmp);
}
-/* Performs lookups for remote name and IP address. */
+/* Performs lookups for remote name and IP address. This peforms reverse
+ lookup as well to verify that the IP has FQDN. */
void silc_net_check_host_by_sock(int sock, char **hostname, char **ip)
{
if (!dest)
return;
- /* Get same hsot by name to see that the remote host really is
+ /* Get same host by name to see that the remote host really is
the who it says it is */
memset(host_name, 0, sizeof(host_name));
memcpy(host_name, dest->h_name, strlen(dest->h_name));