[Pkg-privacy-commits] [onioncat] 197/241: Garlicat, 1st try

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:17:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to branch upstream-master
in repository onioncat.

commit d44640b037ec8d46eb6a9e9408a1f2700be946a1
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Fri Nov 13 12:11:06 2009 +0000

    Garlicat, 1st try
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/branches/garlicat@525 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 configure          | 22 ++++++-------
 src/Makefile.am    |  4 +--
 src/Makefile.in    |  8 +++--
 src/ocat.c         | 22 ++++++++++---
 src/ocat.h         | 22 +++++++------
 src/ocat_netdesc.c | 45 ++++++++++++++++++++++++++
 src/ocat_netdesc.h | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/ocatctrl.c     |  3 +-
 src/ocatsetup.c    | 25 ++++++++++++---
 src/ocatsocks.c    |  7 ++--
 src/ocattun.c      | 11 ++++---
 src/ocatv6conv.c   |  6 ++--
 12 files changed, 223 insertions(+), 46 deletions(-)

diff --git a/configure b/configure
index 5f4bd8a..0cd06fb 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.62 for onioncat 0.2.0.r514.
+# Generated by GNU Autoconf 2.62 for onioncat 0.2.0.r525.
 #
 # Report bugs to <rahra at cypherpunk.at>.
 #
@@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='onioncat'
 PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.2.0.r514'
-PACKAGE_STRING='onioncat 0.2.0.r514'
+PACKAGE_VERSION='0.2.0.r525'
+PACKAGE_STRING='onioncat 0.2.0.r525'
 PACKAGE_BUGREPORT='rahra at cypherpunk.at'
 
 ac_subst_vars='SHELL
@@ -1259,7 +1259,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures onioncat 0.2.0.r514 to adapt to many kinds of systems.
+\`configure' configures onioncat 0.2.0.r525 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1329,7 +1329,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of onioncat 0.2.0.r514:";;
+     short | recursive ) echo "Configuration of onioncat 0.2.0.r525:";;
    esac
   cat <<\_ACEOF
 
@@ -1421,7 +1421,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-onioncat configure 0.2.0.r514
+onioncat configure 0.2.0.r525
 generated by GNU Autoconf 2.62
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1435,7 +1435,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by onioncat $as_me 0.2.0.r514, which was
+It was created by onioncat $as_me 0.2.0.r525, which was
 generated by GNU Autoconf 2.62.  Invocation command line was
 
   $ $0 $@
@@ -2084,7 +2084,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='onioncat'
- VERSION='0.2.0.r514'
+ VERSION='0.2.0.r525'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2235,7 +2235,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 cat >>confdefs.h <<\_ACEOF
-#define SVN_REVISION "514"
+#define SVN_REVISION "525"
 _ACEOF
 
 
@@ -5208,7 +5208,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by onioncat $as_me 0.2.0.r514, which was
+This file was extended by onioncat $as_me 0.2.0.r525, which was
 generated by GNU Autoconf 2.62.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5261,7 +5261,7 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-onioncat config.status 0.2.0.r514
+onioncat config.status 0.2.0.r525
 configured by $0, generated by GNU Autoconf 2.62,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a0f1d1..653800c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
 bin_PROGRAMS = ocat
-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
-include_HEADERS = ocat.h strlcpy.c strlcat.c
+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 ocat_netdesc.c
+include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c
 
diff --git a/src/Makefile.in b/src/Makefile.in
index e8e4b0b..20f46fd 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -57,7 +57,8 @@ am_ocat_OBJECTS = ocat.$(OBJEXT) ocatlog.$(OBJEXT) ocatroute.$(OBJEXT) \
 	ocatcompat.$(OBJEXT) ocatpeer.$(OBJEXT) ocatsetup.$(OBJEXT) \
 	ocatipv4route.$(OBJEXT) ocateth.$(OBJEXT) ocatsocks.$(OBJEXT) \
 	ocatlibe.$(OBJEXT) ocatctrl.$(OBJEXT) ocatipv6route.$(OBJEXT) \
-	ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT)
+	ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT) \
+	ocat_netdesc.$(OBJEXT)
 ocat_OBJECTS = $(am_ocat_OBJECTS)
 ocat_LDADD = $(LDADD)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -167,8 +168,8 @@ sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
-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
-include_HEADERS = ocat.h strlcpy.c strlcat.c
+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 ocat_netdesc.c
+include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c
 all: all-am
 
 .SUFFIXES:
@@ -236,6 +237,7 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocat.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocat_netdesc.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocat_wintuntap.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocatcompat.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocatctrl.Po at am__quote@
diff --git a/src/ocat.c b/src/ocat.c
index 288c306..cafffe3 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -17,6 +17,7 @@
 
 
 #include "ocat.h"
+#include "ocat_netdesc.h"
 
 
 void usage(const char *s)
@@ -32,6 +33,7 @@ void usage(const char *s)
          "   -d <n>                set debug level to n, default = %d\n"
          "   -f <config_file>      read config from config_file\n"
          "   -i                    convert onion hostname to IPv6 and exit\n"
+         "   -I                    GarliCat mode, use I2P instead of Tor\n"
          "   -l [<ip>:]<port>      set ocat listen address and port, default = 127.0.0.1:%d\n"
          "   -L <log_file>         log output to <log_file> (default = stderr)\n"
          "   -o <ipv6_addr>        convert IPv6 address to onion url and exit\n"
@@ -50,7 +52,7 @@ void usage(const char *s)
          // option defaults start here
          OCAT_DIR, OCAT_CONNECT_LOG, CNF(create_clog), 
          CNF(daemon), CNF(daemon) ^ 1,
-         CNF(debug_level), OCAT_LISTEN_PORT,
+         CNF(debug_level), NDESC(listen_port),
          CNF(pid_file),
          CNF(ocat_dest_port), ntohs(CNF(socks_dst)->sin_port), 
 #ifndef WITHOUT_TUN
@@ -236,14 +238,14 @@ int main(int argc, char *argv[])
    struct passwd *pwd, pwdm;
    int urlconv = 0;
 
-   snprintf(def, 100, "127.0.0.1:%d", OCAT_LISTEN_PORT);
+   snprintf(def, 100, "127.0.0.1:%d", NDESC(listen_port));
 
    init_setup();
 
    if (argc < 2)
       usage(argv[0]), exit(1);
 
-   while ((c = getopt(argc, argv, "abBCd:f:hrRiopl:t:T:s:u:4L:P:")) != -1)
+   while ((c = getopt(argc, argv, "abBCd:f:hrRiIopl:t:T:s:u:4L:P:")) != -1)
       switch (c)
       {
          case 'a':
@@ -275,6 +277,10 @@ int main(int argc, char *argv[])
             urlconv = 1;
             break;
 
+         case 'I':
+            CNF(net_type) = NTYPE_I2P;
+            break;
+
          case 'l':
             add_listener(optarg, def);
             break;
@@ -340,6 +346,13 @@ int main(int argc, char *argv[])
             exit(1);
       }
 
+   // detect network type by command file name
+   // FIXME: this should be not hardcoded in that way
+   if (!strcmp(argv[0], "gcat") || !strcmp(argv[0], "garlicat"))
+      CNF(net_type) = NTYPE_I2P;
+
+   post_init_setup();
+
    if (!CNF(rand_addr) && !argv[optind])
       usage(argv[0]), exit(1);
 
@@ -372,7 +385,7 @@ int main(int argc, char *argv[])
 
    // copy onion-URL from command line
    if (!CNF(rand_addr))
-      strncpy(CNF(onion_url), argv[optind], ONION_NAME_SIZE);
+      strncpy(CNF(onion_url), argv[optind], NDESC(name_size));
    // ...or generate a random one
    else
       rand_onion(CNF(onion_url));
@@ -400,6 +413,7 @@ int main(int argc, char *argv[])
    }
 
    log_msg(LOG_INFO, "%s", CNF(version));
+   log_msg(LOG_INFO, "OC is running in %s mode", CNF(net_type) == NTYPE_I2P ? "GarliCat (I2P)" : "OnionCat (Tor)");
 
 #if 0
    if (CNF(config_file))
diff --git a/src/ocat.h b/src/ocat.h
index 7df4d61..2389631 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -101,7 +101,7 @@
 #endif
 
 #define IP6HLEN sizeof(struct ip6_hdr)
-//! TOR prefix: FD87:D87E:EB43::/48
+/*//! TOR prefix: FD87:D87E:EB43::/48
 #define TOR_PREFIX {{{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0,0,0,0,0,0,0,0,0,0}}}
 #define TOR_PREFIX_LEN 48
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -110,23 +110,23 @@
 #else
 #define TOR_PREFIX4 {0x0a000000}
 #define TOR_PREFIX4_MASK 0xff000000
-#endif
+#endif*/
 //! Length of an .onion-URL (without ".onion" and '\0')
 #define ONION_URL_LEN 16
-//! Total length of .onion-URL
+/*//! Total length of .onion-URL
 #define ONION_NAME_SIZE (ONION_URL_LEN + 7)
 //! Total length of .onion-URL (equal to ONION_NAME_SIZE)
-#define ONION_NAME_LEN ONION_NAME_SIZE
+#define ONION_NAME_LEN ONION_NAME_SIZE*/
 
 #define MAXPEERS 1024
-//! Local listening port for incoming connections from TOR.
+/*//! Local listening port for incoming connections from TOR.
 #define OCAT_LISTEN_PORT 8060
 //! Local control port for querying status information.
 #define OCAT_CTRL_PORT 8066
 //! Virtual destination port for hidden services
 #define OCAT_DEST_PORT 8060
 //! SOCKS port of TOR proxy
-#define TOR_SOCKS_PORT 9050
+#define TOR_SOCKS_PORT 9050*/
 #ifdef __OpenBSD__
 #define OCAT_UNAME "_tor"
 #elif __FreeBSD__
@@ -234,7 +234,10 @@
 
 #define VERSION_STRING_LEN 256
 
-typedef enum PeerType {PT_TOR, PT_I2P} PeerType_t;
+
+#define NTYPE_TOR 0
+#define NTYPE_I2P 1
+
 
 struct OcatSetup
 {
@@ -255,7 +258,7 @@ struct OcatSetup
    int debug_level;
    //! user name to change uid to
    char *usrname;
-   char onion_url[ONION_NAME_SIZE];
+   char onion_url[SIZE_256];
    struct in6_addr ocat_addr;
    //! flag to create connection log
    int create_clog;
@@ -307,6 +310,7 @@ struct OcatSetup
    int ctrl_listen_cnt;
    //! communication pipe for socks "selected" connector
    int socksfd[2];
+   int net_type;
 };
 
 #ifdef PACKET_QUEUE
@@ -358,7 +362,6 @@ typedef struct OcatPeer
    time_t last_io;         //!< timestamp when last I/O packet measurement started
    unsigned inm;
    unsigned outm;
-   PeerType_t type;
 } OcatPeer_t;
 
 typedef struct OcatThread
@@ -565,6 +568,7 @@ void delete_peer(OcatPeer_t *);
 extern struct OcatSetup setup_;
 void print_setup_struct(FILE *);
 void init_setup(void);
+void post_init_setup(void);
 void lock_setup(void);
 void unlock_setup(void);
 
diff --git a/src/ocat_netdesc.c b/src/ocat_netdesc.c
new file mode 100644
index 0000000..4da56d0
--- /dev/null
+++ b/src/ocat_netdesc.c
@@ -0,0 +1,45 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "ocat_netdesc.h"
+
+
+const struct NetDesc netdesc_[2] =
+{
+   {
+      TOR_PREFIX, TOR_PREFIX_LEN,
+      TOR_PREFIX4, TOR_PREFIX4_MASK,
+      TOR_ONION_NAME_SIZE,
+      TOR_DOMAIN,
+      TOR_OCAT_LISTEN_PORT,
+      TOR_OCAT_CTRL_PORT,
+      TOR_OCAT_DEST_PORT,
+      TOR_SOCKS_PORT,
+   },
+   {
+      I2P_PREFIX, I2P_PREFIX_LEN,
+      I2P_PREFIX4, I2P_PREFIX4_MASK,
+      I2P_ONION_NAME_SIZE,
+      I2P_DOMAIN,
+      I2P_OCAT_LISTEN_PORT,
+      I2P_OCAT_CTRL_PORT,
+      I2P_OCAT_DEST_PORT,
+      I2P_SOCKS_PORT,
+   },
+};
+
diff --git a/src/ocat_netdesc.h b/src/ocat_netdesc.h
new file mode 100644
index 0000000..dc5ca4e
--- /dev/null
+++ b/src/ocat_netdesc.h
@@ -0,0 +1,94 @@
+/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OCAT_NETDESC_H
+#define OCAT_NETDESC_H
+
+
+#include "ocat.h"
+
+
+//! This structure contains information that's specifc for an anonymization
+//  network.
+struct NetDesc
+{
+   struct in6_addr prefix;
+   int prefix_len;
+   struct in_addr prefix4;
+   int addr4_mask;
+   int name_size;
+   char *domain;
+   short listen_port;
+   short ctrl_port;
+   short vdest_port;
+   short socks_port;
+};
+
+extern const struct NetDesc netdesc_[2];
+
+#define NDESC(x) (netdesc_[CNF(net_type)].x)
+
+
+// ----- these are #defines for Tor -----
+//
+//! TOR prefix: FD87:D87E:EB43::/48
+#define TOR_PREFIX {{{0xfd,0x87,0xd8,0x7e,0xeb,0x43,0,0,0,0,0,0,0,0,0,0}}}
+#define TOR_PREFIX_LEN 48
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define TOR_PREFIX4 {0x0000000a}
+#define TOR_PREFIX4_MASK 0x000000ff
+#else
+#define TOR_PREFIX4 {0x0a000000}
+#define TOR_PREFIX4_MASK 0xff000000
+#endif
+//! internal domain
+#define TOR_DOMAIN ".onion"
+//! Total length of .onion-URL
+#define TOR_ONION_NAME_SIZE (ONION_URL_LEN + 7)
+//! Local listening port for incoming connections from TOR.
+#define TOR_OCAT_LISTEN_PORT 8060
+//! Local control port for querying status information.
+#define TOR_OCAT_CTRL_PORT 8066
+//! Virtual destination port for hidden services
+#define TOR_OCAT_DEST_PORT 8060
+//! SOCKS port of TOR proxy
+#define TOR_SOCKS_PORT 9050
+
+
+// ----- these are #defines for I2P -----
+//
+//! TOR prefix: FD60:DB4D:DDB5::/48
+#define I2P_PREFIX {{{0xfd,0x60,0xdb,0x4d,0xdd,0xb5,0,0,0,0,0,0,0,0,0,0}}}
+#define I2P_PREFIX_LEN TOR_PREFIX_LEN
+#define I2P_PREFIX4 TOR_PREFIX4
+#define I2P_PREFIX4_MASK TOR_PREFIX4_MASK
+//! internal domain
+#define I2P_DOMAIN ".oc.b32.i2p"
+//! Total length of .onion-URL
+#define I2P_ONION_NAME_SIZE (ONION_URL_LEN + 12)
+//! Local listening port for incoming connections from TOR.
+#define I2P_OCAT_LISTEN_PORT 8061
+//! Local control port for querying status information.
+#define I2P_OCAT_CTRL_PORT 8067
+//! Virtual destination port for hidden services
+#define I2P_OCAT_DEST_PORT 8060
+//! SOCKS port of TOR proxy
+#define I2P_SOCKS_PORT 9051
+
+
+#endif
+
diff --git a/src/ocatctrl.c b/src/ocatctrl.c
index 904c640..5c9e82b 100644
--- a/src/ocatctrl.c
+++ b/src/ocatctrl.c
@@ -24,6 +24,7 @@
 
 
 #include "ocat.h"
+#include "ocat_netdesc.h"
 
 
 /*! ctrl_handler handles connections to local control port.
@@ -36,7 +37,7 @@ void *ctrl_handler(void *p)
 {
    int fd, c;
    FILE *ff, *fo;
-   char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[ONION_NAME_SIZE], timestr[32], *s, *tokbuf;
+   char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf;
    int rlen, cfd;
    struct tm *tm;
    OcatPeer_t *peer;
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index 0278a0c..768cadb 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -24,6 +24,7 @@
 
 
 #include "ocat.h"
+#include "ocat_netdesc.h"
 
 
 static struct sockaddr_in6 socks_dst6_;
@@ -45,14 +46,16 @@ struct OcatSetup setup_ =
    sizeof(uint32_t),
    //TOR_SOCKS_PORT, 
    //OCAT_LISTEN_PORT, 
-   OCAT_DEST_PORT, OCAT_CTRL_PORT, 
+   0, 0,
    //! default tunfd is stdin/stdout
    {0, 1},
    //! default debug level
    LOG_DEBUG,
    OCAT_UNAME, {0}, {{{0}}}, 0, 0, 1, OCAT_DIR, TUN_DEV,
    {'\0'},                                // tunname
-   0, TOR_PREFIX4, TOR_PREFIX4_MASK,
+   0, 
+   //ADDR4_PREFIX, ADDR4_MASK
+   {0}, 0,
    NULL, 1,
 #ifdef __CYGWIN__
    1,
@@ -105,7 +108,9 @@ struct OcatSetup setup_ =
 #endif
    ,
    // socksfd
-   {-1, -1}
+   {-1, -1},
+   // net_type
+   NTYPE_TOR
 };
 
 
@@ -136,6 +141,15 @@ void init_setup(void)
 #else
    snprintf(setup_.version, VERSION_STRING_LEN, "%s (c) %s", PACKAGE_STRING, OCAT_AUTHOR);
 #endif
+}
+
+
+void post_init_setup(void)
+{
+   setup_.ocat_addr4 = NDESC(prefix4);
+   setup_.ocat_addr4_mask = NDESC(addr4_mask);
+   setup_.ocat_dest_port = NDESC(vdest_port);
+   setup_.ocat_ctrl_port = NDESC(ctrl_port);
 
    ctrl_listen_.sin_family = AF_INET;
    ctrl_listen_.sin_port = htons(setup_.ocat_ctrl_port);
@@ -150,7 +164,6 @@ void init_setup(void)
 #ifdef HAVE_SIN_LEN
    ctrl_listen6_.sin6_len = sizeof(ctrl_listen6_);
 #endif
-
 }
 
 
@@ -211,6 +224,7 @@ void print_setup_struct(FILE *f)
          "version[%3d+1/%3d]     = \"%s\"\n"
          "sizeof_setup           = %d\n"
          "term_req               = %d\n"
+         "net_type               = %d (%s)\n"
          ,
          IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]),
          setup_.fhd_key_len,
@@ -243,7 +257,8 @@ void print_setup_struct(FILE *f)
          t / (3600 * 24), t / 3600 % 24, t / 60 % 60,
          (int) strlen(setup_.version), VERSION_STRING_LEN, setup_.version,
          setup_.sizeof_setup,
-         setup_.term_req
+         setup_.term_req,
+         setup_.net_type, setup_.net_type == NTYPE_TOR ? "NTYPE_TOR" : setup_.net_type == NTYPE_I2P ? "NTYPE_I2P" : "unknown"
          );
 
    for (i = 0; i < ROOT_PEERS; i++)
diff --git a/src/ocatsocks.c b/src/ocatsocks.c
index 027bfd5..8fbf22a 100644
--- a/src/ocatsocks.c
+++ b/src/ocatsocks.c
@@ -25,18 +25,19 @@
 /* SOCKS5 is defined in RFC1928 */
 
 #include "ocat.h"
+#include "ocat_netdesc.h"
 
 
 // SOCKS connector queue vars
 static SocksQueue_t *socks_queue_ = NULL;
 
-#define SOCKS_BUFLEN (sizeof(SocksHdr_t) + ONION_NAME_SIZE + strlen(CNF(usrname)) + 2)
+#define SOCKS_BUFLEN (sizeof(SocksHdr_t) + NDESC(name_size) + strlen(CNF(usrname)) + 2)
 
 
 int socks_send_request(const SocksQueue_t *sq)
 {
    int len, ret;
-   char buf[SOCKS_BUFLEN], onion[ONION_NAME_SIZE];
+   char buf[SOCKS_BUFLEN], onion[NDESC(name_size)];
    SocksHdr_t *shdr = (SocksHdr_t*) buf;
 
    ipv6tonion(&sq->addr, onion);
@@ -245,7 +246,7 @@ void print_socks_queue(FILE *f)
 void socks_output_queue(FILE *f)
 {
    int i;
-   char addrstr[INET6_ADDRSTRLEN], onstr[ONION_NAME_LEN], buf[SIZE_1K];
+   char addrstr[INET6_ADDRSTRLEN], onstr[NDESC(name_size)], buf[SIZE_1K];
    SocksQueue_t *squeue;
 
    for (squeue = socks_queue_, i = 0; squeue; squeue = squeue->next, i++)
diff --git a/src/ocattun.c b/src/ocattun.c
index 2bc9c04..6869fcd 100644
--- a/src/ocattun.c
+++ b/src/ocattun.c
@@ -26,6 +26,7 @@
 
 
 #include "ocat.h"
+#include "ocat_netdesc.h"
 
 
 char *tun_dev_ = TUN_DEV;
@@ -60,7 +61,7 @@ int tun_alloc(char *dev, int dev_s, struct in6_addr addr)
    if (system(buf) == -1)
       log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
 
-   snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, TOR_PREFIX_LEN, dev);
+   snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, NDESC(prefix_len), dev);
    log_debug("setting IP routing: \"%s\"", buf);
    if (system(buf) == -1)
       log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
@@ -91,7 +92,7 @@ int tun_alloc(char *dev, int dev_s, struct in6_addr addr)
    strlcpy(dev, ifr.ifr_name, IFNAMSIZ);
    if (!CNF(use_tap))
    {
-      snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, TOR_PREFIX_LEN);
+      snprintf(buf, sizeof(buf), "ifconfig %s add %s/%d up", dev, astr, NDESC(prefix_len));
       log_msg(LOG_INFO, "configuring tun IP: \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
@@ -168,9 +169,9 @@ int tun_alloc(char *dev, int dev_s, struct in6_addr addr)
    if (!CNF(use_tap))
    {
 #ifdef __OpenBSD__
-      snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s prefixlen %d up", dev, astr, TOR_PREFIX_LEN);
+      snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s prefixlen %d up", dev, astr, NDESC(prefix_len));
 #else
-      snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s/%d up", dev, astr, TOR_PREFIX_LEN);
+      snprintf(buf, sizeof(buf), "ifconfig %s inet6 %s/%d up", dev, astr, NDESC(prefix_len));
 #endif
       log_debug("setting IP on tun: \"%s\"", buf);
       if (system(buf) == -1)
@@ -180,7 +181,7 @@ int tun_alloc(char *dev, int dev_s, struct in6_addr addr)
 
       // MacOSX requires the route to be set up manually
       // FIXME: the prefix shouldn't be hardcoded here
-      snprintf(buf, sizeof(buf), "route add -inet6 -net fd87:d87e:eb43:: -prefixlen %d -gateway %s", TOR_PREFIX_LEN, astr);
+      snprintf(buf, sizeof(buf), "route add -inet6 -net fd87:d87e:eb43:: -prefixlen %d -gateway %s", NDESC(prefix_len), astr);
       log_msg(LOG_INFO, "setup routing: \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
diff --git a/src/ocatv6conv.c b/src/ocatv6conv.c
index d6960aa..b31dc24 100644
--- a/src/ocatv6conv.c
+++ b/src/ocatv6conv.c
@@ -26,6 +26,7 @@
 
 
 #include "ocat.h"
+#include "ocat_netdesc.h"
 
 static const char BASE32[] = "abcdefghijklmnopqrstuvwxyz234567";
 //! array contains inverse mapping of base32 starting with '2'.
@@ -39,18 +40,17 @@ static const char deBASE32_[] = {
    /*  P   Q   R   S   T   U   V   W   X   Y   Z
       50  51  52  53  54  55  56  57  58  59  5a */
       15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };  
-static const struct in6_addr tor_prefix_ = TOR_PREFIX;
 
 
 int has_tor_prefix(const struct in6_addr *addr)
 {
-   return memcmp(addr, &tor_prefix_, 6) == 0;
+   return memcmp(addr, &NDESC(prefix), 6) == 0;
 }
 
 
 void set_tor_prefix(struct in6_addr *addr)
 {
-   memcpy(addr, &tor_prefix_, 6);
+   memcpy(addr, &NDESC(prefix), 6);
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git



More information about the Pkg-privacy-commits mailing list