[Pkg-privacy-commits] [onioncat] 56/241: onioncat 0.1.7 released
Intrigeri
intrigeri at moszumanska.debian.org
Wed Aug 26 16:16:26 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 9c3d1293bf0f25f671b87a7782a07c8d9e716d87
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Sat Jun 21 12:11:41 2008 +0000
onioncat 0.1.7 released
git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@223 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
configure.ac | 2 +-
src/ocat.c | 36 ++++++++++++++++++-----------------
src/ocat.h | 9 ++++++++-
src/ocatlog.c | 6 ++++--
src/ocatroute.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++------
5 files changed, 84 insertions(+), 27 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5160cc8..1b6c0a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([onioncat], [0.1.7], [rahra at cypherpunk.at])
+AC_INIT([onioncat], [0.1.8], [rahra at cypherpunk.at])
AM_INIT_AUTOMAKE([-Wall -Werror])
#AC_CONFIG_SRCDIR([ocatroute.c])
AC_CONFIG_HEADERS([config.h])
diff --git a/src/ocat.c b/src/ocat.c
index 0152655..8de5a54 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -39,6 +39,9 @@
int tunfd_[2] = {0, 1};
extern int debug_level_;
+char *usrname_ = OCAT_UNAME;
+char onion_url_[ONION_NAME_SIZE];
+struct in6_addr ocat_addr_;
void usage(const char *s)
@@ -71,10 +74,9 @@ void usage(const char *s)
int main(int argc, char *argv[])
{
- char tunname[IFNAMSIZ] = "", onion[ONION_NAME_SIZE], *s, ip6addr[INET6_ADDRSTRLEN];
- struct in6_addr addr;
+ char tunname[IFNAMSIZ] = "", /*onion[ONION_NAME_SIZE],*/ *s, ip6addr[INET6_ADDRSTRLEN];
+ //struct in6_addr addr;
int c, runasroot = 0;
- char *usrname = OCAT_UNAME;
struct passwd *pwd;
int urlconv = 0, test_only = 0, controller = 1;
@@ -127,7 +129,7 @@ int main(int argc, char *argv[])
#endif
case 'u':
- usrname = optarg;
+ usrname_ = optarg;
break;
case 'v':
@@ -148,25 +150,25 @@ int main(int argc, char *argv[])
if (urlconv == 2)
{
- if (inet_pton(AF_INET6, argv[optind], &addr) <= 0)
+ if (inet_pton(AF_INET6, argv[optind], &ocat_addr_) <= 0)
log_msg(L_ERROR, "%s", strerror(errno)), exit(1);
- if (!has_tor_prefix(&addr))
+ if (!has_tor_prefix(&ocat_addr_))
log_msg(L_ERROR, "address does not have TOR prefix"), exit(1);
- ipv6tonion(&addr, onion);
- printf("%s.onion\n", onion);
+ ipv6tonion(&ocat_addr_, onion_url_);
+ printf("%s.onion\n", onion_url_);
exit(0);
}
// convert parameter to IPv6 address
- strncpy(onion, argv[optind], ONION_NAME_SIZE);
- if ((s = strchr(onion, '.')))
+ strncpy(onion_url_, argv[optind], ONION_NAME_SIZE);
+ if ((s = strchr(onion_url_, '.')))
*s = '\0';
- if (strlen(onion) != 16)
+ if (strlen(onion_url_) != 16)
log_msg(L_ERROR, "parameter seems not to be valid onion hostname"), exit(1);
- if (oniontipv6(onion, &addr) == -1)
+ if (oniontipv6(onion_url_, &ocat_addr_) == -1)
log_msg(L_ERROR, "parameter seems not to be valid onion hostname"), exit(1);
- inet_ntop(AF_INET6, &addr, ip6addr, INET6_ADDRSTRLEN);
+ inet_ntop(AF_INET6, &ocat_addr_, ip6addr, INET6_ADDRSTRLEN);
if (urlconv == 1)
{
@@ -178,7 +180,7 @@ int main(int argc, char *argv[])
#ifndef WITHOUT_TUN
// create TUN device
- tunfd_[0] = tunfd_[1] = tun_alloc(tunname, addr);
+ tunfd_[0] = tunfd_[1] = tun_alloc(tunname, ocat_addr_);
#ifdef TEST_TUN_HDR
test_tun_hdr();
if (test_only)
@@ -199,10 +201,10 @@ int main(int argc, char *argv[])
if (!runasroot && !getuid())
{
errno = 0;
- if (!(pwd = getpwnam(usrname)))
- log_msg(L_FATAL, "can't get information for user \"%s\": \"%s\"", usrname, errno ? strerror(errno) : "user not found"), exit(1);
+ if (!(pwd = getpwnam(usrname_)))
+ log_msg(L_FATAL, "can't get information for user \"%s\": \"%s\"", usrname_, errno ? strerror(errno) : "user not found"), exit(1);
- log_msg(L_NOTICE, "running as root, changing uid/gid to %s (uid %d/gid %d)", usrname, pwd->pw_uid, pwd->pw_gid);
+ log_msg(L_NOTICE, "running as root, changing uid/gid to %s (uid %d/gid %d)", usrname_, pwd->pw_uid, pwd->pw_gid);
if (setgid(pwd->pw_gid))
log_msg(L_ERROR, "could not change gid: \"%s\"", strerror(errno)), exit(1);
if (setuid(pwd->pw_uid))
diff --git a/src/ocat.h b/src/ocat.h
index a728a3b..f15efb0 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -45,6 +45,7 @@
#define TOR_SOCKS_PORT 9050
#define OCAT_UNAME "tor"
#define OCAT_UID 112
+#define OCAT_URL "http://www.abenteuerland.at/onioncat/"
//! Maximum frame (packet) size, should be able to keep one maximum size ipv6-packet: 2^16 + 40 + 4
#define FRAME_SIZE 65580
@@ -193,7 +194,6 @@ extern uint16_t tor_socks_port_;
extern uint16_t ocat_listen_port_;
extern uint16_t ocat_dest_port_;
extern int vrec_;
-extern int tunfd_[2];
#ifndef WITHOUT_TUN
#define TUN_DEV "/dev/net/tun"
@@ -203,6 +203,13 @@ extern uint32_t fhd_key_;
extern pthread_mutex_t thread_mutex_;
extern OcatThread_t *octh_;
+extern char *usrname_;
+
+/* ocat.c */
+//extern int tunfd_[2];
+extern int tunfd_[];
+extern char onion_url_[];
+extern struct in6_addr ocat_addr_;
/* ocatlog.c */
void log_msg(int, const char *, ...);
diff --git a/src/ocatlog.c b/src/ocatlog.c
index e901cd0..d540c67 100644
--- a/src/ocatlog.c
+++ b/src/ocatlog.c
@@ -28,6 +28,7 @@
#include "ocat.h"
+#define TIMESTRLEN 64
int debug_level_ = 4;
static pthread_mutex_t log_mutex_ = PTHREAD_MUTEX_INITIALIZER;
@@ -39,7 +40,7 @@ void log_msg(int lf, const char *fmt, ...)
struct tm *tm;
time_t t;
FILE *out = stderr;
- char timestr[32] = "";
+ char timestr[TIMESTRLEN] = "";
va_list ap;
const OcatThread_t *th = get_thread();
@@ -49,7 +50,8 @@ void log_msg(int lf, const char *fmt, ...)
t = time(NULL);
tm = localtime(&t);
if (tm)
- strftime(timestr, 32, "%c", tm);
+ //strftime(timestr, 32, "%c", tm);
+ strftime(timestr, TIMESTRLEN, "%a, %d %b %Y %H:%M:%S %z", tm);
pthread_mutex_lock(&log_mutex_);
fprintf(out, "%s [%d:%-*s:%6s] ", timestr, th->id, THREAD_NAME_LEN - 1, th->name, flty_[lf]);
diff --git a/src/ocatroute.c b/src/ocatroute.c
index a5f95f5..fdbcf0c 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -286,6 +286,37 @@ void cleanup_socket(int fd, OcatPeer_t *peer)
}
+#define HANDLE_HTTP
+#ifdef HANDLE_HTTP
+#define BSTRLEN 1024
+
+int handle_http(const OcatPeer_t *peer)
+{
+ time_t t;
+ char response[BSTRLEN], timestr[BSTRLEN];
+ struct tm tm;
+
+ // simple check if packet could be an HTTP request
+ if (strncmp(peer->fragbuf, "GET ", 4))
+ return 0;
+
+ t = time(NULL);
+ (void) localtime_r(&t, &tm);
+ strftime(timestr, BSTRLEN, "%a, %d %b %Y %H:%M:%S %z", &tm);
+ snprintf(response, BSTRLEN,
+ "HTTP/1.0 301 HTTP not possible\r\nLocation: %s\r\nDate: %s\r\nContent-Type: text/html; charset=iso-8859-1\r\n\r\n"
+ "<html><body><h1>HTTP not possible!<br>OnionCat is running on this port at \"%s.onion\"</h1></body></html>\r\n",
+ OCAT_URL, timestr, onion_url_
+ );
+ log_msg(L_INFO, "request seems to be HTTP");
+ if (send(peer->tcpfd, response, strlen(response), MSG_DONTWAIT) == -1)
+ log_msg(L_ERROR, "could not send html response");
+
+ return 1;
+}
+#endif
+
+
void *socket_receiver(void *p)
{
int maxfd, len, plen;
@@ -404,6 +435,17 @@ void *socket_receiver(void *p)
if (!plen)
{
+#ifdef HANDLE_HTTP
+ if (handle_http(peer))
+ {
+ log_msg(L_NOTICE, "closing %d due to HTTP.", peer->tcpfd);
+ close(peer->tcpfd);
+ unlock_peer(peer);
+ lock_peers();
+ delete_peer(peer);
+ unlock_peers();
+ }
+#endif
log_msg(L_DEBUG, "FRAGBUF RESET!");
peer->fraglen = 0;
break;
@@ -651,7 +693,7 @@ void *socket_acceptor(void *p)
int socks_connect(const struct in6_addr *addr)
{
struct sockaddr_in in;
- int fd, t;
+ int fd, t, len;
char buf[FRAME_SIZE], onion[ONION_NAME_SIZE];
SocksHdr_t *shdr = (SocksHdr_t*) buf;
@@ -687,12 +729,16 @@ int socks_connect(const struct in6_addr *addr)
shdr->cmd = 1;
shdr->port = htons(ocat_dest_port_);
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)
+ /*
+ strlcpy(buf + sizeof(SocksHdr_t), usrname_, strlen(usrname_) + 1);
+ strlcpy(buf + sizeof(SocksHdr_t) + strlen(usrname_) + 1, onion, sizeof(onion));
+ */
+ memcpy(buf + sizeof(SocksHdr_t), usrname_, strlen(usrname_) + 1);
+ memcpy(buf + sizeof(SocksHdr_t) + strlen(usrname_) + 1, onion, strlen(onion) + 1);
+ len = sizeof(SocksHdr_t) + strlen(usrname_) + strlen(onion) + 2;
+ if (write(fd, shdr, len) != len)
// FIXME: there should be some additional error handling
- log_msg(L_ERROR, "couldn't write %d bytes to SOCKS connection %d", sizeof(SocksHdr_t) + strlen(onion) + 6, fd);
+ log_msg(L_ERROR, "couldn't write %d bytes to SOCKS connection %d", len, fd);
log_msg(L_DEBUG, "connect request sent");
if (read(fd, shdr, sizeof(SocksHdr_t)) < sizeof(SocksHdr_t))
--
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