[Pkg-privacy-commits] [onioncat] 101/241: add route for macosx bugfix in ether_ntoa_r

Intrigeri intrigeri at moszumanska.debian.org
Wed Aug 26 16:16:41 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 66b7381e6f107b8d6d1dcf380f5ef13863df0855
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Tue Dec 16 15:04:18 2008 +0000

    add route for macosx
    bugfix in ether_ntoa_r
    
    
    git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@394 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 ChangeLog       |  3 +++
 src/ocat.h      |  3 +++
 src/ocateth.c   |  2 +-
 src/ocatlog.c   | 15 +++++++++++----
 src/ocatsetup.c | 26 ++++++++++++++++----------
 src/ocatsocks.c |  3 ++-
 src/ocattun.c   | 14 ++++++++++++++
 7 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 570223e..39d7a7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
 * version 
+ - bugfix in ether_ntoa_r()
+ - variable for uptime implemented
+ - routing is setup correctly on MACOSX with TUN dev
  - serious framesize bug with TAP device fixed
  - seems to run on Darwin yet ;)
  - consolidated header files
diff --git a/src/ocat.h b/src/ocat.h
index 0543722..1cbfd3e 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -182,6 +182,8 @@
 //! maximum number of IPv6 routes
 #define MAX_IPV6_ROUTE 1024
 */
+//! retry-delay if connection to TOR's SOCKS port fails
+#define TOR_SOCKS_CONN_TIMEOUT 30
 
 #define IPV4_KEY 0
 #define IPV6_KEY 1
@@ -230,6 +232,7 @@ struct OcatSetup
    //! hardcoded permanent peers
 #define ROOT_PEERS 1
    struct in6_addr root_peer[ROOT_PEERS];
+   time_t uptime;
 };
 
 #ifdef PACKET_QUEUE
diff --git a/src/ocateth.c b/src/ocateth.c
index c2bd7be..632fa4b 100644
--- a/src/ocateth.c
+++ b/src/ocateth.c
@@ -465,7 +465,7 @@ char *ether_ntoa_r(const struct ether_addr *addr, char *buf)
       return NULL;
 
    pthread_mutex_lock(&ether_ntoa_mutex_);
-   strlcpy(buf, 18, ether_ntoa(addr));
+   strlcpy(buf, ether_ntoa(addr), 18);
    pthread_mutex_unlock(&ether_ntoa_mutex_);
    return buf;
 }
diff --git a/src/ocatlog.c b/src/ocatlog.c
index 4a1178a..bf350f3 100644
--- a/src/ocatlog.c
+++ b/src/ocatlog.c
@@ -78,21 +78,28 @@ int open_connect_log(const char *dir)
  */
 void vlog_msgf(FILE *out, int lf, const char *fmt, va_list ap)
 {
+   struct timeval tv;
    struct tm *tm;
    time_t t;
-   char timestr[TIMESTRLEN] = "";
+   char timestr[TIMESTRLEN] = "", timez[TIMESTRLEN] = "";
    const OcatThread_t *th = get_thread();
    int level = LOG_PRI(lf);
 
    if (CNF(debug_level) < level)
       return;
 
-   t = time(NULL);
+   //t = time(NULL);
+   if (gettimeofday(&tv, NULL) == -1)
+      fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, strerror(errno)), exit(1);
+   t = tv.tv_sec;
    if ((tm = localtime(&t)))
-      strftime(timestr, TIMESTRLEN, "%a, %d %b %Y %H:%M:%S %z", tm);
+   {
+      (void) strftime(timestr, TIMESTRLEN, "%a, %d %b %Y %H:%M:%S", tm);
+      (void) strftime(timez, TIMESTRLEN, "%z", tm);
+   }
 
    (void) pthread_mutex_lock(&log_mutex_);
-   fprintf(out, "%s [%d:%-*s:%6s] ", timestr, th->id, THREAD_NAME_LEN - 1, th->name, flty_[level]);
+   fprintf(out, "%s.%03d %s [%d:%-*s:%6s] ", timestr, (int) (tv.tv_usec / 1000), timez, th->id, THREAD_NAME_LEN - 1, th->name, flty_[level]);
    vfprintf(out, fmt, ap);
    fprintf(out, "\n");
    (void) pthread_mutex_unlock(&log_mutex_);
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index f044da3..f8e6bfc 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -47,28 +47,30 @@ struct OcatSetup setup_ =
    {
       {{{0xfd, 0x87, 0xd8, 0x7e, 0xeb, 0x43,
            0xed, 0xb1, 0x8, 0xe4, 0x35, 0x88, 0xe5, 0x46, 0x35, 0xca}}} // initial permanent peer "5wyqrzbvrdsumnok"
-   }
+   },
+   0
 };
 
 
 void init_setup(void)
 {
    setup_.logf = stderr;
+   setup_.uptime = time(NULL);
 }
 
 
-#define _SB 100
+#define SBUF 100
 
 void print_setup_struct(FILE *f)
 {
-   char ip[_SB], nm[_SB], ip6[_SB], logf[_SB], hw[_SB], rp[ROOT_PEERS][_SB];
-   int i;
+   char ip[SBUF], nm[SBUF], ip6[SBUF], logf[SBUF], hw[SBUF], rp[ROOT_PEERS][SBUF];
+   int i, t;
 
-   inet_ntop(AF_INET, &setup_.ocat_addr4, ip, _SB);
-   inet_ntop(AF_INET, &setup_.ocat_addr4_mask, nm, _SB);
-   inet_ntop(AF_INET6, &setup_.ocat_addr, ip6, _SB);
+   inet_ntop(AF_INET, &setup_.ocat_addr4, ip, SBUF);
+   inet_ntop(AF_INET, &setup_.ocat_addr4_mask, nm, SBUF);
+   inet_ntop(AF_INET6, &setup_.ocat_addr, ip6, SBUF);
    for (i = 0; i < ROOT_PEERS; i++)
-      inet_ntop(AF_INET6, &setup_.root_peer[i], rp[i], _SB);
+      inet_ntop(AF_INET6, &setup_.root_peer[i], rp[i], SBUF);
 
    ether_ntoa_r((struct ether_addr*) setup_.ocat_hwaddr, hw);
 
@@ -77,6 +79,8 @@ void print_setup_struct(FILE *f)
    else
       snprintf(logf, sizeof(logf), "%p", setup_.logf);
 
+   t = time(NULL) - setup_.uptime;
+
    fprintf(f,
          "fhd_key[IPV4(%d)]  = 0x%04x\n"
          "fhd_key[IPV6(%d)]  = 0x%04x\n"
@@ -107,7 +111,8 @@ void print_setup_struct(FILE *f)
          "logfn             = \"%s\"\n"
          "logf              = %s\n"
          "daemon            = %d\n"
-         "root_peer[0]      = %s\n",
+         "root_peer[0]      = %s\n"
+         "uptime            = %d days, %d:%02d\n",
  
          IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]),
          setup_.fhd_key_len,
@@ -136,7 +141,8 @@ void print_setup_struct(FILE *f)
          setup_.logfn,
          logf,
          setup_.daemon,
-         rp[0]
+         rp[0],
+         t / (3600 * 24), t / 3600 % 24, t / 60 % 60
          );
 }
 
diff --git a/src/ocatsocks.c b/src/ocatsocks.c
index 823b499..d672baf 100644
--- a/src/ocatsocks.c
+++ b/src/ocatsocks.c
@@ -61,8 +61,9 @@ int socks_connect(const SocksQueue_t *sq)
    t = time(NULL);
    if (connect(fd, (struct sockaddr*) &in, sizeof(in)) == -1)
    {
-      log_msg(LOG_ERR, "connect() to TOR failed: \"%s\"", strerror(errno));
+      log_msg(LOG_ERR, "connect() to TOR's SOCKS port %d failed: \"%s\". Sleeping for %d seconds.", CNF(tor_socks_port), strerror(errno), TOR_SOCKS_CONN_TIMEOUT);
       oe_close(fd);
+      sleep(TOR_SOCKS_CONN_TIMEOUT);
       return E_SOCKS_CONN;
    }
 
diff --git a/src/ocattun.c b/src/ocattun.c
index 1cd440e..2ac9bac 100644
--- a/src/ocattun.c
+++ b/src/ocattun.c
@@ -98,6 +98,8 @@ int tun_alloc(char *dev, struct in6_addr addr)
 #ifdef __APPLE__
 
 // see http://svn.deepdarc.com/code/miredo-osx/trunk/tuntap/README
+// FIXME: this should be included by the right header file
+//        but I couldn't find it
 #define TUNSIFHEAD  _IOW('t', 96, int)
 
    int prm = 1;
@@ -112,6 +114,18 @@ int tun_alloc(char *dev, struct in6_addr addr)
       log_debug("setting IP on tun: \"%s\"", buf);
       if (system(buf) == -1)
          log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
+
+#ifdef __APPLE__
+
+      // 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);
+      log_msg(LOG_INFO, "setup routing: \"%s\"", buf);
+      if (system(buf) == -1)
+         log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
+ 
+#endif
+
    }
 
 #endif

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