|
|
@ -553,44 +553,24 @@ int32_t iguana_getheadersize(char *buf,int32_t recvlen) |
|
|
|
return(recvlen); |
|
|
|
} |
|
|
|
|
|
|
|
void stats_rpcloop(void *args) |
|
|
|
uint16_t RPC_port; |
|
|
|
|
|
|
|
void LP_rpc_processreq(void *_ptr) |
|
|
|
{ |
|
|
|
static char *jsonbuf; |
|
|
|
uint16_t port; char filetype[128],content_type[128]; |
|
|
|
int32_t recvlen,flag,bindsock,postflag=0,contentlen,sock,remains,numsent,jsonflag=0,hdrsize,len; |
|
|
|
socklen_t clilen; char helpname[512],remoteaddr[64],*buf,*retstr,*space; |
|
|
|
struct sockaddr_in cli_addr; uint32_t ipbits,i,size = 32*IGUANA_MAXPACKETSIZE + 512; |
|
|
|
if ( (port= *(uint16_t *)args) == 0 ) |
|
|
|
port = 7779; |
|
|
|
if ( jsonbuf == 0 ) |
|
|
|
jsonbuf = calloc(1,IGUANA_MAXPACKETSIZE); |
|
|
|
while ( (bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) |
|
|
|
{ |
|
|
|
//if ( coin->MAXPEERS == 1 )
|
|
|
|
// break;
|
|
|
|
//exit(-1);
|
|
|
|
sleep(3); |
|
|
|
} |
|
|
|
printf(">>>>>>>>>> DEX stats 127.0.0.1:%d bind sock.%d DEX stats API enabled <<<<<<<<<\n",port,bindsock); |
|
|
|
space = calloc(1,size); |
|
|
|
while ( bindsock >= 0 ) |
|
|
|
{ |
|
|
|
clilen = sizeof(cli_addr); |
|
|
|
sock = accept(bindsock,(struct sockaddr *)&cli_addr,&clilen); |
|
|
|
if ( sock < 0 ) |
|
|
|
{ |
|
|
|
//printf("iguana_rpcloop ERROR on accept usock.%d errno %d %s\n",sock,errno,strerror(errno));
|
|
|
|
continue; |
|
|
|
} |
|
|
|
memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); |
|
|
|
uint64_t arg64 = *(uint64_t *)_ptr; |
|
|
|
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,*jsonbuf; |
|
|
|
uint32_t ipbits,i,size = 32*IGUANA_MAXPACKETSIZE + 512; |
|
|
|
ipbits = (arg64 >> 32); |
|
|
|
expand_ipbits(remoteaddr,ipbits); |
|
|
|
//printf("remote RPC request from (%s) %x\n",remoteaddr,ipbits);
|
|
|
|
|
|
|
|
memset(jsonbuf,0,IGUANA_MAXPACKETSIZE); |
|
|
|
remains = (int32_t)(IGUANA_MAXPACKETSIZE - 1); |
|
|
|
buf = jsonbuf; |
|
|
|
sock = (arg64 & 0xffffffff); |
|
|
|
recvlen = flag = 0; |
|
|
|
retstr = 0; |
|
|
|
space = calloc(1,size); |
|
|
|
jsonbuf = calloc(1,size); |
|
|
|
remains = size-1; |
|
|
|
buf = jsonbuf; |
|
|
|
while ( remains > 0 ) |
|
|
|
{ |
|
|
|
//printf("flag.%d remains.%d recvlen.%d\n",flag,remains,recvlen);
|
|
|
@ -645,7 +625,8 @@ void stats_rpcloop(void *args) |
|
|
|
content_type[0] = 0; |
|
|
|
if ( recvlen > 0 ) |
|
|
|
{ |
|
|
|
retstr = stats_rpcparse(space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,port); |
|
|
|
jsonflag = postflag = 0; |
|
|
|
retstr = stats_rpcparse(space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,RPC_port); |
|
|
|
if ( filetype[0] != 0 ) |
|
|
|
{ |
|
|
|
static cJSON *mimejson; char *tmp,*typestr=0; long tmpsize; |
|
|
@ -705,7 +686,38 @@ void stats_rpcloop(void *args) |
|
|
|
if ( retstr != space) |
|
|
|
free(retstr); |
|
|
|
} |
|
|
|
free(space); |
|
|
|
free(jsonbuf); |
|
|
|
closesocket(sock); |
|
|
|
} |
|
|
|
|
|
|
|
void stats_rpcloop(void *args) |
|
|
|
{ |
|
|
|
uint16_t port; int32_t sock,bindsock; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits; uint64_t arg64; |
|
|
|
if ( (port= *(uint16_t *)args) == 0 ) |
|
|
|
port = 7779; |
|
|
|
RPC_port = port; |
|
|
|
while ( (bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) |
|
|
|
{ |
|
|
|
//if ( coin->MAXPEERS == 1 )
|
|
|
|
// break;
|
|
|
|
//exit(-1);
|
|
|
|
sleep(3); |
|
|
|
} |
|
|
|
printf(">>>>>>>>>> DEX stats 127.0.0.1:%d bind sock.%d DEX stats API enabled <<<<<<<<<\n",port,bindsock); |
|
|
|
while ( bindsock >= 0 ) |
|
|
|
{ |
|
|
|
clilen = sizeof(cli_addr); |
|
|
|
sock = accept(bindsock,(struct sockaddr *)&cli_addr,&clilen); |
|
|
|
if ( sock < 0 ) |
|
|
|
{ |
|
|
|
//printf("iguana_rpcloop ERROR on accept usock.%d errno %d %s\n",sock,errno,strerror(errno));
|
|
|
|
continue; |
|
|
|
} |
|
|
|
memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); |
|
|
|
//printf("remote RPC request from (%s) %x\n",remoteaddr,ipbits);
|
|
|
|
arg64 = ((uint64_t)ipbits << 32) | (sock & 0xffffffff); |
|
|
|
LP_rpc_processreq((void *)&arg64); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|