Added SOCKS4 and SOCKS5 support for SILC client.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 30 Jun 2000 10:49:48 +0000 (10:49 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 30 Jun 2000 10:49:48 +0000 (10:49 +0000)
acconfig.h
apps/silc/silc.c
configure.in
includes/silcincludes.h
lib/silccore/silcnet.c

index 65e1903ecb897aeb2f51a52c7c0599ecf63106ec..17c67b0e4877211b6c5c30fc20b2620db7354db9 100644 (file)
 #undef SILC_SIM
 #undef HAVE_RTLD_NOW
 #undef HAVE_RTLD_LAZY
+
+/* Redefs for SOCKS5 library */
+#undef SOCKS
+#undef SOCKS5
+#undef Rconnect
+#undef Rgetsockname
+#undef Rgetpeername
+#undef Rbind
+#undef Raccept  
+#undef Rlisten
+#undef Rselect
+#undef Rrecvfrom
+#undef Rsendto
+#undef Rrecv
+#undef Rsend
+#undef Rread
+#undef Rwrite
+#undef Rrresvport
+#undef Rshutdown
+#undef Rlisten
+#undef Rclose
+#undef Rdup
+#undef Rdup2
+#undef Rfclose
+#undef Rgethostbyname
index fa4c1898d86597e12fb320dcfb9786e04c80ead4..93ac83272b3c81752099dc50d988b10ab0bd1db2 100644 (file)
 /*
  * $Id$
  * $Log$
- * Revision 1.1  2000/06/27 11:36:56  priikone
- * Initial revision
+ * Revision 1.2  2000/06/30 10:49:48  priikone
+ *     Added SOCKS4 and SOCKS5 support for SILC client.
+ *
+ * Revision 1.1.1.1  2000/06/27 11:36:56  priikone
+ *     Importet from internal CVS/Added Log headers.
  *
  *
  */
@@ -231,6 +234,10 @@ SILC Secure Internet Live Conferencing, version %s\n",
 
   /* Read local configuration file */
 
+#ifdef SOCKS
+  /* Init SOCKS */
+  SOCKSinit(argv[0]);
+#endif
 
   /* Allocate new client */
   ret = silc_client_alloc(&silc);
index a1382119841f93fc8225101d240352a808ac857b..677d4cbf98656252722a926a98e317f9b657dd72 100644 (file)
@@ -119,6 +119,107 @@ AC_ARG_ENABLE(debug,
 esac ], CFLAGS="-O2 $CFLAGS"
         AC_MSG_RESULT(no))
 
+
+# SOCKS4 support checking
+AC_MSG_CHECKING(whether to support SOCKS4)
+AC_ARG_WITH(socks4,
+[  --with-socks4[=PATH]    Compile with SOCKS4 support.],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    socks=4
+
+    if test -d "$withval/include"; then
+      CFLAGS="$CFLAGS -I$withval/include"
+    else
+      CFLAGS="$CFLAGS -I$withval"
+    fi
+    if test -d "$withval/lib"; then
+      withval="-L$withval/lib -lsocks"
+    else
+      withval="-L$withval -lsocks"
+    fi
+
+    LIBS="$withval $LIBS"
+
+    AC_TRY_LINK([],
+                [ Rconnect(); ],
+                [],
+                [ AC_MSG_ERROR(Could not find SOCKS4 library.)])
+      ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)   
+
+# SOCKS5 support checking
+AC_MSG_CHECKING(whether to support SOCKS5)
+AC_ARG_WITH(socks5,
+[  --with-socks5[=PATH]    Compile with SOCKS5 support.],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    socks=5
+
+    if test -d "$withval/include"; then
+      CFLAGS="$CFLAGS -I$withval/include"
+    else
+      CFLAGS="$CFLAGS -I$withval"
+    fi
+    if test -d "$withval/lib"; then
+      withval="-L$withval/lib -lsocks5"
+    else
+      withval="-L$withval -lsocks5"
+    fi 
+
+    LIBS="$withval $LIBS"
+
+    AC_TRY_LINK([],
+                [ SOCKSconnect(); ],
+                [],
+                [ AC_MSG_ERROR(Could not find SOCKS5 library.)])
+      ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)   
+
+if test "x$socks" = "x4"; then
+  AC_DEFINE(SOCKS)
+  CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
+fi
+
+if test "x$socks" = "x5"; then
+  AC_DEFINE(SOCKS)
+  AC_DEFINE(SOCKS5)
+  AC_DEFINE(Rconnect, SOCKSconnect)
+  AC_DEFINE(Rgetsockname, SOCKSgetsockname)
+  AC_DEFINE(Rgetpeername, SOCKSgetpeername)
+  AC_DEFINE(Rbind, SOCKSbind)
+  AC_DEFINE(Raccept, SOCKSaccept)
+  AC_DEFINE(Rlisten, SOCKSlisten)
+  AC_DEFINE(Rselect, SOCKSselect)
+  AC_DEFINE(Rrecvfrom, SOCKSrecvfrom)
+  AC_DEFINE(Rsendto, SOCKSsendto)
+  AC_DEFINE(Rrecv, SOCKSrecv)
+  AC_DEFINE(Rsend, SOCKSsend)
+  AC_DEFINE(Rread, SOCKSread)
+  AC_DEFINE(Rwrite, SOCKSwrite)
+  AC_DEFINE(Rrresvport, SOCKSrresvport)
+  AC_DEFINE(Rshutdown, SOCKSshutdown)
+  AC_DEFINE(Rlisten, SOCKSlisten)
+  AC_DEFINE(Rclose, SOCKSclose)
+  AC_DEFINE(Rdup, SOCKSdup)
+  AC_DEFINE(Rdup2, SOCKSdup2)
+  AC_DEFINE(Rfclose, SOCKSfclose)
+  AC_DEFINE(Rgethostbyname, SOCKSgethostbyname)
+fi
+
+
 # XXX
 #LIBS="$LIBS -lefence"
 
index abb8b3f87a31e49af30b0f5d22d875a2b50e6381..f62e361da1ebc88ccded59024e5c2458bb43a8e6 100644 (file)
 #include <sys/time.h>
 #include <sys/times.h>
 
+#ifdef SOCKS5
+#include "socks.h"
+#endif
+
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #else
index 79aa3cc7748c8f83f5b7ff233ed0dcf7c15706c7..3104b67c72a20b45790acf2b58b004c22968b213 100644 (file)
 /*
  * $Id$
  * $Log$
- * Revision 1.1  2000/06/27 11:36:55  priikone
- * Initial revision
+ * Revision 1.2  2000/06/30 10:49:48  priikone
+ *     Added SOCKS4 and SOCKS5 support for SILC client.
+ *
+ * Revision 1.1.1.1  2000/06/27 11:36:55  priikone
+ *     Importet from internal CVS/Added Log headers.
  *
  *
  */
@@ -119,6 +122,7 @@ int silc_net_create_connection(int port, char *host)
   /* Set socket information */
   memset(&desthost, 0, sizeof(desthost));
   desthost.sin_port = htons(port);
+  desthost.sin_family = PF_INET;
   memcpy(&desthost.sin_addr, dest->h_addr_list[0], sizeof(desthost.sin_addr));
 
   /* Create the connection socket */
@@ -169,6 +173,7 @@ int silc_net_create_connection_async(int port, char *host)
   /* Set socket information */
   memset(&desthost, 0, sizeof(desthost));
   desthost.sin_port = htons(port);
+  desthost.sin_family = PF_INET;
   memcpy(&desthost.sin_addr, dest->h_addr_list[0], sizeof(desthost.sin_addr));
 
   /* Create the connection socket */