Browse Source

Test

etomic
jl777 8 years ago
parent
commit
36ca7470af
  1. 4
      iguana/exchanges/LP_commands.c
  2. 43
      iguana/exchanges/LP_nativeDEX.c

4
iguana/exchanges/LP_commands.c

@ -331,14 +331,14 @@ trust(pubkey, trust)\n\
bits256 zero; char *cipherstr; int32_t cipherlen; uint8_t cipher[LP_ENCRYPTED_MAXSIZE]; bits256 zero; char *cipherstr; int32_t cipherlen; uint8_t cipher[LP_ENCRYPTED_MAXSIZE];
if ( (reqjson= LP_dereference(argjson,"broadcast")) != 0 ) if ( (reqjson= LP_dereference(argjson,"broadcast")) != 0 )
{ {
if ( (cipherstr= jstr(reqjson,"cipherstr")) != 0 ) if ( (cipherstr= jstr(reqjson,"cipher")) != 0 )
{ {
cipherlen = (int32_t)strlen(cipherstr) >> 1; cipherlen = (int32_t)strlen(cipherstr) >> 1;
if ( cipherlen <= sizeof(cipher) ) if ( cipherlen <= sizeof(cipher) )
{ {
decode_hex(cipher,cipherlen,cipherstr); decode_hex(cipher,cipherlen,cipherstr);
LP_queuesend(calc_crc32(0,&cipher[2],cipherlen-2),LP_mypubsock,base,rel,cipher,cipherlen); LP_queuesend(calc_crc32(0,&cipher[2],cipherlen-2),LP_mypubsock,base,rel,cipher,cipherlen);
} else retstr = clonestr("{\"error\":\"cipherstr too big\"}"); } else retstr = clonestr("{\"error\":\"cipher too big\"}");
} }
else else
{ {

43
iguana/exchanges/LP_nativeDEX.c

@ -148,8 +148,7 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock,
crc32 = calc_crc32(0,&ptr[2],recvlen-2); crc32 = calc_crc32(0,&ptr[2],recvlen-2);
if ( (crc32 & 0xff) == ptr[0] && ((crc32>>8) & 0xff) == ptr[1] ) if ( (crc32 & 0xff) == ptr[0] && ((crc32>>8) & 0xff) == ptr[1] )
encrypted = 1; encrypted = 1;
//printf("%s encrypted.%d recv.%u (%s)\n",typestr,encrypted,crc32,(char *)ptr); printf("%s encrypted.%d recv.%u %02x %02x vs %02x %02x\n",typestr,encrypted,crc32,ptr[0],ptr[1],crc32&0xff,(crc32>>8)&0xff);
portable_mutex_lock(&LP_commandmutex);
i = LP_crc32find(&duplicate,-1,crc32); i = LP_crc32find(&duplicate,-1,crc32);
if ( duplicate == 0 ) if ( duplicate == 0 )
{ {
@ -184,48 +183,14 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock,
if ( jsonstr != 0 && (argjson= cJSON_Parse(jsonstr)) != 0 ) if ( jsonstr != 0 && (argjson= cJSON_Parse(jsonstr)) != 0 )
{ {
len = (int32_t)strlen(jsonstr) + 1; len = (int32_t)strlen(jsonstr) + 1;
/*if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"forwardhex") == 0 ) portable_mutex_lock(&LP_commandmutex);
{ if ( (retstr= LP_command_process(ctx,myipaddr,pubsock,argjson,&((uint8_t *)ptr)[len],recvlen - len)) != 0 )
//printf("got forwardhex\n");
if ( (retstr= LP_forwardhex(ctx,pubsock,jbits256(argjson,"pubkey"),jstr(argjson,"hex"))) != 0 )
{
}
}
else if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"publish") == 0 )
{
printf("got publish\n");
if ( jobj(argjson,"method2") != 0 )
jdelete(argjson,"method2");
jaddstr(argjson,"method2","broadcast");
if ( pubsock >= 0 && (reqjson= LP_dereference(argjson,"publish")) != 0 )
{
msg = jprint(reqjson,1);
/LP_send(pubsock,msg,(int32_t)strlen(msg)+1,1);
}
}
else*/ if ( (retstr= LP_command_process(ctx,myipaddr,pubsock,argjson,&((uint8_t *)ptr)[len],recvlen - len)) != 0 )
{
}
/*if ( LP_COMMAND_RECVSOCK == NN_REP )
{
if ( retstr != 0 )
{
if ( strcmp("PULL",typestr) == 0 )
{
printf("%d got REQ.(%s) -> (%s)\n",recvsock,jprint(argjson,0),retstr);
/LP_send(recvsock,retstr,(int32_t)strlen(retstr)+1,0);
}
}
else if ( strcmp("PULL",typestr) == 0 )
{ {
printf("%d got REQ.(%s) -> null\n",recvsock,jprint(argjson,0));
/LP_send(recvsock,"{\"result\":null}",(int32_t)strlen("{\"result\":null}")+1,0);
} }
}*/ portable_mutex_unlock(&LP_commandmutex);
free_json(argjson); free_json(argjson);
} else printf("error parsing(%s)\n",jsonstr); } else printf("error parsing(%s)\n",jsonstr);
} //else printf("DUPLICATE.(%s)\n",(char *)ptr); } //else printf("DUPLICATE.(%s)\n",(char *)ptr);
portable_mutex_unlock(&LP_commandmutex);
if ( jsonstr != 0 && (void *)jsonstr != (void *)ptr && (void *)jsonstr != (void *)decoded ) if ( jsonstr != 0 && (void *)jsonstr != (void *)ptr && (void *)jsonstr != (void *)decoded )
free(jsonstr); free(jsonstr);
if ( ptr != 0 ) if ( ptr != 0 )

Loading…
Cancel
Save