Changeset 547 for trunk/src/ocatsocks.c


Ignore:
Timestamp:
04/26/10 13:29:15 (2 years ago)
Author:
eagle
Message:
  • configure.ac refined
  • OC now compiles and runs on Solaris 10 using the Universal TUN/TAP driver version 1.1 (http://vtun.sourceforge.net/tun/index.html)
  • ocathosts.[ch] added. It reads IPv6 addresses from /etc/hosts
  • /etc/hosts reverse lookup for I2P .b32 names added
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ocatsocks.c

    r534 r547  
    2727#include "ocat.h" 
    2828#include "ocat_netdesc.h" 
     29#include "ocathosts.h" 
    2930 
    3031 
     
    3738int socks_send_request(const SocksQueue_t *sq) 
    3839{ 
    39    int len, ret; 
    40    char buf[SOCKS_BUFLEN], onion[NDESC(name_size)]; 
     40   int len, ret = -1; 
     41   char buf[SOCKS_BUFLEN], onion[NI_MAXHOST]; 
    4142   SocksHdr_t *shdr = (SocksHdr_t*) buf; 
    4243 
    43    ipv6tonion(&sq->addr, onion); 
    44    strlcat(onion, NDESC(domain), sizeof(onion)); 
    45    log_msg(LOG_INFO, "trying to connect to \"%s\" [%s]", onion, inet_ntop(AF_INET6, &sq->addr, buf, SOCKS_BUFLEN)); 
     44   // Do a hostname lookup if network type is I2P. 
     45   // This is done in order to be able to retrieve a 256 bit base32  
     46   // host from e.g. /etc/hosts. 
     47   if ((CNF(net_type) == NTYPE_I2P) && CNF(hosts_lookup)) 
     48   { 
     49      hosts_check(); 
     50      ret = hosts_get_name(&sq->addr, onion, sizeof(onion)); 
     51   } 
     52 
     53   // If no hostname was found above or network type is Tor 
     54   // do usual OnionCat name transformation. 
     55   if (ret == -1) 
     56   { 
     57      ipv6tonion(&sq->addr, onion); 
     58      strlcat(onion, NDESC(domain), sizeof(onion)); 
     59   } 
     60 
     61   if (inet_ntop(AF_INET6, &sq->addr, buf, sizeof(buf)) == NULL) 
     62   { 
     63      log_msg(LOG_WARNING, "inet_ntop failed: \"%s\"", strerror(errno)); 
     64      buf[0] = '\0'; 
     65   } 
     66   log_msg(LOG_INFO, "trying to connect to \"%s\" [%s] on %d", onion, buf, sq->fd); 
    4667 
    4768   log_debug("doing SOCKS4a handshake"); 
Note: See TracChangeset for help on using the changeset viewer.