From a15d8f107223b3a5098b86ec8ec83c686f941226 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Dec 2016 12:57:53 +0200 Subject: [PATCH] test --- iguana/iguana_rpc.c | 2 ++ iguana/main.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index a7ce5e14d..ca47d66ae 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -32,6 +32,8 @@ char *sglue(GLUEARGS,char *agent,char *method) jaddstr(json,"agent",agent); jaddstr(json,"method",method); jaddstr(json,"coin",coin->symbol); + if ( userpass != 0 ) + jaddstr(json,"userpass",userpass); if ( coin != 0 && coin->chain->userpass[0] != 0 ) { if ( userpass == 0 || strcmp(userpass,coin->chain->userpass) != 0 ) diff --git a/iguana/main.c b/iguana/main.c index d9e0cb0ff..cd68ec531 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -326,7 +326,7 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,struct iguana_info *coin char *SuperNET_JSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,uint16_t port) { - int32_t autologin = 0; uint32_t timestamp; char *retstr=0,*agent=0,*method=0; uint64_t tag; + int32_t autologin = 0; uint32_t timestamp; char *retstr=0,*agent=0,*method=0,*userpass; uint64_t tag; //printf("SuperNET_JSON.(%s)\n",jprint(json,0)); if ( remoteaddr != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 ) remoteaddr = 0; @@ -351,6 +351,14 @@ char *SuperNET_JSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON OS_randombytes((uint8_t *)&tag,sizeof(tag)); jadd64bits(json,"tag",tag); } + if ( coin != 0 && coin->FULLNODE >= 0 && coin->chain->userpass[0] != 0 ) + { + if ( (userpass= jstr(json,"userpass")) == 0 || strcmp(userpass,coin->chain->userpass) != 0 ) + { + printf("iguana authentication error {%s} (%s) != (%s)\n",jprint(json,0),userpass,coin->chain->userpass); + return(clonestr("{\"error\":\"authentication error\"}")); + } + } if ( (retstr= SuperNET_processJSON(myinfo,coin,json,remoteaddr,port)) == 0 ) printf("null retstr from SuperNET_JSON\n"); if ( autologin != 0 )