[Pkg-privacy-commits] [onioncat] 234/241: OC now is able to load hostnames from /etc/hosts for Tor-version as well. It is off by default for Tor and on for I2P (the latter was already the case before). Option -H toggle this feature. Controller offer the commands 'hosts' and 'hreload' for hosts debugging. Domains names are looked up in hosts file by domain setup_.domain which is '.onion' for Tor and '.b32.i2p' for I2P.

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:17:17 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 09eff5eec85be6dd8624c64e779f9fa9f5beae9c
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Tue Mar 18 12:46:45 2014 +0000

    OC now is able to load hostnames from /etc/hosts for Tor-version as well. It is off by default for Tor and on for I2P (the latter was already the case before). Option -H toggle this feature. Controller offer the commands 'hosts' and 'hreload' for hosts debugging. Domains names are looked up in hosts file by domain setup_.domain which is '.onion' for Tor and '.b32.i2p' for I2P.
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@563 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 configure          | 22 +++++++++++-----------
 src/ocat.c         |  6 +++---
 src/ocat.h         |  1 +
 src/ocat_netdesc.c |  2 ++
 src/ocat_netdesc.h |  3 ++-
 src/ocatctrl.c     | 11 +++++++++++
 src/ocathosts.c    | 24 ++++++++++++++++++++++++
 src/ocathosts.h    |  4 ++++
 src/ocatsetup.c    | 14 ++++++++++----
 src/ocatsocks.c    |  8 ++++----
 10 files changed, 72 insertions(+), 23 deletions(-)

diff --git a/configure b/configure
index c4a34e9..e66c45a 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.68 for onioncat 0.2.2.r559.
+# Generated by GNU Autoconf 2.68 for onioncat 0.2.2.r562.
 #
 # Report bugs to <rahra at cypherpunk.at>.
 #
@@ -559,8 +559,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='onioncat'
 PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.2.2.r559'
-PACKAGE_STRING='onioncat 0.2.2.r559'
+PACKAGE_VERSION='0.2.2.r562'
+PACKAGE_STRING='onioncat 0.2.2.r562'
 PACKAGE_BUGREPORT='rahra at cypherpunk.at'
 PACKAGE_URL=''
 
@@ -1221,7 +1221,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.2.r559 to adapt to many kinds of systems.
+\`configure' configures onioncat 0.2.2.r562 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1291,7 +1291,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of onioncat 0.2.2.r559:";;
+     short | recursive ) echo "Configuration of onioncat 0.2.2.r562:";;
    esac
   cat <<\_ACEOF
 
@@ -1384,7 +1384,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-onioncat configure 0.2.2.r559
+onioncat configure 0.2.2.r562
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1694,7 +1694,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.2.r559, which was
+It was created by onioncat $as_me 0.2.2.r562, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2509,7 +2509,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='onioncat'
- VERSION='0.2.2.r559'
+ VERSION='0.2.2.r562'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2553,7 +2553,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 
-$as_echo "#define SVN_REVISION \"559\"" >>confdefs.h
+$as_echo "#define SVN_REVISION \"562\"" >>confdefs.h
 
 
 
@@ -5086,7 +5086,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=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.2.r559, which was
+This file was extended by onioncat $as_me 0.2.2.r562, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5152,7 +5152,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-onioncat config.status 0.2.2.r559
+onioncat config.status 0.2.2.r562
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
diff --git a/src/ocat.c b/src/ocat.c
index 4fc6b9d..b6e5bed 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -29,7 +29,7 @@ void usage(const char *s)
          "   -b                    daemonize (default = %d)\n"
          "   -B                    do not daemonize (default = %d)\n"
          "   -h                    display usage message\n"
-         "   -H                    ignore /etc/hosts while in GarliCat mode\n"
+         "   -H                    toggle /etc/hosts lookup (default = %d)\n"
          "   -C                    disable local controller interface\n"
          "   -d <n>                set debug level to n, default = %d\n"
          "   -f <config_file>      read config from config_file (default = %s)\n"
@@ -53,7 +53,7 @@ void usage(const char *s)
          , CNF(version), s,
          // option defaults start here
          OCAT_DIR, NDESC(clog_file), CNF(create_clog), 
-         CNF(daemon), CNF(daemon) ^ 1,
+         CNF(daemon), CNF(daemon) ^ 1, CNF(hosts_lookup),
          CNF(debug_level), CNF(config_file), NDESC(listen_port),
          CNF(pid_file),
          CNF(ocat_dest_port), ntohs(CNF(socks_dst)->sin_port), 
@@ -372,7 +372,7 @@ int parse_opt(int argc, char *argv[])
             exit(1);
 
          case 'H':
-            CNF(hosts_lookup) = 0;
+            CNF(hosts_lookup) = !CNF(hosts_lookup);
             break;
 
          case 'l':
diff --git a/src/ocat.h b/src/ocat.h
index 46a47c7..8409b48 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -353,6 +353,7 @@ struct OcatSetup
       respect to security because both ends are verfied. */
    int unidirectional;
    int hosts_lookup;
+   const char *domain;     //!< domain name appended to network host name
    struct in6_addr oc_vdns;
 };
 
diff --git a/src/ocat_netdesc.c b/src/ocat_netdesc.c
index b3b6453..1d85c63 100644
--- a/src/ocat_netdesc.c
+++ b/src/ocat_netdesc.c
@@ -33,6 +33,7 @@ const struct NetDesc netdesc_[2] =
       TOR_OCAT_CONNECT_LOG,
       TOR_PID_FILE,
       "ocat.conf",
+      0
    },
    {
       I2P_PREFIX, I2P_PREFIX_LEN,
@@ -46,6 +47,7 @@ const struct NetDesc netdesc_[2] =
       I2P_OCAT_CONNECT_LOG,
       I2P_PID_FILE,
       "gcat.conf",
+      1
    },
 };
 
diff --git a/src/ocat_netdesc.h b/src/ocat_netdesc.h
index 59cea41..f2da4a1 100644
--- a/src/ocat_netdesc.h
+++ b/src/ocat_netdesc.h
@@ -39,6 +39,7 @@ struct NetDesc
    char *clog_file;
    char *pid_file;
    char *config_file;
+   int hosts_lookup;
 };
 
 extern const struct NetDesc netdesc_[2];
@@ -90,7 +91,7 @@ extern const struct NetDesc netdesc_[2];
 #define I2P_PREFIX4 TOR_PREFIX4
 #define I2P_PREFIX4_MASK TOR_PREFIX4_MASK
 //! internal domain
-#define I2P_DOMAIN ".oc.b32.i2p"
+#define I2P_DOMAIN ".b32.i2p"
 //! Total length of .onion-URL
 #define I2P_ONION_NAME_SIZE (ONION_URL_LEN + 12)
 //! Local listening port for incoming connections from TOR.
diff --git a/src/ocatctrl.c b/src/ocatctrl.c
index 8d31a7e..2c275b5 100644
--- a/src/ocatctrl.c
+++ b/src/ocatctrl.c
@@ -25,6 +25,7 @@
 
 #include "ocat.h"
 #include "ocat_netdesc.h"
+#include "ocathosts.h"
 
 
 /*! ctrl_handler handles connections to local control port.
@@ -269,6 +270,14 @@ void *ctrl_handler(void *p)
       {
          fprintf(ff, "%s\n", CNF(version));
       }
+      else if (!strcmp(bufp, "hosts"))
+      {
+         hosts_list(ff);
+      }
+      else if (!strcmp(bufp, "hreload"))
+      {
+         hosts_check();
+      }
       else if (!strcmp(bufp, "help") || !strcmp(bufp, "?"))
       {
          fprintf(fo,
@@ -276,6 +285,8 @@ void *ctrl_handler(void *p)
                "exit | quit .... exit from control interface\n"
                "terminate ...... terminate OnionCat\n"
                "close <n> ...... close file descriptor <n> of a peer\n"
+               "hosts .......... list hosts database\n"
+               "hreload ........ reload hosts database\n"
                "status ......... list peer status\n"
                "threads ........ show active threads\n"
                "route .......... show routing table\n"
diff --git a/src/ocathosts.c b/src/ocathosts.c
index fc94447..0bdf0a4 100644
--- a/src/ocathosts.c
+++ b/src/ocathosts.c
@@ -239,6 +239,30 @@ int hosts_get_name(const struct in6_addr *addr, char *buf, int s)
 }
 
 
+/*! Output list of hosts to file.
+ *  @return Returns always 0.
+ **/
+int hosts_list(FILE *f)
+{
+   char in6[INET6_ADDRSTRLEN];
+   int i;
+   struct hosts_ent *h;
+
+   pthread_mutex_lock(&hosts_mutex_);
+   for (i = hosts_.hosts_ent_cnt - 1, h = hosts_.hosts_ent; i >= 0; i--, h++)
+   {
+      if (inet_ntop(AF_INET6, &h->addr, in6, sizeof(in6)) == NULL)
+      {
+         log_msg(LOG_ERR, "inet_ntop() failed: %s", strerror(errno));
+         continue;
+      }
+      fprintf(f, "%s %s\n", in6, h->name);
+   }
+   pthread_mutex_unlock(&hosts_mutex_);
+   return 0;
+}
+
+
 void hosts_init(const char *dom)
 {
    hosts_.hdom = dom;
diff --git a/src/ocathosts.h b/src/ocathosts.h
index 20e6323..cc645af 100644
--- a/src/ocathosts.h
+++ b/src/ocathosts.h
@@ -18,6 +18,9 @@
 #ifndef OCATHOSTS_H
 #define OCATHOSTS_H
 
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
@@ -52,6 +55,7 @@ struct hosts_info
 int hosts_check(void);
 int hosts_get_name(const struct in6_addr*, char*, int);
 void hosts_init(const char*);
+int hosts_list(FILE *);
 
 #endif
 
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index 9a3d53d..0051d5d 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -125,7 +125,9 @@ struct OcatSetup setup_ =
    // unidirectional
    1,
    // hosts_lookup
-   1
+   0,
+   // domain
+   ""
 };
 
 
@@ -155,8 +157,6 @@ void init_setup(void)
    memset(&ctrl_listen_, 0, sizeof(ctrl_listen_));
    memset(&ctrl_listen6_, 0, sizeof(ctrl_listen6_));
 
-   hosts_init(".b32.i2p");
-
 #ifdef __linux__
    CNF(fhd_key[IPV6_KEY]) = htonl(ETHERTYPE_IPV6);
    CNF(fhd_key[IPV4_KEY]) = htonl(ETHERTYPE_IP);
@@ -176,6 +176,9 @@ void post_init_setup(void)
    setup_.ocat_addr4_mask = NDESC(addr4_mask);
    setup_.ocat_dest_port = NDESC(vdest_port);
    setup_.ocat_ctrl_port = NDESC(ctrl_port);
+   setup_.hosts_lookup = NDESC(hosts_lookup);
+   setup_.domain = NDESC(domain);
+   hosts_init(NDESC(domain));
 
    l = strlen(SYSCONFDIR) + strlen(NDESC(config_file)) + 2;
    if ((setup_.config_file = malloc(l)) != NULL)
@@ -276,6 +279,8 @@ void print_setup_struct(FILE *f)
          "ctrl_listen_cnt        = %d\n"
          "unidirectional         = %d\n"
          "hosts_lookup           = %d\n"
+         "domain                 = \"%s\"\n"
+         "----------------------\n"
          ,
          IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]),
          setup_.fhd_key_len,
@@ -315,7 +320,8 @@ void print_setup_struct(FILE *f)
          setup_.clear_stats,
          setup_.ctrl_listen_cnt,
          setup_.unidirectional,
-         setup_.hosts_lookup
+         setup_.hosts_lookup,
+         setup_.domain
          );
 
 #ifdef CONNECT_ROOT_PEERS
diff --git a/src/ocatsocks.c b/src/ocatsocks.c
index f9c69fd..fc1be93 100644
--- a/src/ocatsocks.c
+++ b/src/ocatsocks.c
@@ -42,10 +42,10 @@ int socks_send_request(const SocksQueue_t *sq)
    char buf[SOCKS_BUFLEN], onion[NI_MAXHOST];
    SocksHdr_t *shdr = (SocksHdr_t*) buf;
 
-   // Do a hostname lookup if network type is I2P.
+   // Do a hostname lookup if option set.
    // This is done in order to be able to retrieve a 256 bit base32 
    // host from e.g. /etc/hosts.
-   if ((CNF(net_type) == NTYPE_I2P) && CNF(hosts_lookup))
+   if (CNF(hosts_lookup))
    {
       hosts_check();
       ret = hosts_get_name(&sq->addr, onion, sizeof(onion));
@@ -56,7 +56,7 @@ int socks_send_request(const SocksQueue_t *sq)
    if (ret == -1)
    {
       ipv6tonion(&sq->addr, onion);
-      strlcat(onion, NDESC(domain), sizeof(onion));
+      strlcat(onion, CNF(domain), sizeof(onion));
    }
 
    log_debug("SOCKS_BUFLEN = %d, NI_MAXHOST = %d", SOCKS_BUFLEN, NI_MAXHOST);
@@ -288,7 +288,7 @@ void socks_output_queue(FILE *f)
             i, 
             addrstr, 
             ipv6tonion(&squeue->addr, onstr),
-            NDESC(domain),
+            CNF(domain),
             squeue->state,
             squeue->perm ? "PERMANENT" : "TEMPORARY",
             squeue->perm,

-- 
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