Tor and privoxy had been ported to iphone and works very well.

cjacker huang cjacker at gmail.com
Mon Dec 17 09:25:57 UTC 2007


Hi, there,
   I just ported libevent, tor-0.1.2.18 and privoxy to iphone 1.1.1 fw.
and finished a iPhone app named iTor.app.

There is almost no need to change the code.
just modify the project files(disable some configure tests and set
some default definitions) and a little code.(the default
MAXCONNECTIONS 15000 is too big, I use cygwin's value 3200).

these three definitions had been set to 1 by default:

USING_TWOS_COMPLEMENT
NULL_REP_IS_ZERO_BYTES
TIME_T_IS_SIGNED


It works pretty good on iphone. also I tested it with privoxy on PC
and tor on iphone.

for more infomation and source.
http://www.linux-ren.org/modules/everestblog/?p=161

the patch is below, compile it with:

$autoconf
$./configure --host=arm-apple-darwin --enable-iphone



diff -Nur tor-0.1.2.18/configure.in tor-0.1.2.18n/configure.in
--- tor-0.1.2.18/configure.in	2007-10-28 19:17:47.000000000 +0800
+++ tor-0.1.2.18n/configure.in	2007-12-17 17:16:19.000000000 +0800
@@ -19,6 +19,13 @@
     CFLAGS="$CFLAGS -g"
 fi])

+AC_ARG_ENABLE(iphone,
+ AC_HELP_STRING(--enable-iphone, compile with iphone),
+[if test x$enableval = xyes; then
+	iphone=true
+    CFLAGS="$CFLAGS -D__DARWIN_UNIX03 -D__IPHONE"
+fi])
+
 AC_ARG_ENABLE(eventdns,
      AC_HELP_STRING(--enable-eventdns, enable asynchronous dns module),
      [case "${enableval}" in
@@ -395,8 +402,8 @@
     CPPFLAGS="-I$tor_cv_openssl_dir $CPPFLAGS"
   fi
 fi
-
-if test -z "$CROSS_COMPILE"
+if test $iphone = false; then
+if test -z "$CROSS_COMPILE"
 then
 AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
                tor_cv_openssl_linker_option, [
@@ -458,7 +465,7 @@
    LDFLAGS="$tor_cv_openssl_linker_option $LDFLAGS"
 fi
 fi
-
+fi
 dnl Make sure to enable support for large off_t if avalable.

 AC_SYS_LARGEFILE
@@ -584,7 +591,7 @@
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif])
-
+if test $iphone = false; then
 if test -z "$CROSS_COMPILE"; then
 AC_CACHE_CHECK([whether time_t is signed], tor_cv_time_t_signed, [
 AC_TRY_RUN([
@@ -610,6 +617,13 @@
   AC_DEFINE([TIME_T_IS_SIGNED], 1,
             [Define to 1 iff time_t is signed])
 fi
+fi
+
+if test $iphone = true; then
+  AC_DEFINE([TIME_T_IS_SIGNED], 1,
+            [Define to 1 iff time_t is signed])
+fi
+

 AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
 #ifdef HAVE_SYS_SOCKET_H
@@ -648,6 +662,11 @@
             [Define to 1 iff memset(0) sets pointers to NULL])
 fi

+if test $iphone = true; then
+  AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
+            [Define to 1 iff memset(0) sets pointers to NULL])
+fi
+
 # And what happens when we malloc zero?

 if test -z "$CROSS_COMPILE"; then
@@ -696,6 +715,11 @@
             [Define to 1 iff we represent negative integers with
two's complement])
 fi

+if test $iphone = true; then
+  AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
+            [Define to 1 iff we represent negative integers with
two's complement])
+fi
+
 # Whether we should use the dmalloc memory allocation debugging library.
 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
 AC_ARG_WITH(dmalloc,
diff -Nur tor-0.1.2.18/src/or/or.h tor-0.1.2.18n/src/or/or.h
--- tor-0.1.2.18/src/or/or.h	2007-10-14 19:06:52.000000000 +0800
+++ tor-0.1.2.18n/src/or/or.h	2007-12-17 17:16:23.000000000 +0800
@@ -80,7 +80,7 @@

 /** Upper bound on maximum simultaneous connections; can be lowered by
  * config file. */
-#if defined(CYGWIN) || defined(__CYGWIN__)
+#if defined(CYGWIN) || defined(__CYGWIN__) || (__IPHONE)
 /* http://archives.seul.org/or/talk/Aug-2006/msg00210.html */
 #define MAXCONNECTIONS 3200
 #else


-- 
This is Cjacker.



More information about the tor-dev mailing list