Changeset 68fdcd372dd8543d8d885b9ba882d7291319b2fc

Show
Ignore:
Timestamp:
01/21/11 20:44:07 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1295642647 +0000
git-parent:

[5c8387e2362c33a8359b6892d55e77b0c5a5be8b]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1295642647 +0000
Message:

allow noit.socket to take an address from which address family can be inferred. Before we passed an optional argument of 'inet' or 'inet6' which continue to work. Now you can pass '::1' or another valid IPv6 address and AF_INET6 will be selected.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/lua_noit.c

    r3bfc79e r68fdcd3  
    10921092  int n = lua_gettop(L); 
    10931093  uint8_t family = AF_INET; 
     1094  union { 
     1095    struct in_addr addr4; 
     1096    struct in6_addr addr6; 
     1097  } a; 
    10941098 
    10951099  if(n > 0 && lua_isstring(L,1)) { 
     
    10971101    if(!strcmp(fam, "inet")) family = AF_INET; 
    10981102    else if(!strcmp(fam, "inet6")) family = AF_INET6; 
    1099     else luaL_error(L, "noit.socket unknown family %s", fam); 
     1103    else if(inet_pton(AF_INET, fam, &a) == 1) family = AF_INET; 
     1104    else if(inet_pton(AF_INET6, fam, &a) == 1) family = AF_INET6; 
     1105    else luaL_error(L, "noit.socket family for %s unknown", fam); 
    11001106  } 
    11011107