+Sun Oct 26 21:19:02 EET 2003 Pekka Riikonen <priikone@silcnet.org>
+
+ * Resolve the IP for file transfer listener from the connection
+ socket. Affected file lib/silcclient/client_ftp.c.
+
+ * Accept NULL hostname parameter in the functions
+ silc_net_check_[local|remote]_by_socket. Do not reverse lookup
+ if hostname is not wanted.
+
Fri Oct 24 21:24:12 CEST 2003 Jochen Eisinger <jochen@penguin-breeder.org>
* Fixed race condition between silc_client_init and
/* Create the listener for incoming key exchange protocol. */
if (!do_not_bind) {
+ session->listener = -1;
if (local_ip)
session->hostname = strdup(local_ip);
else
- session->hostname = silc_net_localip();
- session->listener = silc_net_create_server(local_port, session->hostname);
+ silc_net_check_local_by_sock(conn->sock->sock, NULL,
+ &session->hostname);
+ if (session->hostname)
+ session->listener = silc_net_create_server(local_port,
+ session->hostname);
if (session->listener < 0) {
/* Could not create listener. Do the second best thing; send empty
key agreement packet and let the remote client provide the point
for the key exchange. */
SILC_LOG_DEBUG(("Could not create listener"));
silc_free(session->hostname);
+ session->listener = 0;
session->hostname = NULL;
session->port = 0;
} else {
} else {
/* Add the listener for the key agreement */
SILC_LOG_DEBUG(("Creating listener for file transfer"));
- session->hostname = silc_net_localip();
- session->listener = silc_net_create_server(0, session->hostname);
+ session->listener = -1;
+ silc_net_check_local_by_sock(conn->sock->sock, NULL, &session->hostname);
+ if (session->hostname)
+ session->listener = silc_net_create_server(0, session->hostname);
if (session->listener < 0) {
SILC_LOG_DEBUG(("Could not create listener"));
+ session->listener = 0;
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
"Cannot create listener on %s: %s",
session->hostname, strerror(errno));
struct sockaddr_storage remote;
char s[NI_MAXHOST];
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving remote hostname and IP address"));
struct sockaddr_in remote;
char *host_ip;
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving remote hostname and IP address"));
return FALSE;
#endif
- /* Get host by address */
- if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
- return FALSE;
+ /* Do reverse lookup if we want hostname too. */
+ if (hostname) {
+ /* Get host by address */
+ if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
+ return FALSE;
- *hostname = silc_memdup(host, strlen(host));
- SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
+ *hostname = silc_memdup(host, strlen(host));
+ SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
- /* Reverse */
- if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
- return FALSE;
+ /* Reverse */
+ if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
+ return FALSE;
- if (strcmp(*ip, host))
- return FALSE;
+ if (strcmp(*ip, host))
+ return FALSE;
+ }
SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip));
return TRUE;
struct sockaddr_storage local;
char s[NI_MAXHOST];
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving local hostname and IP address"));
struct sockaddr_in local;
char *host_ip;
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving local hostname and IP address"));
return FALSE;
#endif
- /* Get host by address */
- if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
- return FALSE;
+ /* Do reverse lookup if we want hostname too. */
+ if (hostname) {
+ /* Get host by address */
+ if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
+ return FALSE;
- *hostname = silc_memdup(host, strlen(host));
- SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
+ *hostname = silc_memdup(host, strlen(host));
+ SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
- /* Reverse */
- if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
- return FALSE;
+ /* Reverse */
+ if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
+ return FALSE;
- if (strcmp(*ip, host))
- return FALSE;
+ if (strcmp(*ip, host))
+ return FALSE;
+ }
SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip));
return TRUE;