Relays, SOCKS: no tracing of their own

sockmap() under WITHLOG, and the SOCKS proxy under SOCKSTRACE, wrote
what they did to the log or to stderr, a build for debugging asking for
it: some 200 lines in the middle of the code, never built otherwise.
They go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir Dubrovin 2026-10-28 11:57:37 +03:00
parent d762833a6b
commit c846b4950d
2 changed files with 0 additions and 209 deletions

View File

@ -10,15 +10,6 @@
#define MAXFAILATTEMPT 10 #define MAXFAILATTEMPT 10
#ifdef WITHLOG
#if WITHLOG > 1
char logbuf[1024];
#endif
#define log(X) dolog(param,(const unsigned char *)(X))
#else
#define log(X)
#endif
#ifdef WITHSPLICE #ifdef WITHSPLICE
#include <fcntl.h> #include <fcntl.h>
@ -129,9 +120,6 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
uint64_t inclientbuf = 0, inserverbuf = 0; uint64_t inclientbuf = 0, inserverbuf = 0;
int FROMCLIENT = 1, TOCLIENTBUF = 1, TOSERVER = 1, int FROMCLIENT = 1, TOCLIENTBUF = 1, TOSERVER = 1,
FROMSERVER = 1, TOSERVERBUF = 1, TOCLIENT = 1; FROMSERVER = 1, TOSERVERBUF = 1, TOCLIENT = 1;
#if WITHLOG > 1
int FROMCLIENTBUF = 1, FROMSERVERBUF = 1;
#endif
int HASERROR=0; int HASERROR=0;
int CLIENTTERMREAD = 0, CLIENTTERMWRITE = 0, SERVERTERMREAD = 0, SERVERTERMWRITE = 0; int CLIENTTERMREAD = 0, CLIENTTERMWRITE = 0, SERVERTERMREAD = 0, SERVERTERMWRITE = 0;
/* the side has hung up: closed by the peer after its own was shut down */ /* the side has hung up: closed by the peer after its own was shut down */
@ -239,26 +227,6 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
){ ){
#if WITHLOG > 1
sprintf(logbuf, "int FROMCLIENT = %d, TOCLIENTBUF = %d, FROMCLIENTBUF = %d, TOSERVER = %d, "
"FROMSERVER = %d, TOSERVERBUF = %d, FROMSERVERBUF = %d, TOCLIENT = %d; inclientbuf=%d; "
"inserverbuf=%d, CLIENTTERMREAD=%d CLIENTTERMWRITE=%d SERVERTERMREAD=%d SERVERTERMWRITE=%d fromserver=%u, fromclient=%u"
#ifdef WITHSPLICE
", inserverpipe=%d, inclentpipe=%d "
"TOCLIENTPIPE=%d FROMCLIENTPIPE==%d TOSERVERPIPE==%d FROMSERVERPIPE=%d"
#endif
,
FROMCLIENT, TOCLIENTBUF, FROMCLIENTBUF, TOSERVER,
FROMSERVER, TOSERVERBUF, FROMSERVERBUF, TOCLIENT,
(int)inclientbuf, (int)inserverbuf, CLIENTTERMREAD, CLIENTTERMWRITE, SERVERTERMREAD, SERVERTERMWRITE,
(unsigned)fromserver, (unsigned)fromclient
#ifdef WITHSPLICE
,(int)inserverpipe, (int)inclientpipe,
TOCLIENTPIPE, FROMCLIENTPIPE, TOSERVERPIPE, FROMSERVERPIPE
#endif
);
log(logbuf);
#endif
if(needaction && param->srv->gracedelay && !sleeptime){ if(needaction && param->srv->gracedelay && !sleeptime){
if(gracetime != curtime){ if(gracetime != curtime){
@ -299,9 +267,6 @@ log(logbuf);
} }
if(inclientbuf && TOSERVER){ if(inclientbuf && TOSERVER){
#ifdef WITHLOG
log("send to server from buf");
#endif
if(!param->nolongdatfilter){ if(!param->nolongdatfilter){
action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, param->clioffset, (int *)&param->cliinbuf); action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, param->clioffset, (int *)&param->cliinbuf);
if(action == HANDLED){ if(action == HANDLED){
@ -326,9 +291,6 @@ log("send to server from buf");
} }
} }
else { else {
#ifdef WITHLOG
log("done send to server from buf");
#endif
param->nwrites++; param->nwrites++;
param->statscli64 += res; param->statscli64 += res;
inclientbuf -= res; inclientbuf -= res;
@ -346,9 +308,6 @@ log("done send to server from buf");
} }
} }
if(inserverbuf && TOCLIENT){ if(inserverbuf && TOCLIENT){
#ifdef WITHLOG
log("send to client from buf");
#endif
if(!param->nolongdatfilter){ if(!param->nolongdatfilter){
action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, param->srvoffset, (int *)&param->srvinbuf); action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, param->srvoffset, (int *)&param->srvinbuf);
if(action == HANDLED){ if(action == HANDLED){
@ -373,9 +332,6 @@ log("send to client from buf");
} }
else { else {
#ifdef WITHLOG
log("done send to client from buf");
#endif
inserverbuf -= res; inserverbuf -= res;
fromserver -= res; fromserver -= res;
param->srvoffset += res; param->srvoffset += res;
@ -405,21 +361,9 @@ log("done send to client from buf");
/* each direction goes through its pipe if spliced, through its /* each direction goes through its pipe if spliced, through its
buffer otherwise; what was in the buffer before is sent first */ buffer otherwise; what was in the buffer before is sent first */
if(splicecli && inclientpipe && !inclientbuf && FROMCLIENTPIPE && TOSERVER){ if(splicecli && inclientpipe && !inclientbuf && FROMCLIENTPIPE && TOSERVER){
#ifdef WITHLOG
log("send to server from pipe");
#endif
res = splice(pipecli[0], NULL, param->remsock, NULL, MIN(PIPESIZE, inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE); res = splice(pipecli[0], NULL, param->remsock, NULL, MIN(PIPESIZE, inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
/* from a pipe holding data: the socket is full */ /* from a pipe holding data: the socket is full */
if(res < 0 && errno == EAGAIN && fiberblockfunc) fiberblockfunc(param->remsock, POLLOUT); if(res < 0 && errno == EAGAIN && fiberblockfunc) fiberblockfunc(param->remsock, POLLOUT);
#ifdef WITHLOG
log("server from pipe splice finished\n");
#if WITHLOG > 1
#ifdef WITHSPLICE
sprintf(logbuf, "res: %d, errno: %d", (int)res, (int)errno);
log(logbuf);
#endif
#endif
#endif
if(res >0) { if(res >0) {
param->nwrites++; param->nwrites++;
param->statscli64 += res; param->statscli64 += res;
@ -444,21 +388,9 @@ log(logbuf);
} }
} }
if(splicesrv && inserverpipe && !inserverbuf && FROMSERVERPIPE && TOCLIENT){ if(splicesrv && inserverpipe && !inserverbuf && FROMSERVERPIPE && TOCLIENT){
#ifdef WITHLOG
log("send to client from pipe");
#endif
res = splice(pipesrv[0], NULL, param->clisock, NULL, MIN(PIPESIZE, inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE); res = splice(pipesrv[0], NULL, param->clisock, NULL, MIN(PIPESIZE, inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
/* from a pipe holding data: the socket is full */ /* from a pipe holding data: the socket is full */
if(res < 0 && errno == EAGAIN && fiberblockfunc) fiberblockfunc(param->clisock, POLLOUT); if(res < 0 && errno == EAGAIN && fiberblockfunc) fiberblockfunc(param->clisock, POLLOUT);
#ifdef WITHLOG
log("client from pipe splice finished\n");
#if WITHLOG > 1
#ifdef WITHSPLICE
sprintf(logbuf, "res: %d, errno: %d", (int)res, (int)errno);
log(logbuf);
#endif
#endif
#endif
if(res > 0) { if(res > 0) {
inserverpipe -= res; inserverpipe -= res;
fromserver -= res; fromserver -= res;
@ -476,9 +408,6 @@ log(logbuf);
} }
} }
if(splicecli && !wantbufcli && fromclient>inclientpipe && FROMCLIENT && TOCLIENTPIPE && !SESSIONEND){ if(splicecli && !wantbufcli && fromclient>inclientpipe && FROMCLIENT && TOCLIENTPIPE && !SESSIONEND){
#ifdef WITHLOG
log("read from client to pipe");
#endif
if(pipecli[0] < 0 && pipenew(pipecli) < 0){ if(pipecli[0] < 0 && pipenew(pipecli) < 0){
/* no pipe to be had: copy instead */ /* no pipe to be had: copy instead */
allowcli = splicecli = TOCLIENTPIPE = FROMCLIENTPIPE = 0; allowcli = splicecli = TOCLIENTPIPE = FROMCLIENTPIPE = 0;
@ -497,15 +426,6 @@ log("read from client to pipe");
} }
errno = 0; errno = 0;
res = splice(param->clisock, NULL, pipecli[1], NULL, (int)MIN((uint64_t)PIPESIZE - inclientpipe, (uint64_t)fromclient-inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE); res = splice(param->clisock, NULL, pipecli[1], NULL, (int)MIN((uint64_t)PIPESIZE - inclientpipe, (uint64_t)fromclient-inclientpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
#ifdef WITHLOG
log("client to pipe splice finished\n");
#if WITHLOG > 1
#ifdef WITHSPLICE
sprintf(logbuf, "res: %d, errno: %d", (int)res, (int)errno);
log(logbuf);
#endif
#endif
#endif
if(res <= 0) { if(res <= 0) {
FROMCLIENT = TOCLIENTPIPE = 0; FROMCLIENT = TOCLIENTPIPE = 0;
if(res == 0 && !errno) { if(res == 0 && !errno) {
@ -527,9 +447,6 @@ log(logbuf);
} }
} }
else { else {
#ifdef WITHLOG
log("done read from client to pipe");
#endif
graceclinum++; graceclinum++;
graceclitraf += res; graceclitraf += res;
gracesrvnum = gracesrvtraf = 0; gracesrvnum = gracesrvtraf = 0;
@ -544,9 +461,6 @@ log("done read from client to pipe");
} }
} }
if(splicesrv && !wantbufsrv && fromserver > inserverpipe && FROMSERVER && TOSERVERPIPE && !SESSIONEND){ if(splicesrv && !wantbufsrv && fromserver > inserverpipe && FROMSERVER && TOSERVERPIPE && !SESSIONEND){
#ifdef WITHLOG
log("read from server to pipe\n");
#endif
if(pipesrv[0] < 0 && pipenew(pipesrv) < 0){ if(pipesrv[0] < 0 && pipenew(pipesrv) < 0){
allowsrv = splicesrv = TOSERVERPIPE = FROMSERVERPIPE = 0; allowsrv = splicesrv = TOSERVERPIPE = FROMSERVERPIPE = 0;
if(param->srvinbuf < SRVROOM) TOSERVERBUF = 1; if(param->srvinbuf < SRVROOM) TOSERVERBUF = 1;
@ -562,15 +476,6 @@ log("read from server to pipe\n");
} }
errno = 0; errno = 0;
res = splice(param->remsock, NULL, pipesrv[1], NULL, MIN(PIPESIZE - inserverpipe, fromserver - inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE); res = splice(param->remsock, NULL, pipesrv[1], NULL, MIN(PIPESIZE - inserverpipe, fromserver - inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
#ifdef WITHLOG
log("server to pipe splice finished\n");
#if WITHLOG > 1
#ifdef WITHSPLICE
sprintf(logbuf, "res: %d, errno: %d", (int)res, (int)errno);
log(logbuf);
#endif
#endif
#endif
if(res <= 0) { if(res <= 0) {
FROMSERVER = TOSERVERPIPE = 0; FROMSERVER = TOSERVERPIPE = 0;
if(res == 0 && !errno) { if(res == 0 && !errno) {
@ -590,9 +495,6 @@ log(logbuf);
} }
} }
else { else {
#ifdef WITHLOG
log("done read from server to pipe\n");
#endif
gracesrvnum++; gracesrvnum++;
gracesrvtraf += res; gracesrvtraf += res;
graceclinum = graceclitraf = 0; graceclinum = graceclitraf = 0;
@ -617,9 +519,6 @@ log("done read from server to pipe\n");
#endif #endif
{ {
if((!splicecli || draincli) && fromclient > inclientbuf && FROMCLIENT && TOCLIENTBUF && !SESSIONEND){ if((!splicecli || draincli) && fromclient > inclientbuf && FROMCLIENT && TOCLIENTBUF && !SESSIONEND){
#ifdef WITHLOG
log("read from client to buf");
#endif
/* let go while spliced: made again */ /* let go while spliced: made again */
if(!param->clibuf && bufget(param, CLIENT)) RETURN(21); if(!param->clibuf && bufget(param, CLIENT)) RETURN(21);
/* no address: it would overwrite the client's with what a /* no address: it would overwrite the client's with what a
@ -638,9 +537,6 @@ log("read from client to buf");
} }
} }
else { else {
#ifdef WITHLOG
log("done read from client to buf");
#endif
graceclinum++; graceclinum++;
graceclitraf += res; graceclitraf += res;
gracesrvnum = gracesrvtraf = 0; gracesrvnum = gracesrvtraf = 0;
@ -676,9 +572,6 @@ log("done read from client to buf");
} }
if((!splicesrv || drainsrv) && fromserver > inserverbuf && FROMSERVER && TOSERVERBUF && !SESSIONEND){ if((!splicesrv || drainsrv) && fromserver > inserverbuf && FROMSERVER && TOSERVERBUF && !SESSIONEND){
#ifdef WITHLOG
log("read from server to buf");
#endif
if(!param->srvbuf && bufget(param, SERVER)) RETURN(21); if(!param->srvbuf && bufget(param, SERVER)) RETURN(21);
res = param->srv->so._recvfrom(param->sostate, param->remsock, (char *)param->srvbuf + param->srvinbuf, (int)MIN((uint64_t)SRVROOM - param->srvinbuf, fromserver-inserverbuf), 0, NULL, NULL); res = param->srv->so._recvfrom(param->sostate, param->remsock, (char *)param->srvbuf + param->srvinbuf, (int)MIN((uint64_t)SRVROOM - param->srvinbuf, fromserver-inserverbuf), 0, NULL, NULL);
if(res <= 0) { if(res <= 0) {
@ -694,9 +587,6 @@ log("read from server to buf");
} }
} }
else { else {
#ifdef WITHLOG
log("done read from server to buf");
#endif
gracesrvnum++; gracesrvnum++;
gracesrvtraf += res; gracesrvtraf += res;
graceclinum = graceclitraf = 0; graceclinum = graceclitraf = 0;
@ -775,12 +665,6 @@ log("done read from server to buf");
if(cli_events){ if(cli_events){
fds[fdsc].fd = param->clisock; fds[fdsc].fd = param->clisock;
fds[fdsc].events = cli_events; fds[fdsc].events = cli_events;
#ifdef WITHLOG
if(cli_events & POLLIN)
log("wait reading from client");
if(cli_events & POLLOUT)
log("wait writing to client");
#endif
} }
} }
else if(!clipolled){ else if(!clipolled){
@ -793,15 +677,9 @@ log("wait writing to client");
} }
else { else {
if(fds[fdsc].revents & POLLIN) { if(fds[fdsc].revents & POLLIN) {
#ifdef WITHLOG
log("ready to read from client");
#endif
FROMCLIENT = 1; FROMCLIENT = 1;
} }
if(fds[fdsc].revents & POLLOUT) { if(fds[fdsc].revents & POLLOUT) {
#ifdef WITHLOG
log("ready to write to client");
#endif
TOCLIENT = 1; TOCLIENT = 1;
} }
if(fds[fdsc].revents & (POLLHUP)) { if(fds[fdsc].revents & (POLLHUP)) {
@ -838,21 +716,12 @@ log("ready to write to client");
if(srv_events){ if(srv_events){
fds[fdsc].fd = param->remsock; fds[fdsc].fd = param->remsock;
fds[fdsc].events = srv_events; fds[fdsc].events = srv_events;
#ifdef WITHLOG
if(srv_events & POLLIN)
log("wait reading from server");
if(srv_events & POLLOUT)
log("wait writing from server");
#endif
} }
} }
else if(!srvpolled){ else if(!srvpolled){
} }
else if(srv_events){ else if(srv_events){
if(fds[fdsc].revents & (POLLERR|POLLNVAL)) { if(fds[fdsc].revents & (POLLERR|POLLNVAL)) {
#ifdef WITHLOG
log("poll from server failed");
#endif
SERVERTERMREAD = 1; SERVERTERMREAD = 1;
SERVERTERMWRITE = 1; SERVERTERMWRITE = 1;
@ -860,21 +729,12 @@ log("poll from server failed");
} }
else { else {
if(fds[fdsc].revents & POLLIN) { if(fds[fdsc].revents & POLLIN) {
#ifdef WITHLOG
log("ready to read from server");
#endif
FROMSERVER = 1; FROMSERVER = 1;
} }
if(fds[fdsc].revents & POLLOUT) { if(fds[fdsc].revents & POLLOUT) {
#ifdef WITHLOG
log("ready to write to server");
#endif
TOSERVER = 1; TOSERVER = 1;
} }
if(fds[fdsc].revents & (POLLHUP)) { if(fds[fdsc].revents & (POLLHUP)) {
#ifdef WITHLOG
log("server terminated connection");
#endif
if(fds[fdsc].events & POLLIN) FROMSERVER = 1; if(fds[fdsc].events & POLLIN) FROMSERVER = 1;
if(fds[fdsc].events & POLLOUT){ if(fds[fdsc].events & POLLOUT){
if(hupwrite(param->remsock, fds[fdsc].revents, timeo)) TOSERVER = 1; if(hupwrite(param->remsock, fds[fdsc].revents, timeo)) TOSERVER = 1;
@ -895,9 +755,6 @@ log("server terminated connection");
{ {
if(splicecli && fromclient>inclientpipe && !TOCLIENTPIPE && inclientpipe < PIPESIZE){ if(splicecli && fromclient>inclientpipe && !TOCLIENTPIPE && inclientpipe < PIPESIZE){
if(!after){ if(!after){
#ifdef WITHLOG
log("wait writing to client pipe");
#endif
fds[fdsc].fd = pipecli[1]; fds[fdsc].fd = pipecli[1];
fds[fdsc].events |= POLLOUT; fds[fdsc].events |= POLLOUT;
} }
@ -906,9 +763,6 @@ log("wait writing to client pipe");
RETURN(90); RETURN(90);
} }
if(fds[fdsc].revents & POLLOUT) { if(fds[fdsc].revents & POLLOUT) {
#ifdef WITHLOG
log("ready to write to client pipe");
#endif
TOCLIENTPIPE = 1; TOCLIENTPIPE = 1;
} }
} }
@ -916,9 +770,6 @@ log("ready to write to client pipe");
} }
if(splicecli && inclientpipe && !FROMCLIENTPIPE){ if(splicecli && inclientpipe && !FROMCLIENTPIPE){
if(!after){ if(!after){
#ifdef WITHLOG
log("wait reading from client pipe");
#endif
fds[fdsc].fd = pipecli[0]; fds[fdsc].fd = pipecli[0];
fds[fdsc].events |= (POLLIN); fds[fdsc].events |= (POLLIN);
} }
@ -926,18 +777,12 @@ log("wait reading from client pipe");
if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){ if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){
RETURN(90); RETURN(90);
} }
#ifdef WITHLOG
log("ready reading from client pipe");
#endif
if(fds[fdsc].revents & (POLLIN)) FROMCLIENTPIPE = 1; if(fds[fdsc].revents & (POLLIN)) FROMCLIENTPIPE = 1;
} }
fdsc++; fdsc++;
} }
if(splicesrv && fromserver>inserverpipe && !TOSERVERPIPE && inserverpipe < PIPESIZE){ if(splicesrv && fromserver>inserverpipe && !TOSERVERPIPE && inserverpipe < PIPESIZE){
if(!after){ if(!after){
#ifdef WITHLOG
log("wait writing to server pipe");
#endif
fds[fdsc].fd = pipesrv[1]; fds[fdsc].fd = pipesrv[1];
fds[fdsc].events |= POLLOUT; fds[fdsc].events |= POLLOUT;
} }
@ -945,18 +790,12 @@ log("wait writing to server pipe");
if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){ if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){
RETURN(90); RETURN(90);
} }
#ifdef WITHLOG
log("ready writing to server pipe");
#endif
if(fds[fdsc].revents & POLLOUT) TOSERVERPIPE = 1; if(fds[fdsc].revents & POLLOUT) TOSERVERPIPE = 1;
} }
fdsc++; fdsc++;
} }
if(splicesrv && inserverpipe && !FROMSERVERPIPE){ if(splicesrv && inserverpipe && !FROMSERVERPIPE){
if(!after){ if(!after){
#ifdef WITHLOG
log("wait reading from server pipe");
#endif
fds[fdsc].fd = pipesrv[0]; fds[fdsc].fd = pipesrv[0];
fds[fdsc].events |= (POLLIN); fds[fdsc].events |= (POLLIN);
} }
@ -964,9 +803,6 @@ log("wait reading from server pipe");
if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){ if(fds[fdsc].revents & (POLLHUP|POLLERR|POLLNVAL)){
RETURN(90); RETURN(90);
} }
#ifdef WITHLOG
log("ready reading from server pipe");
#endif
if(fds[fdsc].revents & (POLLIN)) FROMSERVERPIPE = 1; if(fds[fdsc].revents & (POLLIN)) FROMSERVERPIPE = 1;
} }
fdsc++; fdsc++;
@ -997,26 +833,14 @@ log("ready reading from server pipe");
#ifdef WITHLOG
log("entering poll");
#endif
res = sockpoll(&param->srv->so, param->sostate, fds, fdsc, res = sockpoll(&param->srv->so, param->sostate, fds, fdsc,
((CLIENTTERMREAD || SERVERTERMREAD)? ((CLIENTTERMREAD || SERVERTERMREAD)?
MIN(timeo, param->srv->timeouts[LINGER_TO]) : timeo) * 1000); MIN(timeo, param->srv->timeouts[LINGER_TO]) : timeo) * 1000);
#ifdef WITHLOG
log("leaving poll");
#endif
if(res < 0){ if(res < 0){
#ifdef WITHLOG
log("poll error");
#endif
if(errno != EINTR) RETURN(91); if(errno != EINTR) RETURN(91);
break; break;
} }
if(res < 1){ if(res < 1){
#ifdef WITHLOG
log("timeout");
#endif
RETURN (92); RETURN (92);
} }
} }

View File

@ -14,11 +14,6 @@ unsigned char * commands[] = {(unsigned char *)"UNKNOWN", (unsigned char *)"CONN
#define BUFSIZE 1024 #define BUFSIZE 1024
#if SOCKSTRACE > 0
char tracebuf[256];
#endif
static void printcommand(unsigned char * buf, int command, struct clientparam *param){ static void printcommand(unsigned char * buf, int command, struct clientparam *param){
sprintf((char *)buf, "%s ", commands[command]); sprintf((char *)buf, "%s ", commands[command]);
if(*param->hostname){ if(*param->hostname){
@ -223,10 +218,6 @@ void * sockschild(struct clientparam* param) {
if(param->extport) RETURN (12); if(param->extport) RETURN (12);
*SAPORT(&param->sinsl) = 0; *SAPORT(&param->sinsl) = 0;
if(param->srv->so._bind(param->sostate, param->remsock,(struct sockaddr *)&param->sinsl,SASIZE(&param->sinsl)))RETURN (12); if(param->srv->so._bind(param->sostate, param->remsock,(struct sockaddr *)&param->sinsl,SASIZE(&param->sinsl)))RETURN (12);
#if SOCKSTRACE > 0
fprintf(stderr, "%hu bound to communicate with server\n", *SAPORT(&param->sinsl));
fflush(stderr);
#endif
} }
sasize = sizeof(param->sinsl); sasize = sizeof(param->sinsl);
param->srv->so._getsockname(param->sostate, param->remsock, (struct sockaddr *)&param->sinsl, &sasize); param->srv->so._getsockname(param->sostate, param->remsock, (struct sockaddr *)&param->sinsl, &sasize);
@ -247,12 +238,6 @@ fflush(stderr);
if(bindwithrange(param, param->clisock, &sin, param->intport)) {RETURN (12);} if(bindwithrange(param, param->clisock, &sin, param->intport)) {RETURN (12);}
sasize = sizeof(sin); sasize = sizeof(sin);
param->srv->so._getsockname(param->sostate, param->clisock, (struct sockaddr *)&sin, &sasize); param->srv->so._getsockname(param->sostate, param->clisock, (struct sockaddr *)&sin, &sasize);
#if SOCKSTRACE > 0
fprintf(stderr, "%hu binded to communicate with client\n",
ntohs(*SAPORT(&sin))
);
fflush(stderr);
#endif
} }
param->res = 0; param->res = 0;
@ -288,16 +273,6 @@ CLEANRET:
*SAPORT(&sin) = port; *SAPORT(&sin) = port;
} }
} }
#if SOCKSTRACE > 0
myinet_ntop(*SAFAMILY(&sin), SAADDR(&sin), tracebuf, SASIZE(&sin));
fprintf(stderr, "Sending confirmation to client with code %d for %s with %s:%hu\n",
param->res,
commands[command],
tracebuf,
ntohs(*SAPORT(&sin))
);
fflush(stderr);
#endif
if(!param->res) repcode = 0; if(!param->res) repcode = 0;
else if(param->res <= 10) repcode = 2; else if(param->res <= 10) repcode = 2;
else if (param->res < 20) repcode = 5; else if (param->res < 20) repcode = 5;
@ -408,14 +383,6 @@ fflush(stderr);
#endif #endif
} }
#if SOCKSTRACE > 0
fprintf(stderr, "Sending incoming connection to client with code %d for %s with %hu\n",
param->res,
commands[command],
*SAPORT(&param->sinsr)
);
fflush(stderr);
#endif
if(ver == 5){ if(ver == 5){
buf[3] = (*SAFAMILY(&param->sinsr) == AF_INET)?1:4; buf[3] = (*SAFAMILY(&param->sinsr) == AF_INET)?1:4;
memcpy(buf+4, SAADDR(&param->sinsr), SAADDRLEN(&param->sinsr)); memcpy(buf+4, SAADDR(&param->sinsr), SAADDRLEN(&param->sinsr));