Changeset 1a26a9


Ignore:
Timestamp:
09/26/09 11:42:32 (3 years ago)
Author:
Erik Ekman <yarrick@…>
Branches:
master
Children:
b17790
Parents:
c5bdf0
git-author:
Erik Ekman <yarrick@…> (09/26/09 11:42:32)
git-committer:
Erik Ekman <erik@…> (02/04/12 20:34:04)
Message:

#82, switch to gethostbyname() for win32 support

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rc5bdf0 r1a26a9  
    2929                Patch by Anne Bezemer, merge help by logix. 
    3030        - Merged low-latency patch from Anne Bezemer, fixes #76. 
    31         - Resolve client nameserver argument (except on win32), #82. 
     31        - Resolve client nameserver argument if given as hostname, fixes #82. 
    3232 
    33332009-06-01: 0.5.2 "WifiFree" 
  • man/iodine.8

    rc5bdf0 r1a26a9  
    222222The nameserver to use to relay the dns traffic. This can be any relaying 
    223223nameserver or the server running iodined if reachable. This field can be 
    224 given as an IP address, or as a hostname (except on Win32 currently). 
    225 This argument is optional, and if not specified a nameserver will be read 
    226 from the 
     224given as an IP address, or as a hostname. This argument is optional, and  
     225if not specified a nameserver will be read from the 
    227226.I /etc/resolv.conf 
    228227file. 
  • src/client.c

    rc5bdf0 r1a26a9  
    146146 
    147147        if (inet_aton(cp, &addr) != 1) { 
     148                /* try resolving if a domain is given */ 
     149                struct hostent *host; 
     150                const char *err; 
     151                host = gethostbyname(cp); 
     152                if (host != NULL && h_errno > 0) { 
     153                        int i = 0; 
     154                        while (host->h_addr_list[i] != 0) { 
     155                                addr = *(struct in_addr *) host->h_addr_list[i++]; 
     156                                fprintf(stderr, "Resolved %s to %s\n", cp, inet_ntoa(addr)); 
     157                                goto setaddr; 
     158                        } 
     159                } 
    148160#ifndef WINDOWS32 
    149                 /* MinGW only supports getaddrinfo on WinXP and higher.. 
    150                  * so turn it off in windows for now 
    151                  * 
    152                  * try resolving if a domain is given */ 
    153                 struct addrinfo *addrinfo; 
    154                 struct addrinfo *res; 
    155                 if (getaddrinfo(cp, NULL, NULL, &addrinfo) == 0) { 
    156                         struct sockaddr_in *inaddr; 
    157                         for (res = addrinfo; res != NULL; res = res->ai_next) { 
    158                                 inaddr = (struct sockaddr_in *) res->ai_addr; 
    159                                 addr = inaddr->sin_addr; 
     161                err = hstrerror(h_errno); 
     162#else 
     163                { 
     164                        DWORD wserr = WSAGetLastError(); 
     165                        switch (wserr) { 
     166                        case WSAHOST_NOT_FOUND: 
     167                                err = "Host not found"; 
    160168                                break; 
    161                         } 
    162                         freeaddrinfo(addrinfo); 
    163                 } else 
    164 #endif 
    165                         errx(1, "error parsing nameserver address: '%s'", cp); 
    166         } 
    167  
     169                        case WSANO_DATA: 
     170                                err = "No data record found"; 
     171                                break; 
     172                        default: 
     173                                err = "Unknown error"; 
     174                                break; 
     175                        } 
     176                } 
     177#endif /* !WINDOWS32 */ 
     178                errx(1, "error resolving nameserver '%s': %s", cp, err); 
     179        } 
     180 
     181setaddr: 
    168182        memset(&nameserv, 0, sizeof(nameserv)); 
    169183        nameserv.sin_family = AF_INET; 
  • src/iodine.c

    rc5bdf0 r1a26a9  
    9090        fprintf(stderr, "  -z context, to apply specified SELinux context after initialization\n"); 
    9191        fprintf(stderr, "  -F pidfile to write pid to a file\n"); 
    92         fprintf(stderr, "nameserver is the IP number/hostname of the relaying nameserver\n    " 
    93                         "(hostname not supported on win32). if absent, /etc/resolv.conf is used\n"); 
     92        fprintf(stderr, "nameserver is the IP number/hostname of the relaying nameserver. if absent, /etc/resolv.conf is used\n"); 
    9493        fprintf(stderr, "topdomain is the FQDN that is delegated to the tunnel endpoint.\n"); 
    9594 
Note: See TracChangeset for help on using the changeset viewer.