Compare commits

..

No commits in common. "381ef993a7249e384ae387ed7a9d78ddad8e50e4" and "aaa04116a8132b24a50c9250d70e5416606c7018" have entirely different histories.

5 changed files with 25 additions and 52 deletions

View File

@ -72,8 +72,6 @@
#define PW_ACCT_INPUT_PACKETS 47
#define PW_ACCT_OUTPUT_PACKETS 48
#define PW_ACCT_TERMINATE_CAUSE 49
#define PW_ACCT_INPUT_GIGAWORDS 52
#define PW_ACCT_OUTPUT_GIGAWORDS 53
#define PW_EVENT_TIMESTAMP 55
@ -377,7 +375,7 @@ int radsend(struct clientparam * param, int auth, int stop){
/* NAS-Port */
*ptr++ = PW_NAS_PORT_ID;
*ptr++ = 6;
(*(uint32_t *)ptr)=htonl(param->srv?(uint32_t)ntohs((*SAPORT(&param->srv->intsa))):0);
(*(uint32_t *)ptr)=htonl((uint32_t)ntohs((*SAPORT(&param->srv->intsa))));
ptr+=4;
total_length+=6;
@ -481,28 +479,12 @@ int radsend(struct clientparam * param, int auth, int stop){
(*(uint32_t *)ptr)=htonl((uint32_t)param->statssrv64);
ptr+=4;
total_length+=6;
/* Acct-Input-Gigawords */
if(param->statssrv64 > 0xFFFFFFFFULL){
*ptr++ = PW_ACCT_INPUT_GIGAWORDS;
*ptr++ = 6;
(*(uint32_t *)ptr)=htonl((uint32_t)(param->statssrv64 >> 32));
ptr+=4;
total_length+=6;
}
/* Acct-Output-Octets */
*ptr++ = PW_ACCT_OUTPUT_OCTETS;
*ptr++ = 6;
(*(uint32_t *)ptr)=htonl((uint32_t)param->statscli64);
ptr+=4;
total_length+=6;
/* Acct-Output-Gigawords */
if(param->statscli64 > 0xFFFFFFFFULL){
*ptr++ = PW_ACCT_OUTPUT_GIGAWORDS;
*ptr++ = 6;
(*(uint32_t *)ptr)=htonl((uint32_t)(param->statscli64 >> 32));
ptr+=4;
total_length+=6;
}
/* Acct-Input-Packets */
*ptr++ = PW_ACCT_INPUT_PACKETS;
*ptr++ = 6;

View File

@ -115,7 +115,10 @@ unsigned char * dologname (unsigned char *buf, unsigned char *name, const unsign
return buf;
}
if(strchr((char *)name, '%')){
dobuf2(NULL, buf, NULL, NULL, ts, (char *)name);
struct clientparam fakecli;
memset(&fakecli, 0, sizeof(fakecli));
dobuf2(&fakecli, buf, NULL, NULL, ts, (char *)name);
}
else switch(lt){
case NONE:

View File

@ -20,8 +20,16 @@ struct srvparam logsrv;
void dolog(struct clientparam * param, const unsigned char *s){
if(param && param->srv)param->srv->logfunc(param, s);
else logstdout(NULL, s);
static int init = 0;
if(param)param->srv->logfunc(param, s);
else {
if(!init){
srvinit(&logsrv, &logparam);
init = 1;
}
logstdout(&logparam, s);
}
}
@ -62,9 +70,6 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
long timezone;
unsigned delay;
if(!logparam.srv) srvinit(&logsrv, &logparam);
if(!param) param = &logparam;
#ifdef _WIN32
@ -312,21 +317,15 @@ int dobuf(struct clientparam * param, unsigned char * buf, const unsigned char *
int i;
char * format;
time_t t;
int has_srv;
time(&t);
has_srv = param && param->srv;
if(has_srv){
if(param->trafcountfunc)(*param->trafcountfunc)(param);
format = param->srv->logformat?(char *)param->srv->logformat : DEFLOGFORMAT;
}
else {
format = DEFLOGFORMAT;
}
if(!param) return 0;
if(param->trafcountfunc)(*param->trafcountfunc)(param);
format = param->srv->logformat?(char *)param->srv->logformat : DEFLOGFORMAT;
tm = (*format == 'G' || *format == 'g')?
gmtime(&t) : localtime(&t);
i = dobuf2(param, buf, s, doublec, tm, format + 1);
if(has_srv) clearstat(param);
clearstat(param);
return i;
}
@ -340,8 +339,8 @@ void logstdout(struct clientparam * param, const unsigned char *s) {
unsigned char tmpbuf[8192];
dobuf(param, tmpbuf, s, NULL);
log = (param && param->srv && param->srv->stdlog)?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
if(!param || !param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
log = param->srv->stdlog?param->srv->stdlog:conf.stdlog?conf.stdlog:stdout;
if(!param->nolog)if(fprintf(log, "%s\n", tmpbuf) < 0) {
perror("printf()");
};
if(log != conf.stdlog)fflush(log);

View File

@ -399,7 +399,7 @@ log("done read from client to pipe");
#ifdef WITHLOG
log("read from server to pipe\n");
#endif
res = splice(param->remsock, NULL, pipesrv[1], NULL, MIN(MAXSPLICE - inserverpipe, fromserver - inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
res = splice(param->remsock, NULL, pipesrv[1], NULL, MIN(MAXSPLICE - inclientpipe, fromserver - inserverpipe), SPLICE_F_NONBLOCK|SPLICE_F_MOVE);
#ifdef WITHLOG
log("server to pipe splice finished\n");
#if WITHLOG > 1

View File

@ -77,17 +77,11 @@ void * sockschild(struct clientparam* param) {
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);}
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(441);};
buf[i] = 0;
if(!param->username) {
param->username = (unsigned char *)strdup((char *)buf);
if(!param->username){RETURN(21);}
}
if(!param->username)param->username = (unsigned char *)strdup((char *)buf);
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(445);}
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(441);};
buf[i] = 0;
if(!param->password) {
param->password = (unsigned char *)strdup((char *)buf);
if(!param->password){RETURN(21);}
}
if(!param->password)param->password = (unsigned char *)strdup((char *)buf);
buf[0] = 1;
buf[1] = 0;
if(socksend(param, param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(481);}
@ -161,7 +155,6 @@ void * sockschild(struct clientparam* param) {
}
if(param->hostname)free(param->hostname);
param->hostname = (unsigned char *)strdup((char *)buf);
if(!param->hostname){RETURN(21);}
if (ver == 5) {
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
buf[0] = (unsigned char) res;
@ -173,17 +166,13 @@ void * sockschild(struct clientparam* param) {
else {
if(sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]) < 0) {RETURN(441);}
buf[127] = 0;
if(param->srv->needuser && *buf && !param->username) {
param->username = (unsigned char *)strdup((char *)buf);
if(!param->username){RETURN(21);}
}
if(param->srv->needuser && *buf && !param->username)param->username = (unsigned char *)strdup((char *)buf);
if(!memcmp(SAADDR(&param->req), "\0\0\0", 3)){
param->service = S_SOCKS45;
if(sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]) < 0) {RETURN(441);}
buf[127] = 0;
if(param->hostname)free(param->hostname);
param->hostname = (unsigned char *)strdup((char *)buf);
if(!param->hostname){RETURN(21);}
if(!getip46(param->srv->family, buf, (struct sockaddr *) &param->req)) RETURN(100);
param->sinsr = param->req;
}