Changeset 525


Ignore:
Timestamp:
11/13/09 13:11:06 (2 years ago)
Author:
eagle
Message:

Garlicat, 1st try

Location:
branches/garlicat
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/garlicat/configure

    r514 r525  
    11#! /bin/sh 
    22# Guess values for system-dependent variables and create Makefiles. 
    3 # Generated by GNU Autoconf 2.62 for onioncat 0.2.0.r514. 
     3# Generated by GNU Autoconf 2.62 for onioncat 0.2.0.r525. 
    44# 
    55# Report bugs to <rahra@cypherpunk.at>. 
     
    597597PACKAGE_NAME='onioncat' 
    598598PACKAGE_TARNAME='onioncat' 
    599 PACKAGE_VERSION='0.2.0.r514' 
    600 PACKAGE_STRING='onioncat 0.2.0.r514' 
     599PACKAGE_VERSION='0.2.0.r525' 
     600PACKAGE_STRING='onioncat 0.2.0.r525' 
    601601PACKAGE_BUGREPORT='rahra@cypherpunk.at' 
    602602 
     
    12601260  # This message is too long to be a string in the A/UX 3.1 sh. 
    12611261  cat <<_ACEOF 
    1262 \`configure' configures onioncat 0.2.0.r514 to adapt to many kinds of systems. 
     1262\`configure' configures onioncat 0.2.0.r525 to adapt to many kinds of systems. 
    12631263 
    12641264Usage: $0 [OPTION]... [VAR=VALUE]... 
     
    13301330if test -n "$ac_init_help"; then 
    13311331  case $ac_init_help in 
    1332      short | recursive ) echo "Configuration of onioncat 0.2.0.r514:";; 
     1332     short | recursive ) echo "Configuration of onioncat 0.2.0.r525:";; 
    13331333   esac 
    13341334  cat <<\_ACEOF 
     
    14221422if $ac_init_version; then 
    14231423  cat <<\_ACEOF 
    1424 onioncat configure 0.2.0.r514 
     1424onioncat configure 0.2.0.r525 
    14251425generated by GNU Autoconf 2.62 
    14261426 
     
    14361436running configure, to aid debugging if configure makes a mistake. 
    14371437 
    1438 It was created by onioncat $as_me 0.2.0.r514, which was 
     1438It was created by onioncat $as_me 0.2.0.r525, which was 
    14391439generated by GNU Autoconf 2.62.  Invocation command line was 
    14401440 
     
    20852085# Define the identity of the package. 
    20862086 PACKAGE='onioncat' 
    2087  VERSION='0.2.0.r514' 
     2087 VERSION='0.2.0.r525' 
    20882088 
    20892089 
     
    22362236 
    22372237cat >>confdefs.h <<\_ACEOF 
    2238 #define SVN_REVISION "514" 
     2238#define SVN_REVISION "525" 
    22392239_ACEOF 
    22402240 
     
    52095209# values after options handling. 
    52105210ac_log=" 
    5211 This file was extended by onioncat $as_me 0.2.0.r514, which was 
     5211This file was extended by onioncat $as_me 0.2.0.r525, which was 
    52125212generated by GNU Autoconf 2.62.  Invocation command line was 
    52135213 
     
    52625262cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 
    52635263ac_cs_version="\\ 
    5264 onioncat config.status 0.2.0.r514 
     5264onioncat config.status 0.2.0.r525 
    52655265configured by $0, generated by GNU Autoconf 2.62, 
    52665266  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" 
  • branches/garlicat/src/Makefile.am

    r486 r525  
    11bin_PROGRAMS = ocat 
    2 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c 
    3 include_HEADERS = ocat.h strlcpy.c strlcat.c 
     2ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c ocat_netdesc.c 
     3include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
    44 
  • branches/garlicat/src/Makefile.in

    r508 r525  
    5858        ocatipv4route.$(OBJEXT) ocateth.$(OBJEXT) ocatsocks.$(OBJEXT) \ 
    5959        ocatlibe.$(OBJEXT) ocatctrl.$(OBJEXT) ocatipv6route.$(OBJEXT) \ 
    60         ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) 
     60        ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) \ 
     61        ocat_netdesc.$(OBJEXT) 
    6162ocat_OBJECTS = $(am_ocat_OBJECTS) 
    6263ocat_LDADD = $(LDADD) 
     
    168169sysconfdir = @sysconfdir@ 
    169170target_alias = @target_alias@ 
    170 ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c 
    171 include_HEADERS = ocat.h strlcpy.c strlcat.c 
     171ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c ocat_netdesc.c 
     172include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
    172173all: all-am 
    173174 
     
    237238 
    238239@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat.Po@am__quote@ 
     240@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat_netdesc.Po@am__quote@ 
    239241@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocat_wintuntap.Po@am__quote@ 
    240242@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocatcompat.Po@am__quote@ 
  • branches/garlicat/src/ocat.c

    r523 r525  
    1818 
    1919#include "ocat.h" 
     20#include "ocat_netdesc.h" 
    2021 
    2122 
     
    3334         "   -f <config_file>      read config from config_file\n" 
    3435         "   -i                    convert onion hostname to IPv6 and exit\n" 
     36         "   -I                    GarliCat mode, use I2P instead of Tor\n" 
    3537         "   -l [<ip>:]<port>      set ocat listen address and port, default = 127.0.0.1:%d\n" 
    3638         "   -L <log_file>         log output to <log_file> (default = stderr)\n" 
     
    5153         OCAT_DIR, OCAT_CONNECT_LOG, CNF(create_clog),  
    5254         CNF(daemon), CNF(daemon) ^ 1, 
    53          CNF(debug_level), OCAT_LISTEN_PORT, 
     55         CNF(debug_level), NDESC(listen_port), 
    5456         CNF(pid_file), 
    5557         CNF(ocat_dest_port), ntohs(CNF(socks_dst)->sin_port),  
     
    237239   int urlconv = 0; 
    238240 
    239    snprintf(def, 100, "127.0.0.1:%d", OCAT_LISTEN_PORT); 
     241   snprintf(def, 100, "127.0.0.1:%d", NDESC(listen_port)); 
    240242 
    241243   init_setup(); 
     
    244246      usage(argv[0]), exit(1); 
    245247 
    246    while ((c = getopt(argc, argv, "abBCd:f:hrRiopl:t:T:s:u:4L:P:")) != -1) 
     248   while ((c = getopt(argc, argv, "abBCd:f:hrRiIopl:t:T:s:u:4L:P:")) != -1) 
    247249      switch (c) 
    248250      { 
     
    274276         case 'i': 
    275277            urlconv = 1; 
     278            break; 
     279 
     280         case 'I': 
     281            CNF(net_type) = NTYPE_I2P; 
    276282            break; 
    277283 
     
    340346            exit(1); 
    341347      } 
     348 
     349   // detect network type by command file name 
     350   // FIXME: this should be not hardcoded in that way 
     351   if (!strcmp(argv[0], "gcat") || !strcmp(argv[0], "garlicat")) 
     352      CNF(net_type) = NTYPE_I2P; 
     353 
     354   post_init_setup(); 
    342355 
    343356   if (!CNF(rand_addr) && !argv[optind]) 
     
    373386   // copy onion-URL from command line 
    374387   if (!CNF(rand_addr)) 
    375       strncpy(CNF(onion_url), argv[optind], ONION_NAME_SIZE); 
     388      strncpy(CNF(onion_url), argv[optind], NDESC(name_size)); 
    376389   // ...or generate a random one 
    377390   else 
     
    401414 
    402415   log_msg(LOG_INFO, "%s", CNF(version)); 
     416   log_msg(LOG_INFO, "OC is running in %s mode", CNF(net_type) == NTYPE_I2P ? "GarliCat (I2P)" : "OnionCat (Tor)"); 
    403417 
    404418#if 0 
  • branches/garlicat/src/ocat.h

    r523 r525  
    102102 
    103103#define IP6HLEN sizeof(struct ip6_hdr) 
    104 //! TOR prefix: FD87:D87E:EB43::/48 
     104/*//! TOR prefix: FD87:D87E:EB43::/48 
    105105#define TOR_PREFIX {{{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0,0,0,0,0,0,0,0,0,0}}} 
    106106#define TOR_PREFIX_LEN 48 
     
    111111#define TOR_PREFIX4 {0x0a000000} 
    112112#define TOR_PREFIX4_MASK 0xff000000 
    113 #endif 
     113#endif*/ 
    114114//! Length of an .onion-URL (without ".onion" and '\0') 
    115115#define ONION_URL_LEN 16 
    116 //! Total length of .onion-URL 
     116/*//! Total length of .onion-URL 
    117117#define ONION_NAME_SIZE (ONION_URL_LEN + 7) 
    118118//! Total length of .onion-URL (equal to ONION_NAME_SIZE) 
    119 #define ONION_NAME_LEN ONION_NAME_SIZE 
     119#define ONION_NAME_LEN ONION_NAME_SIZE*/ 
    120120 
    121121#define MAXPEERS 1024 
    122 //! Local listening port for incoming connections from TOR. 
     122/*//! Local listening port for incoming connections from TOR. 
    123123#define OCAT_LISTEN_PORT 8060 
    124124//! Local control port for querying status information. 
     
    127127#define OCAT_DEST_PORT 8060 
    128128//! SOCKS port of TOR proxy 
    129 #define TOR_SOCKS_PORT 9050 
     129#define TOR_SOCKS_PORT 9050*/ 
    130130#ifdef __OpenBSD__ 
    131131#define OCAT_UNAME "_tor" 
     
    235235#define VERSION_STRING_LEN 256 
    236236 
    237 typedef enum PeerType {PT_TOR, PT_I2P} PeerType_t; 
     237 
     238#define NTYPE_TOR 0 
     239#define NTYPE_I2P 1 
     240 
    238241 
    239242struct OcatSetup 
     
    256259   //! user name to change uid to 
    257260   char *usrname; 
    258    char onion_url[ONION_NAME_SIZE]; 
     261   char onion_url[SIZE_256]; 
    259262   struct in6_addr ocat_addr; 
    260263   //! flag to create connection log 
     
    308311   //! communication pipe for socks "selected" connector 
    309312   int socksfd[2]; 
     313   int net_type; 
    310314}; 
    311315 
     
    359363   unsigned inm; 
    360364   unsigned outm; 
    361    PeerType_t type; 
    362365} OcatPeer_t; 
    363366 
     
    566569void print_setup_struct(FILE *); 
    567570void init_setup(void); 
     571void post_init_setup(void); 
    568572void lock_setup(void); 
    569573void unlock_setup(void); 
  • branches/garlicat/src/ocatctrl.c

    r512 r525  
    2525 
    2626#include "ocat.h" 
     27#include "ocat_netdesc.h" 
    2728 
    2829 
     
    3738   int fd, c; 
    3839   FILE *ff, *fo; 
    39    char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[ONION_NAME_SIZE], timestr[32], *s, *tokbuf; 
     40   char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf; 
    4041   int rlen, cfd; 
    4142   struct tm *tm; 
  • branches/garlicat/src/ocatsetup.c

    r514 r525  
    2525 
    2626#include "ocat.h" 
     27#include "ocat_netdesc.h" 
    2728 
    2829 
     
    4647   //TOR_SOCKS_PORT,  
    4748   //OCAT_LISTEN_PORT,  
    48    OCAT_DEST_PORT, OCAT_CTRL_PORT,  
     49   0, 0, 
    4950   //! default tunfd is stdin/stdout 
    5051   {0, 1}, 
     
    5354   OCAT_UNAME, {0}, {{{0}}}, 0, 0, 1, OCAT_DIR, TUN_DEV, 
    5455   {'\0'},                                // tunname 
    55    0, TOR_PREFIX4, TOR_PREFIX4_MASK, 
     56   0,  
     57   //ADDR4_PREFIX, ADDR4_MASK 
     58   {0}, 0, 
    5659   NULL, 1, 
    5760#ifdef __CYGWIN__ 
     
    106109   , 
    107110   // socksfd 
    108    {-1, -1} 
     111   {-1, -1}, 
     112   // net_type 
     113   NTYPE_TOR 
    109114}; 
    110115 
     
    137142   snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s", PACKAGE_STRING, OCAT_AUTHOR); 
    138143#endif 
     144} 
     145 
     146 
     147void post_init_setup(void) 
     148{ 
     149   setup_.ocat_addr4 = NDESC(prefix4); 
     150   setup_.ocat_addr4_mask = NDESC(addr4_mask); 
     151   setup_.ocat_dest_port = NDESC(vdest_port); 
     152   setup_.ocat_ctrl_port = NDESC(ctrl_port); 
    139153 
    140154   ctrl_listen_.sin_family = AF_INET; 
     
    151165   ctrl_listen6_.sin6_len = sizeof(ctrl_listen6_); 
    152166#endif 
    153  
    154167} 
    155168 
     
    212225         "sizeof_setup           = %d\n" 
    213226         "term_req               = %d\n" 
     227         "net_type               = %d (%s)\n" 
    214228         , 
    215229         IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]), 
     
    244258         (int) strlen(setup_.version), VERSION_STRING_LEN, setup_.version, 
    245259         setup_.sizeof_setup, 
    246          setup_.term_req 
     260         setup_.term_req, 
     261         setup_.net_type, setup_.net_type == NTYPE_TOR ? "NTYPE_TOR" : setup_.net_type == NTYPE_I2P ? "NTYPE_I2P" : "unknown" 
    247262         ); 
    248263 
  • branches/garlicat/src/ocatsocks.c

    r508 r525  
    2626 
    2727#include "ocat.h" 
     28#include "ocat_netdesc.h" 
    2829 
    2930 
     
    3132static SocksQueue_t *socks_queue_ = NULL; 
    3233 
    33 #define SOCKS_BUFLEN (sizeof(SocksHdr_t) + ONION_NAME_SIZE + strlen(CNF(usrname)) + 2) 
     34#define SOCKS_BUFLEN (sizeof(SocksHdr_t) + NDESC(name_size) + strlen(CNF(usrname)) + 2) 
    3435 
    3536 
     
    3738{ 
    3839   int len, ret; 
    39    char buf[SOCKS_BUFLEN], onion[ONION_NAME_SIZE]; 
     40   char buf[SOCKS_BUFLEN], onion[NDESC(name_size)]; 
    4041   SocksHdr_t *shdr = (SocksHdr_t*) buf; 
    4142 
     
    246247{ 
    247248   int i; 
    248    char addrstr[INET6_ADDRSTRLEN], onstr[ONION_NAME_LEN], buf[SIZE_1K]; 
     249   char addrstr[INET6_ADDRSTRLEN], onstr[NDESC(name_size)], buf[SIZE_1K]; 
    249250   SocksQueue_t *squeue; 
    250251 
  • branches/garlicat/src/ocattun.c

    r511 r525  
    2727 
    2828#include "ocat.h" 
     29#include "ocat_netdesc.h" 
    2930 
    3031 
     
    6162      log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno)); 
    6263 
    63    snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, TOR_PREFIX_LEN, dev); 
     64   snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, NDESC(prefix_len), dev); 
    6465   log_debug("setting IP routing: \"%s\"", buf); 
    6566   if (system(buf) == -1) 
     
    9293   if (!CNF(use_tap)) 
    9394   { 
    94       snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, TOR_PREFIX_LEN); 
     95      snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, NDESC(prefix_len)); 
    9596      log_msg(LOG_INFO, "configuring tun IP: \"%s\"", buf); 
    9697      if (system(buf) == -1) 
     
    169170   { 
    170171#ifdef __OpenBSD__ 
    171       snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s prefixlen %d up", dev, astr, TOR_PREFIX_LEN); 
     172      snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s prefixlen %d up", dev, astr, NDESC(prefix_len)); 
    172173#else 
    173       snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s/%d up", dev, astr, TOR_PREFIX_LEN); 
     174      snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s/%d up", dev, astr, NDESC(prefix_len)); 
    174175#endif 
    175176      log_debug("setting IP on tun: \"%s\"", buf); 
     
    181182      // MacOSX requires the route to be set up manually 
    182183      // FIXME: the prefix shouldn't be hardcoded here 
    183       snprintf(buf, sizeof(buf), "route add -inet6 -net fd87:d87e:eb43:: -prefixlen %d -gateway %s", TOR_PREFIX_LEN, astr); 
     184      snprintf(buf, sizeof(buf), "route add -inet6 -net fd87:d87e:eb43:: -prefixlen %d -gateway %s", NDESC(prefix_len), astr); 
    184185      log_msg(LOG_INFO, "setup routing: \"%s\"", buf); 
    185186      if (system(buf) == -1) 
  • branches/garlicat/src/ocatv6conv.c

    r500 r525  
    2727 
    2828#include "ocat.h" 
     29#include "ocat_netdesc.h" 
    2930 
    3031static const char BASE32[] = "abcdefghijklmnopqrstuvwxyz234567"; 
     
    4041      50  51  52  53  54  55  56  57  58  59  5a */ 
    4142      15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };   
    42 static const struct in6_addr tor_prefix_ = TOR_PREFIX; 
    4343 
    4444 
    4545int has_tor_prefix(const struct in6_addr *addr) 
    4646{ 
    47    return memcmp(addr, &tor_prefix_, 6) == 0; 
     47   return memcmp(addr, &NDESC(prefix), 6) == 0; 
    4848} 
    4949 
     
    5151void set_tor_prefix(struct in6_addr *addr) 
    5252{ 
    53    memcpy(addr, &tor_prefix_, 6); 
     53   memcpy(addr, &NDESC(prefix), 6); 
    5454} 
    5555 
Note: See TracChangeset for help on using the changeset viewer.