|
|
@ -412,7 +412,12 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po |
|
|
|
{ |
|
|
|
jadd(json,"tokens",tokens); |
|
|
|
jaddstr(json,"urlmethod",urlmethod); |
|
|
|
if ( (data= jstr(json,"POST")) == 0 || (argjson= cJSON_Parse(data)) == 0 ) |
|
|
|
if ( (data= jstr(json,"POST")) != 0 ) |
|
|
|
{ |
|
|
|
free_json(argjson); |
|
|
|
argjson = cJSON_Parse(data); |
|
|
|
} |
|
|
|
if ( argjson != 0 ) |
|
|
|
{ |
|
|
|
userpass = jstr(argjson,"userpass"); |
|
|
|
//printf("userpass.(%s)\n",userpass);
|
|
|
@ -499,7 +504,6 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ( is_cJSON_Array(argjson) != 0 && (n= cJSON_GetArraySize(argjson)) > 0 ) |
|
|
|
{ |
|
|
|
cJSON *retitem,*retarray = cJSON_CreateArray(); |
|
|
@ -555,6 +559,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po |
|
|
|
#endif |
|
|
|
} |
|
|
|
free_json(argjson); |
|
|
|
} |
|
|
|
free_json(json); |
|
|
|
if ( tmpjson != 0 ) |
|
|
|
free(tmpjson); |
|
|
@ -599,7 +604,7 @@ void LP_rpc_processreq(void *_ptr) |
|
|
|
static uint32_t spawned,maxspawned; |
|
|
|
char filetype[128],content_type[128]; |
|
|
|
int32_t recvlen,flag,postflag=0,contentlen,remains,sock,numsent,jsonflag=0,hdrsize,len; |
|
|
|
char helpname[512],remoteaddr[64],*buf,*retstr,space[4096],*jsonbuf; struct rpcrequest_info *req = _ptr; |
|
|
|
char helpname[512],remoteaddr[64],*buf,*retstr,space[4096],space2[8192],*jsonbuf; struct rpcrequest_info *req = _ptr; |
|
|
|
uint32_t ipbits,i,size = IGUANA_MAXPACKETSIZE + 512; |
|
|
|
ipbits = req->ipbits;; |
|
|
|
expand_ipbits(remoteaddr,ipbits); |
|
|
@ -698,9 +703,14 @@ void LP_rpc_processreq(void *_ptr) |
|
|
|
char *response,hdrs[1024]; |
|
|
|
//printf("RETURN.(%s) jsonflag.%d postflag.%d\n",retstr,jsonflag,postflag);
|
|
|
|
if ( jsonflag != 0 || postflag != 0 ) |
|
|
|
{ |
|
|
|
if ( strlen(retstr)+1024+1+1 < sizeof(space2) ) |
|
|
|
response = space2; |
|
|
|
else |
|
|
|
{ |
|
|
|
response = malloc(strlen(retstr)+1024+1+1); |
|
|
|
printf("alloc response.%p\n",response); |
|
|
|
} |
|
|
|
sprintf(hdrs,"HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\nAccess-Control-Allow-Methods: GET, POST\r\nCache-Control : no-cache, no-store, must-revalidate\r\n%sContent-Length : %8d\r\n\r\n",content_type,(int32_t)strlen(retstr)); |
|
|
|
response[0] = '\0'; |
|
|
|
strcat(response,hdrs); |
|
|
@ -734,7 +744,7 @@ void LP_rpc_processreq(void *_ptr) |
|
|
|
printf("iguana sent.%d remains.%d of recvlen.%d (%s)\n",numsent,remains,recvlen,jsonbuf); |
|
|
|
} |
|
|
|
} |
|
|
|
if ( retstr != space ) |
|
|
|
if ( retstr != space && retstr != space2 ) |
|
|
|
{ |
|
|
|
printf("free retstr.%p\n",retstr); |
|
|
|
free(retstr); |
|
|
@ -752,7 +762,7 @@ void LP_rpc_processreq(void *_ptr) |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
printf("free req.%p\n",req); |
|
|
|
//printf("free req.%p\n",req);
|
|
|
|
free(req); |
|
|
|
} |
|
|
|
spawned--; |
|
|
@ -811,7 +821,7 @@ void stats_rpcloop(void *args) |
|
|
|
continue; |
|
|
|
} |
|
|
|
req = calloc(1,sizeof(*req)); |
|
|
|
printf("alloc req.%p\n",req); |
|
|
|
//printf("alloc req.%p\n",req);
|
|
|
|
req->sock = sock; |
|
|
|
req->ipbits = ipbits; |
|
|
|
req->port = port; |
|
|
|