From aa84d1501fc5d6024acfabc7b4b688b891f8e234 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Fri, 30 Jun 2000 10:49:48 +0000 Subject: [PATCH] Added SOCKS4 and SOCKS5 support for SILC client. --- acconfig.h | 25 ++++++++++ apps/silc/silc.c | 11 ++++- configure.in | 101 ++++++++++++++++++++++++++++++++++++++++ includes/silcincludes.h | 4 ++ lib/silccore/silcnet.c | 9 +++- 5 files changed, 146 insertions(+), 4 deletions(-) diff --git a/acconfig.h b/acconfig.h index 65e1903e..17c67b0e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -14,3 +14,28 @@ #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 diff --git a/apps/silc/silc.c b/apps/silc/silc.c index fa4c1898..93ac8327 100644 --- a/apps/silc/silc.c +++ b/apps/silc/silc.c @@ -20,8 +20,11 @@ /* * $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); diff --git a/configure.in b/configure.in index a1382119..677d4cbf 100644 --- a/configure.in +++ b/configure.in @@ -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" diff --git a/includes/silcincludes.h b/includes/silcincludes.h index abb8b3f8..f62e361d 100644 --- a/includes/silcincludes.h +++ b/includes/silcincludes.h @@ -40,6 +40,10 @@ #include #include +#ifdef SOCKS5 +#include "socks.h" +#endif + #ifdef HAVE_GETOPT_H #include #else diff --git a/lib/silccore/silcnet.c b/lib/silccore/silcnet.c index 79aa3cc7..3104b67c 100644 --- a/lib/silccore/silcnet.c +++ b/lib/silccore/silcnet.c @@ -20,8 +20,11 @@ /* * $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 */ -- 2.24.0