Browse Source

add Referer check

dPoW2
jl777 8 years ago
parent
commit
69be8e78fa
  1. 49
      iguana/dpow/dpow_prices.c
  2. 32
      iguana/iguana_rpc.c

49
iguana/dpow/dpow_prices.c

@ -221,11 +221,52 @@ char *PAX_bases[64] =
"BUND", "NAS100", "SPX500", "US30", "EUSTX50", "UK100", "JPN225", "GER30", "SUI30", "AUS200", "HKG33", "XAUUSD", "BTCRUB", "BTCCNY", "BTCUSD" // abstract
};
uint32_t MINDENOMS[] = { 1000, 1000, 100000, 1000, 1000, 1000, 1000, 1000, // major currencies
10000, 100000, 10000, 1000, 100000, 10000, 1000, 10000, 1000, 10000, 10000, 10000, 10000, 100000, 1000, 1000000, 1000, 10000, 1000, 1000, 10000, 1000, 10000000, 10000, // end of currencies
1, 100, 1, 1, // metals, gold must be first
100, 1, 10000, 100, 100, 1000, 100000, 1000, 1000, 1000
uint64_t M1SUPPLY[] = { 3317900000000, 6991604000000, 667780000000000, 1616854000000, 331000000000, 861909000000, 584629000000, 46530000000, // major currencies
45434000000000, 16827000000000, 3473357229000, 306435000000, 27139000000000, 2150641000000, 347724099000, 1469583000000, 749543000000, 1826110000000, 2400434000000, 1123925000000, 3125276000000, 13975000000000, 317657000000, 759706000000000, 354902000000, 2797061000000, 162189000000, 163745000000, 1712000000000, 39093000000, 1135490000000000, 80317000000,
100000000 };
#define MIND 1000
uint32_t MINDENOMS[] = { MIND, MIND, 100*MIND, MIND, MIND, MIND, MIND, MIND, // major currencies
10*MIND, 100*MIND, 10*MIND, MIND, 100*MIND, 10*MIND, MIND, 10*MIND, MIND, 10*MIND, 10*MIND, 10*MIND, 10*MIND, 100*MIND, MIND, 1000*MIND, MIND, 10*MIND, MIND, MIND, 10*MIND, MIND, 10000*MIND, 10*MIND, // end of currencies
10*MIND,
};
uint64_t komodo_paxvol(uint64_t volume,uint64_t price)
{
if ( volume < 10000000000 )
return((volume * price) / 1000000000);
else if ( volume < (uint64_t)10 * 10000000000 )
return((volume * (price / 10)) / 100000000);
else if ( volume < (uint64_t)100 * 10000000000 )
return(((volume / 10) * (price / 10)) / 10000000);
else if ( volume < (uint64_t)1000 * 10000000000 )
return(((volume / 10) * (price / 100)) / 1000000);
else if ( volume < (uint64_t)10000 * 10000000000 )
return(((volume / 100) * (price / 100)) / 100000);
else if ( volume < (uint64_t)100000 * 10000000000 )
return(((volume / 100) * (price / 1000)) / 10000);
else if ( volume < (uint64_t)1000000 * 10000000000 )
return(((volume / 1000) * (price / 1000)) / 1000);
else if ( volume < (uint64_t)10000000 * 10000000000 )
return(((volume / 1000) * (price / 10000)) / 100);
else return(((volume / 10000) * (price / 10000)) / 10);
}
void pax_rank(uint64_t *ranked,uint32_t *pvals)
{
int32_t i; uint64_t vals[32],sum = 0;
for (i=0; i<32; i++)
{
vals[i] = komodo_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]);
sum += vals[i];
}
for (i=0; i<32; i++)
{
ranked[i] = (vals[i] * 1000000000) / sum;
printf("%.6f ",(double)ranked[i]/1000000000.);
}
};
#define YAHOO_METALS "XAU", "XAG", "XPT", "XPD"
static char *Yahoo_metals[] = { YAHOO_METALS };

32
iguana/iguana_rpc.c

@ -843,24 +843,28 @@ cJSON *SuperNET_urlconv(char *value,int32_t bufsize,char *urlstr)
char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *postflagp,char *urlstr,char *remoteaddr,char *filetype,uint16_t port)
{
cJSON *tokens,*argjson,*origargjson,*json = 0; long filesize; struct iguana_info *coin = 0;
char symbol[64],buf[4096],*originstr,urlmethod[16],*data,url[8192],furl[8192],*retstr,*filestr,*token = 0; int32_t i,j,n,num=0;
char symbol[64],buf[4096],*originstr,*fieldstr,urlmethod[16],*data,url[8192],furl[8192],*retstr,*filestr,*token = 0; int32_t i,j,n,iter,num=0;
//printf("rpcparse.(%s)\n",urlstr);
if ( myinfo->remoteorigin == 0 )
{
n = (int32_t)(strlen(urlstr) - strlen("Origin: "));
for (i=0; i<n; i++)
if ( strncmp("Origin: ",&urlstr[i],strlen("Origin: ")) == 0 )
{
originstr = &urlstr[i + strlen("Origin: ")];
if ( strncmp(originstr,"http://127.0.0.",strlen("http://127.0.0.")) == 0 )
originstr = "http://127.0.0.1:";
if ( strncmp("null",originstr,strlen("null")) != 0 && strncmp("http://localhost:",originstr,strlen("http://localhost:")) != 0 && strncmp("http://127.0.0.1:",originstr,strlen("http://127.0.0.1:")) != 0 && strncmp("http://easydex.supernet.org",originstr,strlen("http://easydex.supernet.org")) != 0 )
for (iter=0; iter<2; iter++)
{
fieldstr = (iter == 0) ? "Origin: " : "Referer: ";
n = (int32_t)(strlen(urlstr) - strlen(fieldstr));
for (i=0; i<n; i++)
if ( strncmp(fieldstr,&urlstr[i],strlen(fieldstr)) == 0 )
{
printf("remote Origin REJECT.(%s)\n",urlstr);
return(clonestr("{\"error\":\"remote origin not enabled\"}"));
} //else printf("allow file://\n");
break;
}
originstr = &urlstr[i + strlen(fieldstr)];
if ( strncmp(originstr,"http://127.0.0.",strlen("http://127.0.0.")) == 0 )
originstr = "http://127.0.0.1:";
if ( strncmp("null",originstr,strlen("null")) != 0 && strncmp("http://localhost:",originstr,strlen("http://localhost:")) != 0 && strncmp("http://127.0.0.1:",originstr,strlen("http://127.0.0.1:")) != 0 && strncmp("http://easydex.supernet.org",originstr,strlen("http://easydex.supernet.org")) != 0 )
{
printf("remote %s REJECT.(%s)\n",fieldstr,urlstr);
return(clonestr("{\"error\":\"remote origin not enabled\"}"));
} //else printf("allow file://\n");
break;
}
}
}
for (i=0; i<sizeof(urlmethod)-1&&urlstr[i]!=0&&urlstr[i]!=' '; i++)
urlmethod[i] = urlstr[i];

Loading…
Cancel
Save