Changeset f1f7b5e


Ignore:
Timestamp:
2010-07-24T22:50:23Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
8b01217
Parents:
2945c6f
Message:

Take the local address from the IM/IRC connection when setting up a listening
socket for file transfers.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dcc.c

    r2945c6f rf1f7b5e  
    104104        /* listen and request */
    105105
    106         if( ( df->fd = ft_listen( &saddr, host, port, TRUE, &errmsg ) ) == -1 )
     106        if( ( df->fd = ft_listen( &saddr, host, port, irc->fd, TRUE, &errmsg ) ) == -1 )
    107107        {
    108108                dcc_abort( df, "Failed to listen locally, check your ft_listen setting in bitlbee.conf: %s", errmsg );
  • lib/ftutil.c

    r2945c6f rf1f7b5e  
    3636 * Creates a listening socket and returns it in saddr_ptr.
    3737 */
    38 int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int for_bitlbee_client, char **errptr )
     38int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, char **errptr )
    3939{
    4040        int fd, gret, saddrlen;
     
    8383                }
    8484        }
     85        else if( copy_fd >= 0 && getsockname( copy_fd, (struct sockaddr*) &saddrs, &ssize ) == 0 &&
     86                 ( saddrs.ss_family == AF_INET || saddrs.ss_family == AF_INET6 ) &&
     87                 getnameinfo( (struct sockaddr*) &saddrs, ssize, host, HOST_NAME_MAX,
     88                              NULL, 0, NI_NUMERICHOST ) == 0 )
     89        {
     90                /* We just took our local address on copy_fd, which is likely to be a
     91                   sensible address from which we can do a file transfer now - the
     92                   most sensible we can get easily. */
     93        }
    8594        else
    8695        {
     
    117126        }
    118127
     128        ssize = sizeof( struct sockaddr_storage );
    119129        ASSERTSOCKOP( getsockname( fd, ( struct sockaddr *)saddr, &ssize ), "Getting socket name" );
    120130
  • lib/ftutil.h

    r2945c6f rf1f7b5e  
    3838/* This function should be used with care. host should be AT LEAST a
    3939   char[HOST_NAME_MAX+1] and port AT LEAST a char[6]. */
    40 int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int for_bitlbee_client, char **errptr );
     40int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, char **errptr );
  • protocols/jabber/s5bytestream.c

    r2945c6f rf1f7b5e  
    911911               
    912912                if( strcmp( proxy, "<local>" ) == 0 ) {
    913                         if( ( tf->fd = ft_listen( &tf->saddr, host, port, FALSE, &errmsg ) ) != -1 ) {
     913                        if( ( tf->fd = ft_listen( &tf->saddr, host, port, jd->fd, FALSE, &errmsg ) ) != -1 ) {
    914914                                sh = g_new0( jabber_streamhost_t, 1 );
    915915                                sh->jid = g_strdup( tf->ini_jid );
Note: See TracChangeset for help on using the changeset viewer.