Bugzilla – Attachment 1615 Details for
Bug 1572
accept SOCKS requests over the mux socket in master mode
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for dsocks-1.6
dsocks-unixsocket-0.patch (text/plain), 3.75 KB, created by
Salvador Fandiño
on 2009-03-11 20:16:41 AEDT
(
hide
)
Description:
patch for dsocks-1.6
Filename:
MIME Type:
Creator:
Salvador Fandiño
Created:
2009-03-11 20:16:41 AEDT
Size:
3.75 KB
patch
obsolete
>diff -ru dsocks-1.6/dsocks.c my-dsocks-1.6/dsocks.c >--- dsocks-1.6/dsocks.c Thu Oct 12 06:13:58 2006 >+++ my-dsocks-1.6/dsocks.c Mon Mar 9 16:38:12 2009 >@@ -30,6 +30,7 @@ > #include <stdlib.h> > #include <string.h> > #include <unistd.h> >+#include <sys/un.h> > > #include "atomicio.h" > #include "dsocks.h" >@@ -39,8 +40,17 @@ > const struct addrinfo *, struct addrinfo **); > typedef struct hostent *(*gethostbyname_fn)(const char *name); > >+typedef union { >+ struct sockaddr any; >+ struct sockaddr_in in; >+ struct sockaddr_un un; >+} sockaddr_any; >+ >+static int _dsocks_domain = AF_UNSPEC; > static int _dsocks_tor; >-static struct sockaddr_in _dsocks_sin, _dsocks_ns; >+static struct sockaddr_in _dsocks_sin; >+static struct sockaddr_un _dsocks_sun; >+static struct sockaddr_in _dsocks_ns; > static char _dsocks_user[MAXLOGNAME + 1]; > static char _dsocks_host[MAXHOSTNAMELEN + 1]; > static connect_fn _dsocks_connect, _sys_connect; >@@ -181,17 +191,41 @@ > connect(int fd, const struct sockaddr *sa, socklen_t len) > { > struct sockaddr_in sin; >+ int fd1; > > if (sa->sa_family != AF_INET || IS_LOOPBACK(sa)) > return ((*_sys_connect)(fd, sa, len)); > > memcpy(&sin, sa, sizeof(sin)); >- if ((*_sys_connect)(fd, (struct sockaddr *)&_dsocks_sin, >- sizeof(_dsocks_sin)) == -1) { >- warnx("(dsocks) couldn't connect to proxy at %s", >- _sin_ntoa(&_dsocks_sin)); >- return (-1); >+ if (_dsocks_domain == AF_UNIX) { >+ if ((fd1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { >+ warnx("(dsocks) couldn't create socket: %s", >+ strerror(errno)); >+ return (-1); >+ } >+ if ((*_sys_connect)(fd1, (struct sockaddr *)&_dsocks_sun, >+ sizeof(struct sockaddr_un)) == -1) { >+ warnx("(dsocks) couldn't connect to proxy at %s: %s", >+ _dsocks_sun.sun_path, strerror(errno)); >+ close(fd1); >+ return (-1); >+ } >+ if (dup2(fd1, fd) == -1) { >+ warnx("(dsocks) couldn't dup socket: %s", >+ strerror(errno)); >+ close(fd1); >+ return (-1); >+ } >+ close(fd1); > } >+ else { >+ if ((*_sys_connect)(fd, (struct sockaddr *)&_dsocks_sin, >+ sizeof(struct sockaddr_in)) == -1) { >+ warnx("(dsocks) couldn't connect to proxy at %s", >+ _sin_ntoa(&_dsocks_sin)); >+ return (-1); >+ } >+ } > return ((*_dsocks_connect)(fd, (struct sockaddr *)&sin, sizeof(sin))); > } > >@@ -592,11 +626,30 @@ > if (getenv(DSOCKS_ENV_TOR) != NULL) { > _dsocks_tor = 1; > } >- if ((env = getenv(DSOCKS_ENV_PROXY)) != NULL) { >+ if ((env = getenv(DSOCKS_ENV_DOMAIN)) != NULL) { >+ if (!strcmp(env, "UNIX")) >+ _dsocks_domain = AF_UNIX; >+ else if (!strcmp(env, "INET")) >+ _dsocks_domain = AF_INET; >+ else >+ errx(1, "(dsocks) invalid proxy domain (valid " >+ "values are UNIX and INET): %s\n", env); >+ } >+ env = getenv(DSOCKS_ENV_PROXY); >+ if (!env) env = "127.0.0.1"; >+ >+ if ((_dsocks_domain == AF_UNIX) || >+ ((_dsocks_domain == AF_UNSPEC) && strchr(env, '/'))) { >+ _dsocks_sun.sun_len = sizeof(_dsocks_sun); >+ _dsocks_sun.sun_family = _dsocks_domain = AF_UNIX; >+ if (strlen(env) >= sizeof(_dsocks_sun.sun_path)) >+ errx(1, "(dsocks) server path too long\n"); >+ strcpy(_dsocks_sun.sun_path, env); >+ } else { >+ _dsocks_domain = AF_INET; > if (_sin_aton(env, &_dsocks_sin, 1080) < 0) > errx(1, "(dsocks) invalid proxy: %s", env); >- } else >- _sin_aton("127.0.0.1", &_dsocks_sin, 1080); >+ } > > if ((env = getenv(DSOCKS_ENV_NAMESERVER)) != NULL) { > if (_sin_aton(env, &_dsocks_ns, 53) < 0) >diff -ru dsocks-1.6/dsocks.h my-dsocks-1.6/dsocks.h >--- dsocks-1.6/dsocks.h Thu Oct 12 06:13:58 2006 >+++ my-dsocks-1.6/dsocks.h Mon Mar 9 16:34:51 2009 >@@ -72,6 +72,7 @@ > #define DSOCKS_ENV_PROXY "DSOCKS_PROXY" > #define DSOCKS_ENV_TOR "DSOCKS_TOR" > #define DSOCKS_ENV_NAMESERVER "DSOCKS_NAMESERVER" >+#define DSOCKS_ENV_DOMAIN "DSOCKS_DOMAIN" > > void _dsocks_init(void) __attribute__((constructor)); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1572
:
1613
|
1614
| 1615 |
1616