|
@@ -28,8 +28,8 @@ int DBGLEVEL = 0;
|
|
|
int already_loaded = 0;
|
|
int already_loaded = 0;
|
|
|
typedef int (* handler)(int argc, unsigned char ** argv);
|
|
typedef int (* handler)(int argc, unsigned char ** argv);
|
|
|
|
|
|
|
|
-struct extparam * conf;
|
|
|
|
|
-struct commands * commandhandlers;
|
|
|
|
|
|
|
+struct extparam * sconfp;
|
|
|
|
|
+struct commands * scommandhandlers;
|
|
|
struct pluginlink * pl;
|
|
struct pluginlink * pl;
|
|
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
@@ -169,12 +169,9 @@ int h_trafcorrect(int argc, unsigned char ** argv) {
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static unsigned short myhtons(unsigned short port) {
|
|
|
|
|
- return (port << 8) | (port >> 8);
|
|
|
|
|
-}
|
|
|
|
|
|
|
+void(*origprelog)(struct clientparam * param) = NULL;
|
|
|
|
|
|
|
|
-LOGFUNC origlogfunc;
|
|
|
|
|
-void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|
|
|
|
|
|
+void mylogfunc(struct clientparam * param) {
|
|
|
PROXYSERVICE g_s = S_NOSERVICE;
|
|
PROXYSERVICE g_s = S_NOSERVICE;
|
|
|
int port;
|
|
int port;
|
|
|
int rule = 0;
|
|
int rule = 0;
|
|
@@ -189,7 +186,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|
|
port = starttrafcorrect->port;
|
|
port = starttrafcorrect->port;
|
|
|
g_s = starttrafcorrect->p_service;
|
|
g_s = starttrafcorrect->p_service;
|
|
|
if (starttrafcorrect->p_service == S_NOSERVICE) g_s = param->service;
|
|
if (starttrafcorrect->p_service == S_NOSERVICE) g_s = param->service;
|
|
|
- if (starttrafcorrect->port <= 0) port = myhtons(*SAPORT(¶m->sinsr));
|
|
|
|
|
|
|
+ if (starttrafcorrect->port <= 0) port = htons(*SAPORT(¶m->sinsr));
|
|
|
|
|
|
|
|
#ifndef NOPSTDINT
|
|
#ifndef NOPSTDINT
|
|
|
statssrv_before = param->statssrv64;
|
|
statssrv_before = param->statssrv64;
|
|
@@ -199,7 +196,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|
|
statscli_before = param->statscli;
|
|
statscli_before = param->statscli;
|
|
|
#endif
|
|
#endif
|
|
|
rule++;
|
|
rule++;
|
|
|
- if (((g_s == param->service) && (port == myhtons(*SAPORT(¶m->sinsr)))) ||
|
|
|
|
|
|
|
+ if (((g_s == param->service) && (port == htons(*SAPORT(¶m->sinsr)))) ||
|
|
|
( ((starttrafcorrect->type == UDP) &&
|
|
( ((starttrafcorrect->type == UDP) &&
|
|
|
((param->operation == UDPASSOC)||
|
|
((param->operation == UDPASSOC)||
|
|
|
(param->operation == DNSRESOLVE)||
|
|
(param->operation == DNSRESOLVE)||
|
|
@@ -240,9 +237,9 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|
|
}
|
|
}
|
|
|
if (DBGLEVEL == 1) {
|
|
if (DBGLEVEL == 1) {
|
|
|
#ifndef NOPSTDINT
|
|
#ifndef NOPSTDINT
|
|
|
- fprintf(stdout, "Port=%hd; Before: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; After: srv=%"PRINTF_INT64_MODIFIER"d, cli=%"PRINTF_INT64_MODIFIER"d; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
|
|
|
|
|
|
+ fprintf(stdout, "Port=%hd; Before: srv=%"PRIu64", cli=%"PRIu64"; After: srv=%"PRIu64", cli=%"PRIu64"; nreads=%ld; nwrites=%ld; Rule=%d\n",htons(*SAPORT(¶m->sinsr)), statssrv_before, statscli_before, param->statssrv64, param->statscli64,param->nreads,param->nwrites,rule);
|
|
|
#else
|
|
#else
|
|
|
- fprintf(stdout, "Port=%hd; Before: srv=%lu, cli=%lu; After: srv=%lu, cli=%lu; nreads=%ld; nwrites=%ld; Rule=%d\n",myhtons(param->sins.sin_port), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
|
|
|
|
|
|
+ fprintf(stdout, "Port=%hd; Before: srv=%lu, cli=%lu; After: srv=%lu, cli=%lu; nreads=%ld; nwrites=%ld; Rule=%d\n",htons(*SAPORT(¶m->sins)), statssrv_before, statscli_before, param->statssrv, param->statscli,param->nreads,param->nwrites,rule);
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
ok = 1;
|
|
ok = 1;
|
|
@@ -252,7 +249,7 @@ void mylogfunc(struct clientparam * param, const unsigned char * pz) {
|
|
|
if ((!ok) && (DBGLEVEL == 1)) {
|
|
if ((!ok) && (DBGLEVEL == 1)) {
|
|
|
fprintf(stdout, "No rules specifed: service=%d, port=%d, operation=%d", param->service, *SAPORT(¶m->sinsr),param->operation);
|
|
fprintf(stdout, "No rules specifed: service=%d, port=%d, operation=%d", param->service, *SAPORT(¶m->sinsr),param->operation);
|
|
|
}
|
|
}
|
|
|
- origlogfunc(param, pz);
|
|
|
|
|
|
|
+ if(origprelog)origprelog(param);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
@@ -277,8 +274,8 @@ BOOL WINAPI DllMain( HINSTANCE hModule,
|
|
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char** argv) {
|
|
PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char** argv) {
|
|
|
|
|
|
|
|
struct commands * starthandler;
|
|
struct commands * starthandler;
|
|
|
- conf = pluginlink->conf;
|
|
|
|
|
- commandhandlers = pluginlink->commandhandlers;
|
|
|
|
|
|
|
+ sconfp = pluginlink->conf;
|
|
|
|
|
+ scommandhandlers = pluginlink->commandhandlers;
|
|
|
pl = pluginlink;
|
|
pl = pluginlink;
|
|
|
|
|
|
|
|
if (argc>1) {
|
|
if (argc>1) {
|
|
@@ -295,7 +292,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char**
|
|
|
}
|
|
}
|
|
|
already_loaded = 1;
|
|
already_loaded = 1;
|
|
|
/* äîáàâëÿåì êîìàíäó "trafcorrect" */
|
|
/* äîáàâëÿåì êîìàíäó "trafcorrect" */
|
|
|
- starthandler = commandhandlers;
|
|
|
|
|
|
|
+ starthandler = scommandhandlers;
|
|
|
for ( ; starthandler->next; starthandler = starthandler->next);
|
|
for ( ; starthandler->next; starthandler = starthandler->next);
|
|
|
trafcorrect_handler.next = NULL;
|
|
trafcorrect_handler.next = NULL;
|
|
|
trafcorrect_handler.minargs = 1;
|
|
trafcorrect_handler.minargs = 1;
|
|
@@ -305,8 +302,8 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, char**
|
|
|
starthandler->next = &trafcorrect_handler;
|
|
starthandler->next = &trafcorrect_handler;
|
|
|
|
|
|
|
|
/* ïîäìåíÿåì conf->logfunc, ñ öåëüþ êîíòðîëèðîâàòü òðàôôèê */
|
|
/* ïîäìåíÿåì conf->logfunc, ñ öåëüþ êîíòðîëèðîâàòü òðàôôèê */
|
|
|
- origlogfunc = conf->logfunc;
|
|
|
|
|
- conf->logfunc = mylogfunc;
|
|
|
|
|
|
|
+ origprelog = sconfp->prelog;
|
|
|
|
|
+ sconfp->prelog = mylogfunc;
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|