mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-28 15:10:12 +08:00
Fix Windows compilation
This commit is contained in:
parent
3957210609
commit
68ef9dcc59
@ -29,7 +29,7 @@ AFTERCLEAN = (find . -type f -name "*.o" -delete && find src/ -type f -name "Mak
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.FreeBSD
|
MAKEFILE = Makefile.FreeBSD
|
||||||
PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin
|
PLUGINS ?= StringsPlugin TrafficPlugin TransparentPlugin FilePlugin
|
||||||
OPENSSL_CHECK = $(shell echo "\#include <openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testssl.o - 2>/dev/null && $(CC) $(LDFLAGS) -otestssl testssl.o -lcrypto -lssl 2>/dev/null && rm testssl testssl.o && echo true||echo false)
|
OPENSSL_CHECK = $(shell echo "\#include <openssl/ssl.h>\\n int main(){return 0;}" | tr -d \\\\ | $(CC) -x c $(CFLAGS) -o testssl.o - 2>/dev/null && $(CC) $(LDFLAGS) -otestssl testssl.o -lcrypto -lssl 2>/dev/null && rm testssl testssl.o && echo true||echo false)
|
||||||
ifeq ($(OPENSSL_CHECK), true)
|
ifeq ($(OPENSSL_CHECK), true)
|
||||||
LIBS += -l crypto -l ssl
|
LIBS += -l crypto -l ssl
|
||||||
|
|||||||
@ -26,7 +26,7 @@ REMOVECOMMAND = rm -f
|
|||||||
TYPECOMMAND = cat
|
TYPECOMMAND = cat
|
||||||
COMPATLIBS =
|
COMPATLIBS =
|
||||||
MAKEFILE = Makefile.win
|
MAKEFILE = Makefile.win
|
||||||
PLUGINS := utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin
|
PLUGINS := utf8tocp1251 WindowsAuthentication TrafficPlugin StringsPlugin FilePlugin
|
||||||
VERFILE := 3proxyres.o $(VERFILE)
|
VERFILE := 3proxyres.o $(VERFILE)
|
||||||
VERSION := $(VERSION)
|
VERSION := $(VERSION)
|
||||||
VERSIONDEP := 3proxyres.o $(VERSIONDEP)
|
VERSIONDEP := 3proxyres.o $(VERSIONDEP)
|
||||||
|
|||||||
21
src/conf.c
21
src/conf.c
@ -655,14 +655,14 @@ static int h_fakeresolve(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int h_nscache(int argc, unsigned char **argv){
|
static int h_nscache(int argc, unsigned char **argv){
|
||||||
int res;
|
unsigned res;
|
||||||
|
|
||||||
res = atoi((char *)argv[1]);
|
res = (unsigned)atoi((char *)argv[1]);
|
||||||
if(res < 256) {
|
if(res < 256) {
|
||||||
fprintf(stderr, "Invalid NS cache size: %d\n", res);
|
fprintf(stderr, "Invalid NS cache size: %d\n", res);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(inithashtable(&dns_table, (unsigned)res)){
|
if(inithashtable(&dns_table, (res << 2), (res << 2), res)){
|
||||||
fprintf(stderr, "Failed to initialize NS cache\n");
|
fprintf(stderr, "Failed to initialize NS cache\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -678,14 +678,14 @@ static int h_parentretries(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int h_nscache6(int argc, unsigned char **argv){
|
static int h_nscache6(int argc, unsigned char **argv){
|
||||||
int res;
|
unsigned res;
|
||||||
|
|
||||||
res = atoi((char *)argv[1]);
|
res = (unsigned)atoi((char *)argv[1]);
|
||||||
if(res < 256) {
|
if(res < 256) {
|
||||||
fprintf(stderr, "Invalid NS cache size: %d\n", res);
|
fprintf(stderr, "Invalid NS cache size: %d\n", res);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(inithashtable(&dns6_table, (unsigned)res)){
|
if(inithashtable(&dns6_table, (res<<2), (res<<2), res)){
|
||||||
fprintf(stderr, "Failed to initialize NS cache\n");
|
fprintf(stderr, "Failed to initialize NS cache\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
@ -1429,8 +1429,9 @@ static int h_radius(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
static int h_authcache(int argc, unsigned char **argv){
|
static int h_authcache(int argc, unsigned char **argv){
|
||||||
|
int authcachesize = 0;
|
||||||
|
|
||||||
conf.authcachetype = 0;
|
conf.authcachetype = 0;
|
||||||
int authcachesize;
|
|
||||||
if(strstr((char *) *(argv + 1), "ip")) conf.authcachetype |= 1;
|
if(strstr((char *) *(argv + 1), "ip")) conf.authcachetype |= 1;
|
||||||
if(strstr((char *) *(argv + 1), "user")) conf.authcachetype |= 2;
|
if(strstr((char *) *(argv + 1), "user")) conf.authcachetype |= 2;
|
||||||
if(strstr((char *) *(argv + 1), "pass")) conf.authcachetype |= 4;
|
if(strstr((char *) *(argv + 1), "pass")) conf.authcachetype |= 4;
|
||||||
@ -1438,14 +1439,14 @@ static int h_authcache(int argc, unsigned char **argv){
|
|||||||
if(strstr((char *) *(argv + 1), "acl")) conf.authcachetype |= 16;
|
if(strstr((char *) *(argv + 1), "acl")) conf.authcachetype |= 16;
|
||||||
if(strstr((char *) *(argv + 1), "ext")) conf.authcachetype |= 32;
|
if(strstr((char *) *(argv + 1), "ext")) conf.authcachetype |= 32;
|
||||||
if(argc > 2) conf.authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
if(argc > 2) conf.authcachetime = (unsigned) atoi((char *) *(argv + 2));
|
||||||
if(argc > 3) authcachesize = (unsigned) atoi((char *) *(argv + 2));
|
if(argc > 3) authcachesize = (unsigned) atoi((char *) *(argv + 3));
|
||||||
if(!conf.authcachetype) conf.authcachetype = 6;
|
if(!conf.authcachetype) conf.authcachetype = 6;
|
||||||
if(!conf.authcachetime) conf.authcachetime = 600;
|
if(!conf.authcachetime) conf.authcachetime = 600;
|
||||||
if(inithashtable(&auth_table, authcachesize? authcachesize : 4096)){
|
if(!authcachesize) authcachesize = 65536*4;
|
||||||
|
if(inithashtable(&auth_table, 1024, 1024, authcachesize)){
|
||||||
fprintf(stderr, "Failed to initialize auth cache\n");
|
fprintf(stderr, "Failed to initialize auth cache\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if(!authcachesize)auth_table.growlimit = 65536*4;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
32
src/hash.c
32
src/hash.c
@ -35,9 +35,8 @@ void destroyhashtable(struct hashtable *ht){
|
|||||||
#define hvalue(ht,I) ((struct hashentry *)(ht->hashvalues + (I-1)*(sizeof(struct hashentry) + ht->recsize - 4)))
|
#define hvalue(ht,I) ((struct hashentry *)(ht->hashvalues + (I-1)*(sizeof(struct hashentry) + ht->recsize - 4)))
|
||||||
#define hhash(ht,I) ((ht->hashhashvalues + (I-1)*(ht->hash_size)))
|
#define hhash(ht,I) ((ht->hashhashvalues + (I-1)*(ht->hash_size)))
|
||||||
|
|
||||||
int inithashtable(struct hashtable *ht, unsigned npoolsize){
|
int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, unsigned growlimit){
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned tablesize, poolsize;
|
|
||||||
clock_t c;
|
clock_t c;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -52,8 +51,7 @@ int inithashtable(struct hashtable *ht, unsigned npoolsize){
|
|||||||
#endif
|
#endif
|
||||||
c = clock();
|
c = clock();
|
||||||
|
|
||||||
poolsize = tablesize = (npoolsize >> 2);
|
if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1;
|
||||||
if(tablesize < 2) return 1;
|
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
if(ht->ihashtable){
|
if(ht->ihashtable){
|
||||||
myfree(ht->ihashtable);
|
myfree(ht->ihashtable);
|
||||||
@ -82,7 +80,7 @@ int inithashtable(struct hashtable *ht, unsigned npoolsize){
|
|||||||
}
|
}
|
||||||
ht->poolsize = poolsize;
|
ht->poolsize = poolsize;
|
||||||
ht->tablesize = tablesize;
|
ht->tablesize = tablesize;
|
||||||
ht->growlimit = npoolsize;
|
ht->growlimit = growlimit;
|
||||||
memset(ht->ihashtable, 0, ht->tablesize * sizeof(uint32_t));
|
memset(ht->ihashtable, 0, ht->tablesize * sizeof(uint32_t));
|
||||||
memset(ht->hashvalues, 0, ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4));
|
memset(ht->hashvalues, 0, ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4));
|
||||||
|
|
||||||
@ -145,7 +143,7 @@ void hashadd(struct hashtable *ht, const void* name, const void* value, time_t e
|
|||||||
uint32_t hen, he;
|
uint32_t hen, he;
|
||||||
uint32_t *hep;
|
uint32_t *hep;
|
||||||
int overwrite = 0;
|
int overwrite = 0;
|
||||||
uint8_t hash[ht->hash_size];
|
uint8_t hash[MAX_HASH_SIZE];
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
uint32_t last = 0;
|
uint32_t last = 0;
|
||||||
|
|
||||||
@ -153,7 +151,7 @@ void hashadd(struct hashtable *ht, const void* name, const void* value, time_t e
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ht->index2hash(name, hash);
|
ht->index2hash(ht, name, hash);
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
index = hashindex(ht, hash);
|
index = hashindex(ht, hash);
|
||||||
|
|
||||||
@ -193,7 +191,7 @@ void hashadd(struct hashtable *ht, const void* name, const void* value, time_t e
|
|||||||
}
|
}
|
||||||
|
|
||||||
int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *ttl){
|
int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *ttl){
|
||||||
uint8_t hash[ht->hash_size];
|
uint8_t hash[MAX_HASH_SIZE];
|
||||||
uint32_t *hep;
|
uint32_t *hep;
|
||||||
uint32_t he;
|
uint32_t he;
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
@ -201,7 +199,7 @@ int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *tt
|
|||||||
if(!ht || !ht->ihashtable || !name) {
|
if(!ht || !ht->ihashtable || !name) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ht->index2hash(name, hash);
|
ht->index2hash(ht,name, hash);
|
||||||
pthread_mutex_lock(&hash_mutex);
|
pthread_mutex_lock(&hash_mutex);
|
||||||
index = hashindex(ht, hash);
|
index = hashindex(ht, hash);
|
||||||
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
|
||||||
@ -223,24 +221,24 @@ int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *tt
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void char_index2hash(const void *index, uint8_t *hash){
|
void char_index2hash(const struct hashtable *ht, const void *index, uint8_t *hash){
|
||||||
const char* name = index;
|
const char* name = index;
|
||||||
|
|
||||||
blake2b(hash, HASH_SIZE, index, strlen((const char*)index), NULL, 0);
|
blake2b(hash, ht->hash_size, index, strlen((const char*)index), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void param2hash(const void *index, uint8_t *hash){
|
void param2hash(const struct hashtable *ht, const void *index, uint8_t *hash){
|
||||||
blake2b_state S;
|
blake2b_state S;
|
||||||
const struct clientparam *param = (struct clientparam *)index;
|
const struct clientparam *param = (struct clientparam *)index;
|
||||||
|
|
||||||
blake2b_init(&S, HASH_SIZE);
|
blake2b_init(&S, ht->hash_size);
|
||||||
if((conf.authcachetype & 2) && param->username)blake2b_update(&S, param->username, strlen((const char *)param->username) + 1);
|
if((conf.authcachetype & 2) && param->username)blake2b_update(&S, param->username, strlen((const char *)param->username) + 1);
|
||||||
if((conf.authcachetype & 4) && param->password)blake2b_update(&S, param->password, strlen((const char *)param->password) + 1);
|
if((conf.authcachetype & 4) && param->password)blake2b_update(&S, param->password, strlen((const char *)param->password) + 1);
|
||||||
if((conf.authcachetype & 1) && !(conf.authcachetype & 8))blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
if((conf.authcachetype & 1) && !(conf.authcachetype & 8))blake2b_update(&S, SAADDR(¶m->sincr), SAADDRLEN(¶m->sincr));
|
||||||
if((conf.authcachetype & 16))blake2b_update(&S, ¶m->srv->acl, sizeof(param->srv->acl));
|
if((conf.authcachetype & 16))blake2b_update(&S, ¶m->srv->acl, sizeof(param->srv->acl));
|
||||||
blake2b_final(&S, hash, HASH_SIZE);
|
blake2b_final(&S, hash, ht->hash_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hashtable dns_table = {0, 0, 0, 4, HASH_SIZE, char_index2hash};
|
struct hashtable dns_table = {char_index2hash, 4, 16};
|
||||||
struct hashtable dns6_table = {0, 0, 0, 16, HASH_SIZE, char_index2hash};
|
struct hashtable dns6_table = {char_index2hash, 16, 16};
|
||||||
struct hashtable auth_table = {0, 0, 0, sizeof(struct authcache), HASH_SIZE, param2hash};
|
struct hashtable auth_table = {param2hash, sizeof(struct authcache), 16};
|
||||||
|
|||||||
@ -287,7 +287,7 @@ void processcallbacks(struct fp_stream *fps, int what, char *msg, int size){
|
|||||||
case GOT_SMTP_REQ:
|
case GOT_SMTP_REQ:
|
||||||
case GOT_SMTP_DATA:
|
case GOT_SMTP_DATA:
|
||||||
fps->state = FLUSH_DATA;
|
fps->state = FLUSH_DATA;
|
||||||
pl->socksend(fps->fpd.cp->sostate,fps->fpd.cp->clisock, fp_stringtable[1], (int)strlen(fp_stringtable[1]), pl->conf->timeouts[STRING_S]);
|
pl->socksend(fps->fpd.cp->sostate,fps->fpd.cp->clisock, (unsigned char *)fp_stringtable[1], (int)strlen((char *)fp_stringtable[1]), pl->conf->timeouts[STRING_S]);
|
||||||
fps->state = state;
|
fps->state = state;
|
||||||
break;
|
break;
|
||||||
case GOT_HTTP_REQUEST:
|
case GOT_HTTP_REQUEST:
|
||||||
@ -299,7 +299,7 @@ void processcallbacks(struct fp_stream *fps, int what, char *msg, int size){
|
|||||||
case GOT_HTTP_SRVDATA:
|
case GOT_HTTP_SRVDATA:
|
||||||
if(!fps->serversent){
|
if(!fps->serversent){
|
||||||
fps->state = FLUSH_DATA;
|
fps->state = FLUSH_DATA;
|
||||||
pl->socksend(fps->fpd.cp->sostate, fps->fpd.cp->clisock, fp_stringtable[0], (int)strlen(fp_stringtable[0]), pl->conf->timeouts[STRING_S]);
|
pl->socksend(fps->fpd.cp->sostate, fps->fpd.cp->clisock, (unsigned char *)fp_stringtable[0], (int)strlen((char *)fp_stringtable[0]), pl->conf->timeouts[STRING_S]);
|
||||||
fps->state = state;
|
fps->state = state;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -307,7 +307,7 @@ void processcallbacks(struct fp_stream *fps, int what, char *msg, int size){
|
|||||||
case GOT_FTP_REQ:
|
case GOT_FTP_REQ:
|
||||||
case GOT_FTP_SRVDATA:
|
case GOT_FTP_SRVDATA:
|
||||||
fps->state = FLUSH_DATA;
|
fps->state = FLUSH_DATA;
|
||||||
pl->socksend(fps->fpd.cp->sostate, fps->fpd.cp->ctrlsock, fp_stringtable[1], (int)strlen(fp_stringtable[1]), pl->conf->timeouts[STRING_S]);
|
pl->socksend(fps->fpd.cp->sostate, fps->fpd.cp->ctrlsock, (unsigned char *)fp_stringtable[1], (int)strlen((char *)fp_stringtable[1]), pl->conf->timeouts[STRING_S]);
|
||||||
fps->state = state;
|
fps->state = state;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -359,7 +359,7 @@ static int copyfdtosock(struct fp_stream * fps, DIRECTION which, long len){
|
|||||||
if(fps->serversent >= fps->srvhdrwritten){
|
if(fps->serversent >= fps->srvhdrwritten){
|
||||||
sprintf(fps->buf, "%lx\r\n", len);
|
sprintf(fps->buf, "%lx\r\n", len);
|
||||||
sendchunk = (int)strlen(fps->buf);
|
sendchunk = (int)strlen(fps->buf);
|
||||||
if(pl->socksend(fps->fpd.cp->sostate, fps->fpd.cp->clisock, fps->buf, sendchunk, pl->conf->timeouts[STRING_S]) != sendchunk){
|
if(pl->socksend(fps->fpd.cp->sostate, fps->fpd.cp->clisock, (unsigned char *)fps->buf, sendchunk, pl->conf->timeouts[STRING_S]) != sendchunk){
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,13 +398,13 @@ static int copyfdtosock(struct fp_stream * fps, DIRECTION which, long len){
|
|||||||
#endif
|
#endif
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if(pl->socksend(fps->fpd.cp->sostate, sock, fps->buf, res, pl->conf->timeouts[STRING_S]) != res) {
|
if(pl->socksend(fps->fpd.cp->sostate, sock, (unsigned char *)fps->buf, res, pl->conf->timeouts[STRING_S]) != res) {
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
len -= res;
|
len -= res;
|
||||||
}
|
}
|
||||||
if(sendchunk){
|
if(sendchunk){
|
||||||
if(pl->socksend(fps->fpd.cp->sostate, sock, "\r\n", 2, pl->conf->timeouts[STRING_S]) != 2)
|
if(pl->socksend(fps->fpd.cp->sostate, sock, (unsigned char *)"\r\n", 2, pl->conf->timeouts[STRING_S]) != 2)
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
fps->state = state;
|
fps->state = state;
|
||||||
@ -458,7 +458,11 @@ static int WINAPI fp_poll(void *state, struct pollfd *fds, unsigned int nfds, in
|
|||||||
return sso._poll(sso.state, fds, nfds, timeout);
|
return sso._poll(sso.state, fds, nfds, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static fp_ssize_t WINAPI fp_send(void *state, SOCKET s, const char *msg, fp_size_t len, int flags){
|
#ifdef _WIN32
|
||||||
|
static int WINAPI fp_send(void *state, SOCKET s, const char *msg, int len, int flags){
|
||||||
|
#else
|
||||||
|
static fp_ssize_t fp_send(void *state, SOCKET s, const void *msg, size_t len, int flags){
|
||||||
|
#endif
|
||||||
struct fp_stream *fps = NULL;
|
struct fp_stream *fps = NULL;
|
||||||
int res;
|
int res;
|
||||||
res = searchsocket(s, &fps);
|
res = searchsocket(s, &fps);
|
||||||
@ -499,7 +503,7 @@ static fp_ssize_t WINAPI fp_send(void *state, SOCKET s, const char *msg, fp_size
|
|||||||
int hasnonzero = 0, i;
|
int hasnonzero = 0, i;
|
||||||
|
|
||||||
for(i=0; i < len; i++){
|
for(i=0; i < len; i++){
|
||||||
char c = msg[i];
|
char c = ((char *)msg)[i];
|
||||||
|
|
||||||
if(c == '\r' || c == '\n') continue;
|
if(c == '\r' || c == '\n') continue;
|
||||||
if((c<'0'|| c>'9') && (c<'A' || c>'F') && (c<'a' || c>'f')) {
|
if((c<'0'|| c>'9') && (c<'A' || c>'F') && (c<'a' || c>'f')) {
|
||||||
@ -542,7 +546,12 @@ static fp_ssize_t WINAPI fp_send(void *state, SOCKET s, const char *msg, fp_size
|
|||||||
}
|
}
|
||||||
return sso._send(sso.state, s, msg, len, flags);
|
return sso._send(sso.state, s, msg, len, flags);
|
||||||
}
|
}
|
||||||
static fp_ssize_t WINAPI fp_sendto(void *state, SOCKET s, const void *msg, int len, int flags, const struct sockaddr *to, fp_size_t tolen){
|
#ifdef _WIN32
|
||||||
|
static int WINAPI fp_sendto(void *state, SOCKET s, const char *msg, int len, int flags, const struct sockaddr *to, int tolen
|
||||||
|
#else
|
||||||
|
static fp_ssize_t fp_sendto(void *state, SOCKET s, const void *msg, fp_size_t len, int flags, const struct sockaddr *to, SASIZETYPE tolen
|
||||||
|
#endif
|
||||||
|
){
|
||||||
struct fp_stream *fps = NULL;
|
struct fp_stream *fps = NULL;
|
||||||
int res;
|
int res;
|
||||||
res = searchsocket(s, &fps);
|
res = searchsocket(s, &fps);
|
||||||
@ -660,10 +669,20 @@ static fp_ssize_t WINAPI fp_sendto(void *state, SOCKET s, const void *msg, int l
|
|||||||
}
|
}
|
||||||
return sso._sendto(sso.state, s, msg, len, flags, to, tolen);
|
return sso._sendto(sso.state, s, msg, len, flags, to, tolen);
|
||||||
}
|
}
|
||||||
static fp_ssize_t WINAPI fp_recv(void *state, SOCKET s, void *buf, fp_size_t len, int flags){
|
#ifdef _WIN32
|
||||||
|
static int WINAPI fp_recv(void *state, SOCKET s, char *buf, int len, int flags
|
||||||
|
#else
|
||||||
|
static fp_ssize_t fp_recv(void *state, SOCKET s, void *buf, fp_size_t len, int flags
|
||||||
|
#endif
|
||||||
|
){
|
||||||
return sso._recv(sso.state, s, buf, len, flags);
|
return sso._recv(sso.state, s, buf, len, flags);
|
||||||
}
|
}
|
||||||
static fp_ssize_t WINAPI fp_recvfrom(void *state, SOCKET s, void * buf, fp_size_t len, int flags, struct sockaddr * from, fp_size_t * fromlen){
|
#ifdef _WIN32
|
||||||
|
static int WINAPI fp_recvfrom(void *state, SOCKET s, char *buf, int len, int flags, struct sockaddr * from, int * fromlen
|
||||||
|
#else
|
||||||
|
static fp_ssize_t fp_recvfrom(void *state, SOCKET s, void *buf, fp_size_t len, int flags, struct sockaddr * from, SASIZETYPE * fromlen
|
||||||
|
#endif
|
||||||
|
){
|
||||||
return sso._recvfrom(sso.state, s, buf, len, flags, from, fromlen);
|
return sso._recvfrom(sso.state, s, buf, len, flags, from, fromlen);
|
||||||
}
|
}
|
||||||
static int WINAPI fp_shutdown(void *state, SOCKET s, int how){
|
static int WINAPI fp_shutdown(void *state, SOCKET s, int how){
|
||||||
@ -766,7 +785,7 @@ static FILTER_ACTION fp_request(void *fc, struct clientparam * param, unsigned c
|
|||||||
closefiles(FC);
|
closefiles(FC);
|
||||||
FC->state = 0;
|
FC->state = 0;
|
||||||
}
|
}
|
||||||
processcallbacks(FC, FP_CALLONREQUEST, *buf_p + offset, *length_p - offset);
|
processcallbacks(FC, FP_CALLONREQUEST, (char *)*buf_p + offset, *length_p - offset);
|
||||||
if(FC->what &FP_REJECT) return REJECT;
|
if(FC->what &FP_REJECT) return REJECT;
|
||||||
FC->state = GOT_HTTP_REQUEST;
|
FC->state = GOT_HTTP_REQUEST;
|
||||||
genpaths(FC);
|
genpaths(FC);
|
||||||
@ -778,13 +797,13 @@ static FILTER_ACTION fp_request(void *fc, struct clientparam * param, unsigned c
|
|||||||
|
|
||||||
static FILTER_ACTION fp_hcli(void *fc, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int offset, int * length_p){
|
static FILTER_ACTION fp_hcli(void *fc, struct clientparam * param, unsigned char ** buf_p, int * bufsize_p, int offset, int * length_p){
|
||||||
if(fc && param->service == S_SMTPP) {
|
if(fc && param->service == S_SMTPP) {
|
||||||
processcallbacks(FC, FP_CALLONREQUEST, *buf_p + offset, *length_p - offset);
|
processcallbacks(FC, FP_CALLONREQUEST, (char *)*buf_p + offset, *length_p - offset);
|
||||||
if(FC->what & FP_REJECT) return REJECT;
|
if(FC->what & FP_REJECT) return REJECT;
|
||||||
if(!FC->state)genpaths(FC);
|
if(!FC->state)genpaths(FC);
|
||||||
FC->state = GOT_SMTP_REQ;
|
FC->state = GOT_SMTP_REQ;
|
||||||
}
|
}
|
||||||
if(fc && param->service == S_FTPPR) {
|
if(fc && param->service == S_FTPPR) {
|
||||||
processcallbacks(FC, FP_CALLONREQUEST, *buf_p + offset, *length_p - offset);
|
processcallbacks(FC, FP_CALLONREQUEST, (char *)*buf_p + offset, *length_p - offset);
|
||||||
if(FC->what & FP_REJECT) return REJECT;
|
if(FC->what & FP_REJECT) return REJECT;
|
||||||
genpaths(FC);
|
genpaths(FC);
|
||||||
FC->state = GOT_FTP_REQ;
|
FC->state = GOT_FTP_REQ;
|
||||||
@ -852,7 +871,7 @@ static int h_cachedir(int argc, unsigned char **argv){
|
|||||||
char * dirp;
|
char * dirp;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
dirp = (argc > 1)? argv[1] : getenv("TEMP");
|
dirp = (argc > 1)? (char *)argv[1] : getenv("TEMP");
|
||||||
len = strlen(dirp);
|
len = strlen(dirp);
|
||||||
if(!dirp || !len || len > 200 || strchr(dirp, '%')) {
|
if(!dirp || !len || len > 200 || strchr(dirp, '%')) {
|
||||||
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
|
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
|
||||||
@ -869,7 +888,7 @@ static int h_cachedir(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int h_preview(int argc, unsigned char **argv){
|
static int h_preview(int argc, unsigned char **argv){
|
||||||
preview = atoi(argv[1]);
|
preview = atoi((char *)argv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -244,7 +244,7 @@ void mschap(const unsigned char *win_password,
|
|||||||
const unsigned char *challenge, unsigned char *response);
|
const unsigned char *challenge, unsigned char *response);
|
||||||
|
|
||||||
void destroyhashtable(struct hashtable *ht);
|
void destroyhashtable(struct hashtable *ht);
|
||||||
int inithashtable(struct hashtable *ht, unsigned nhashsize);
|
int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, unsigned growlimit);
|
||||||
void hashadd(struct hashtable *ht, const void* name, const void* value, time_t expires);
|
void hashadd(struct hashtable *ht, const void* name, const void* value, time_t expires);
|
||||||
int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *ttl);
|
int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *ttl);
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ int mutex_unlock(int *val);
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <Ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#define pthread_mutex_t CRITICAL_SECTION
|
#define pthread_mutex_t CRITICAL_SECTION
|
||||||
#define pthread_mutex_init(x, y) InitializeCriticalSection(x)
|
#define pthread_mutex_init(x, y) InitializeCriticalSection(x)
|
||||||
#define pthread_mutex_lock(x) EnterCriticalSection(x)
|
#define pthread_mutex_lock(x) EnterCriticalSection(x)
|
||||||
@ -754,15 +754,15 @@ struct child {
|
|||||||
unsigned char **argv;
|
unsigned char **argv;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HASH_SIZE (16)
|
#define MAX_HASH_SIZE (16)
|
||||||
|
|
||||||
struct hashtable {
|
struct hashtable {
|
||||||
|
void (*index2hash)(const struct hashtable *ht, const void *index, uint8_t *hash);
|
||||||
|
unsigned recsize;
|
||||||
|
unsigned hash_size;
|
||||||
unsigned poolsize;
|
unsigned poolsize;
|
||||||
unsigned tablesize;
|
unsigned tablesize;
|
||||||
unsigned growlimit;
|
unsigned growlimit;
|
||||||
unsigned recsize;
|
|
||||||
unsigned hash_size;
|
|
||||||
void (*index2hash)(const void *index, unsigned char *hash);
|
|
||||||
uint32_t * ihashtable;
|
uint32_t * ihashtable;
|
||||||
uint8_t * hashvalues;
|
uint8_t * hashvalues;
|
||||||
uint8_t * hashhashvalues;
|
uint8_t * hashhashvalues;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user