+Mon Feb 19 19:59:28 EET 2001 Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+ * The client entry's userinfo pointer must be always valid.
+ Otherwise the [<unknown>] bug will surface beacuse the WHOIS
+ will fail since it requires the userinfo. Now, the userinfo
+ is allocated as "" if actual userinfo does not exist. Actually,
+ it must exist and it is totally Ok to drop client connections
+ that does not announce the userinfo. However, we will make
+ this workaround for now.
+
+ * Added silc_net_get_remote_port into lib/silcutil/silcnet.[ch]
+ to return the remote port by socket.
+
Mon Feb 19 14:26:49 EET 2001 Pekka Riikonen <priikone@poseidon.pspt.fi>
* Changed SILC_SERVER_COMMAND_EXEC_PENDING macro to the name
SILC_LOG_ERROR(("Bad command payload, packet dropped"));
silc_buffer_free(packet->buffer);
silc_packet_context_free(packet);
+ silc_socket_free(ctx->sock);
silc_free(ctx);
return;
}
/* If this function was called from pending command then instead of
processing the command now, register a pending command callback which
will process it after we've received the automatic USERS command
- reply. */
- silc_server_command_pending(server, SILC_COMMAND_USERS, 0,
- silc_server_command_destructor,
- silc_server_command_users,
- silc_server_command_dup(cmd));
+ reply which server will send in JOIN. */
+ silc_server_command_pending(server, SILC_COMMAND_USERS, 0, NULL,
+ silc_server_command_users, cmd);
cmd->pending = TRUE;
silc_buffer_free(buffer);
silc_buffer_free(idp);
break;
if (cmd == NULL || !cmd->cb) {
- silc_free(ctx);
+ silc_server_command_reply_free(ctx);
return;
}
void silc_server_command_reply_##func(void *context)
/* Prototypes */
+void silc_server_command_reply_free(SilcServerCommandReplyContext cmd);
void silc_server_command_reply_process(SilcServer server,
SilcSocketConnection sock,
SilcBuffer buffer);
}
if (!newsocket->hostname)
newsocket->hostname = strdup(newsocket->ip);
+ newsocket->port = silc_net_get_remote_port(sock);
SILC_LOG_INFO(("Incoming connection from %s (%s)", newsocket->hostname,
newsocket->ip));
Mun huone:Mun servo:Pekka Riikonen:priikone@poseidon.pspt.fi
[ServerInfo]
-lassi.kuo.fi.ssh.com:10.2.1.7:Kuopio, Finland:1334
+lassi.kuo.fi.ssh.com:212.146.8.245:Kuopio, Finland:1334
[ListenPort]
-10.2.1.7:10.2.1.7:1334
+212.146.8.245:212.146.8.245:1334
[Logging]
infologfile:silcd2.log:10000
[AdminConnection]
[ServerConnection]
-10.2.1.7:passwd:priikone:1333:1:1
+212.146.8.245:passwd:priikone:1333:1:1
[RouterConnection]
-10.2.1.7:passwd:priikone:1335:1:1:0
+212.146.8.245:passwd:priikone:1335:1:1:0
[DenyConnection]
[RedirectClient]
conn->nickname = strdup(client->username);
conn->sock->hostname = conn->remote_host;
+ conn->sock->ip = strdup(conn->remote_host);
conn->sock->port = conn->remote_port;
/* Allocate internal Key Exchange context. This is sent to the
silc_net_close_connection(sock->sock);
client->ops->say(client, sock->user_data,
- "Closed connection to host %s", sock->hostname ?
- sock->hostname : sock->ip);
+ "Closed connection to host %s", sock->hostname);
/* Free everything */
if (sock->user_data) {
int silc_packet_send(SilcSocketConnection sock, int force_send)
{
+ SILC_LOG_DEBUG(("Sending packet to %s:%d [%s]", sock->hostname,
+ sock->port,
+ (sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
+ sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
+ sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
+ "Router")));
+
/* Send now if forced to do so */
if (force_send == TRUE) {
int ret;
{
int ret;
+ SILC_LOG_DEBUG(("Receiving packet from %s:%d [%s]", sock->hostname,
+ sock->port,
+ (sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
+ sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
+ sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
+ "Router")));
+
/* Allocate the incoming data buffer if not done already. */
if (!sock->inbuf)
sock->inbuf = silc_buffer_alloc(SILC_PACKET_DEFAULT_SIZE);
-
+
/* Read some data from connection */
ret = silc_packet_read(sock->sock, sock->inbuf);
- /* Error */
- if (ret == -1) {
- SILC_LOG_ERROR(("Error reading packet, dropped"));
- }
-
return ret;
}
SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip));
}
+/* Return remote port by socket. */
+
+unsigned short silc_net_get_remote_port(int sock)
+{
+ struct sockaddr_in remote;
+ int len;
+
+ memset(&remote, 0, sizeof(remote));
+ len = sizeof(remote);
+ if (getpeername(sock, (struct sockaddr *)&remote, &len) < 0)
+ return 0;
+
+ return ntohs(remote.sin_port);
+}
+
/* Return name of localhost. */
char *silc_net_localhost()
int silc_net_set_socket_opt(int sock, int level, int option, int on);
int silc_net_is_ip(const char *addr);
void silc_net_check_host_by_sock(int sock, char **hostname, char **ip);
+unsigned short silc_net_get_remote_port(int sock);
char *silc_net_localhost();
#endif