[Pkg-privacy-commits] [onioncat] 12/241: improved FreeBSD tun code
Intrigeri
intrigeri at moszumanska.debian.org
Wed Aug 26 16:16:14 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 a9b6359d9755054e8dad1ece7001cf11134cc6b0
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Fri Feb 8 11:37:44 2008 +0000
improved FreeBSD tun code
git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@127 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
ocat.h | 1 +
ocatroute.c | 5 +++++
ocattun.c | 17 ++++++++++++++---
ocatv6conv.c | 7 +++++++
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/ocat.h b/ocat.h
index 88c74cc..7e69968 100644
--- a/ocat.h
+++ b/ocat.h
@@ -105,6 +105,7 @@ int has_tor_prefix(const struct in6_addr *);
/* ocattun.c */
#ifndef WITHOUT_TUN
int tun_alloc(char *, struct in6_addr);
+void test_tun_hdr(void);
#endif
/* ocatroute.c */
diff --git a/ocatroute.c b/ocatroute.c
index 85e191e..e2ad771 100644
--- a/ocatroute.c
+++ b/ocatroute.c
@@ -298,6 +298,11 @@ int validate_frame(const struct ip6_hdr *ihd, int len)
log_msg(L_ERROR, "[validate_frame] source address invalid. Remote ocat could not reply");
return 0;
}
+ if (is_testping(&ihd->ip6_dst))
+ {
+ log_msg(L_DEBUG, "[validate_frame] test ping detected");
+ return 0;
+ }
return ntohs(ihd->ip6_plen);
}
diff --git a/ocattun.c b/ocattun.c
index 8638f11..1034d81 100644
--- a/ocattun.c
+++ b/ocattun.c
@@ -57,6 +57,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
char buf[FRAME_SIZE];
#endif
+ log_msg(L_DEBUG, "opening tun \"%s\"", tun_dev_);
if( (fd = open(tun_dev_, O_RDWR)) < 0 )
perror("open tun"), exit(1);
@@ -108,9 +109,6 @@ int tun_alloc(char *dev, struct in6_addr addr)
if (system(buf) == -1)
log_msg(L_ERROR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
#else
- sprintf(buf, "ifconfig tun0 inet6 %s/%d up", astr, TOR_PREFIX_LEN);
-/* if (system(buf) == -1)
- log_msg(L_ERROR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));*/
int prm = 1;
if (ioctl(fd, TUNSIFHEAD, &prm) == -1)
perror("ioctl:TUNSIFHEAD"), exit(1);
@@ -118,6 +116,12 @@ int tun_alloc(char *dev, struct in6_addr addr)
// prm = IFF_BROADCAST;
if (ioctl(fd, TUNSIFMODE, &prm) == -1)
perror("ioctl:TUNSIFMODE"), exit(1);
+
+ sprintf(buf, "ifconfig tun0 inet6 %s/%d up", astr, TOR_PREFIX_LEN);
+ log_msg(L_DEBUG, "setting IP on tun: \"%s\"", buf);
+ if (system(buf) == -1)
+ log_msg(L_ERROR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
+
#endif
#endif
@@ -136,8 +140,15 @@ void test_tun_hdr(void)
log_msg(L_FATAL, "[test_tun_hdr] this should never happen..."), exit(1);
inet_ntop(AF_INET6, &addr, addrstr, INET6_ADDRSTRLEN);
+#ifdef linux
sprintf(buf, "ping6 -c 1 -w 1 %s >/dev/null 2>&1", addrstr);
+#else
+ //sprintf(buf, "ping6 -c 1 %s >/dev/null 2>&1", addrstr);
+ sprintf(buf, "ping6 -c 1 %s", addrstr);
+#endif
log_msg(L_NOTICE, "[test_tun_hdr] testing tun header: \"%s\"", buf);
+ // FIXME: This is somehow an unclean try to wait for ifconfig to finish
+ sleep(1);
if (system(buf) == -1)
log_msg(L_FATAL, "[test_tun_hdr] test failed: \"%s\"", strerror(errno));
rlen = read(tunfd_[0], buf, FRAME_SIZE);
diff --git a/ocatv6conv.c b/ocatv6conv.c
index 24ab611..06bb571 100644
--- a/ocatv6conv.c
+++ b/ocatv6conv.c
@@ -20,6 +20,13 @@ static const char BASE32[] = "abcdefghijklmnopqrstuvwxyz234567";
static const char tor_prefix_[] = TOR_PREFIX;
+int is_testping(const struct in6_addr *addr)
+{
+ char to[10] = {0,0,0,0,0,0,0,0,0,1};
+ return memcmp((char*) addr + 6, to, 10) == 0;
+}
+
+
int has_tor_prefix(const struct in6_addr *addr)
{
return memcmp(addr, tor_prefix_, 6) == 0;
--
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