[Pkg-privacy-commits] [onioncat] 36/340: increased debug code for defrag bug

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:22 UTC 2015


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

infinity0 pushed a commit to branch debian
in repository onioncat.

commit 95e22339b3deb9a60280fdb51f1362e2d24f704a
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date:   Sat Mar 22 12:49:38 2008 +0000

    increased debug code for defrag bug
    
    git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@177 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
 ocatlog.c   |  2 +-
 ocatroute.c | 57 +++++++++++++++++++++++++++++++--------------------------
 2 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/ocatlog.c b/ocatlog.c
index e0d0ba1..3a1ab02 100644
--- a/ocatlog.c
+++ b/ocatlog.c
@@ -36,7 +36,7 @@ void log_msg(int lf, const char *fmt, ...)
       strftime(timestr, 32, "%c", tm);
 
    pthread_mutex_lock(&log_mutex_);
-   fprintf(out, "%s [%d:%-*s] %6s ", timestr, th->id, THREAD_NAME_LEN - 1, th->name, flty_[lf]);
+   fprintf(out, "%s [%d:%-*s:%6s] ", timestr, th->id, THREAD_NAME_LEN - 1, th->name, flty_[lf]);
 
    va_start(ap, fmt);
    vfprintf(out, fmt, ap);
diff --git a/ocatroute.c b/ocatroute.c
index 0c17ce6..4aae2af 100644
--- a/ocatroute.c
+++ b/ocatroute.c
@@ -142,7 +142,7 @@ void rewrite_framehdr(char *buf, int len)
    pthread_mutex_lock(&peer_mutex_);
    if ((peer = search_peer(addr)))
    {
-      log_msg(L_DEBUG, "[forwarding_packet]");
+      log_msg(L_DEBUG, "forwarding %d bytes to TCP fd %d", buflen, peer->tcpfd);
       if (write(peer->tcpfd, buf, buflen) != buflen)
          log_msg(L_ERROR, "could not write %d bytes to peer %d", buflen, peer->tcpfd);
       peer->time = time(NULL);
@@ -158,10 +158,10 @@ void queue_packet(const struct in6_addr *addr, const char *buf, int buflen)
 {
    PacketQueue_t *queue;
 
-   log_msg(L_DEBUG, "[queue_packet] copying packet to heap for queue");
+   log_msg(L_DEBUG, "copying packet to heap for queue");
    if (!(queue = malloc(sizeof(PacketQueue_t) + buflen)))
    {
-      log_msg(L_ERROR, "[queue_packet] %s for packet to queue", strerror(errno));
+      log_msg(L_ERROR, "%s for packet to queue", strerror(errno));
       return;
    }
 
@@ -171,11 +171,11 @@ void queue_packet(const struct in6_addr *addr, const char *buf, int buflen)
    memcpy(queue->data, buf, buflen);
    queue->time = time(NULL);
 
-   log_msg(L_DEBUG, "[queue_packet] queuing packet");
+   log_msg(L_DEBUG, "queuing packet");
    pthread_mutex_lock(&queue_mutex_);
    queue->next = queue_;
    queue_ = queue;
-   log_msg(L_DEBUG, "[queue_packet] waking up dequeuer");
+   log_msg(L_DEBUG, "waking up dequeuer");
    pthread_cond_signal(&queue_cond_);
    pthread_mutex_unlock(&queue_mutex_);
 }
@@ -196,19 +196,19 @@ void *packet_dequeuer(void *p)
       {
          clock_gettime(CLOCK_REALTIME, &ts);
          ts.tv_sec += DEQUEUER_WAKEUP;
-         log_msg(L_DEBUG, "[packet_dequeuer] timed conditional wait...");
+         log_msg(L_DEBUG, "timed conditional wait...");
          rc = pthread_cond_timedwait(&queue_cond_, &queue_mutex_, &ts);
       }
       else
       {
-         log_msg(L_DEBUG, "[packet_dequeuer] conditional wait...");
+         log_msg(L_DEBUG, "conditional wait...");
          rc = pthread_cond_wait(&queue_cond_, &queue_mutex_);
       }
 
       if (rc)
-         log_msg(L_FATAL, "[packet_dequeuer] woke up: \"%s\"", strerror(rc));
+         log_msg(L_FATAL, "woke up: \"%s\"", strerror(rc));
 
-      log_msg(L_DEBUG, "[packet_dequeuer] starting dequeuing");
+      log_msg(L_DEBUG, "starting dequeuing");
       for (queue = &queue_; *queue; /*queue = &(*queue)->next*/)
       {
          peer = forward_packet(&(*queue)->addr, (*queue)->data, (*queue)->psize);
@@ -220,7 +220,7 @@ void *packet_dequeuer(void *p)
             fqueue = *queue;
             *queue = (*queue)->next;
             free(fqueue);
-            log_msg(L_DEBUG, "[packet_dequeuer] packet dequeued, delay = %d", delay);
+            log_msg(L_DEBUG, "packet dequeued, delay = %d", delay);
             continue;
          }
          queue = &(*queue)->next;
@@ -279,7 +279,7 @@ int validate_frame(const struct ip6_hdr *ihd, int len)
 
 void cleanup_socket(int fd, OcatPeer_t *peer)
 {
-   log_msg(L_NOTICE, "[cleanup_socket] fd %d reached EOF, closing.", fd);
+   log_msg(L_NOTICE, "fd %d reached EOF, closing.", fd);
    close(fd);
    pthread_mutex_lock(&peer_mutex_);
    delete_peer(peer);
@@ -298,7 +298,7 @@ void *socket_receiver(void *p)
    OcatPeer_t *peer;
 
    if (pipe(lpfd_) < 0)
-      log_msg(L_FATAL, "[init_socket_receiver] could not create pipe for socket_receiver: \"%s\"", strerror(errno)), exit(1);
+      log_msg(L_FATAL, "could not create pipe for socket_receiver: \"%s\"", strerror(errno)), exit(1);
 
    //*((uint32_t*) buf) = fhd_key_;
 
@@ -323,10 +323,10 @@ void *socket_receiver(void *p)
       }
       pthread_mutex_unlock(&peer_mutex_);
 
-      log_msg(L_DEBUG, "[socket_receiver] is selecting...");
+      log_msg(L_DEBUG, "selecting...");
       if (select(maxfd + 1, &rset, NULL, NULL, NULL) == -1)
       {
-         log_msg(L_FATAL, "[socket_receiver] select encountered error: \"%s\", restarting", strerror(errno));
+         log_msg(L_FATAL, "select encountered error: \"%s\", restarting", strerror(errno));
          continue;
       }
 
@@ -390,7 +390,10 @@ void *socket_receiver(void *p)
 
                len = plen + IP6HLEN;
                if (peer->fraglen < len)
+               {
+                  log_msg(L_DEBUG, "keeping %d bytes frag", peer->fraglen);
                   break;
+               }
 
                pthread_mutex_lock(&peer_mutex_);
                // set IP address if it is not set yet and frame is valid
@@ -416,6 +419,8 @@ void *socket_receiver(void *p)
                   log_msg(L_DEBUG, "moving fragment. fragsize %d", peer->fraglen);
                   memmove(peer->fragbuf, peer->fragbuf + len, FRAME_SIZE - 4 - len);
                }
+               else
+                  log_msg(L_DEBUG, "fragbuf empty");
             }
          }
       }
@@ -435,7 +440,7 @@ void set_nonblock(int fd)
    log_msg(L_DEBUG, "O_NONBLOCK currently is %x", flags & O_NONBLOCK);
 
    if ((fcntl(fd, F_SETFL, flags | O_NONBLOCK)) == -1)
-      log_msg(L_ERROR, "[set_nonblock] could not set O_NONBLOCK for %d: \"%s\"", fd, strerror(errno));
+      log_msg(L_ERROR, "could not set O_NONBLOCK for %d: \"%s\"", fd, strerror(errno));
 }
 
 
@@ -443,7 +448,7 @@ OcatPeer_t *insert_peer(int fd, const struct in6_addr *addr)
 {
    OcatPeer_t *peer;
 
-   log_msg(L_DEBUG, "[inserting_peer] %d", fd);
+   log_msg(L_DEBUG, "inserting peer fd %d", fd);
 
    set_nonblock(fd);
 
@@ -467,7 +472,7 @@ OcatPeer_t *insert_peer(int fd, const struct in6_addr *addr)
    pthread_mutex_unlock(&peer_mutex_);
 
    // wake up socket_receiver
-   log_msg(L_DEBUG, "[inser_peer] waking up socket_receiver");
+   log_msg(L_DEBUG, "waking up socket_receiver");
    if (write(lpfd_[1], &fd, 1) != 1)
       log_msg(L_FATAL, "couldn't write to socket_receiver pipe: \"%s\"", strerror(errno));
 
@@ -534,7 +539,7 @@ int socks_connect(const struct in6_addr *addr)
    ipv6tonion(addr, onion);
    strcat(onion, ".onion");
 
-   log_msg(L_NOTICE, "[socks_connect] trying to connecto to \"%s\" [%s]", onion, inet_ntop(AF_INET6, addr, buf, FRAME_SIZE));
+   log_msg(L_NOTICE, "trying to connecto to \"%s\" [%s]", onion, inet_ntop(AF_INET6, addr, buf, FRAME_SIZE));
 
    if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
       return E_SOCKS_SOCK;
@@ -542,40 +547,40 @@ int socks_connect(const struct in6_addr *addr)
    t = time(NULL);
    if (connect(fd, (struct sockaddr*) &in, sizeof(in)) < 0)
    {
-      log_msg(L_ERROR, "[socks_connect] connect() failed");
+      log_msg(L_ERROR, "connect() failed");
       close(fd);
       return E_SOCKS_CONN;
    }
    t = time(NULL) - t;
 
-   log_msg(L_DEBUG, "[socks_connect] connect()");
+   log_msg(L_DEBUG, "connect()");
 
    shdr->ver = 4;
    shdr->cmd = 1;
    shdr->port = htons(ocat_dest_port_);
-   shdr->addr.s_addr = 0x01000000;
+   shdr->addr.s_addr = htonl(0x00000001);
    strcpy(buf + sizeof(SocksHdr_t), "tor6");
    strcpy(buf + sizeof(SocksHdr_t) + 5, onion);
 
    if (write(fd, shdr, sizeof(SocksHdr_t) + strlen(onion) + 6) != sizeof(SocksHdr_t) + strlen(onion) + 6)
       log_msg(L_ERROR, "couldn't write %d bytes to SOCKS connection %d", sizeof(SocksHdr_t) + strlen(onion) + 6, fd);
-   log_msg(L_DEBUG, "[socks_connect] connect request sent");
+   log_msg(L_DEBUG, "connect request sent");
 
    if (read(fd, shdr, sizeof(SocksHdr_t)) < sizeof(SocksHdr_t))
    {
-      log_msg(L_ERROR, "[socks_connect] short read, closing.");
+      log_msg(L_ERROR, "short read, closing.");
       close(fd);
       return E_SOCKS_REQ;
    }
-   log_msg(L_DEBUG, "[socks_connect] socks response received");
+   log_msg(L_DEBUG, "socks response received");
 
    if (shdr->ver || (shdr->cmd != 90))
    {
-      log_msg(L_ERROR, "[socks_connect] request failed, reason = %d", shdr->cmd);
+      log_msg(L_ERROR, "request failed, reason = %d", shdr->cmd);
       close(fd);
       return E_SOCKS_RQFAIL;
    }
-   log_msg(L_NOTICE, "[socks_connect] connection to %s successfully opened on fd %d", onion, fd);
+   log_msg(L_NOTICE, "connection to %s successfully opened on fd %d", onion, fd);
 
    ohd = insert_peer(fd, addr);
    pthread_mutex_lock(&peer_mutex_);

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