Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d08cd2fbc6
|
@ -209,7 +209,7 @@ module.exports = function(logger){
|
|||
var redisClient = redis.createClient(6379, "localhost")
|
||||
redisClient.on('ready', function(){
|
||||
redisClient.hgetall("proxyState", function(error, obj) {
|
||||
if (error) {
|
||||
if (error || obj == null) {
|
||||
logger.debug(logSystem, logComponent, logSubCat, 'No last proxy state found in redis');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
/*
|
||||
|
||||
Contributed by Alex Petrov aka SysMan at sysman.net
|
||||
Updated by Alejandro Reyero - TodoJuegos.com
|
||||
|
||||
Part of NOMP project
|
||||
Simple lightweight & fast - a more efficient block notify script in pure C.
|
||||
|
@ -22,8 +23,9 @@ Build with:
|
|||
|
||||
|
||||
Usage in daemon coin.conf
|
||||
blocknotify="/bin/blocknotify localhost:8117 mySuperSecurePassword dogecoin %s"
|
||||
blocknotify="/bin/blocknotify 127.0.0.1:8117 mySuperSecurePassword dogecoin %s"
|
||||
|
||||
*NOTE* If you use "localhost" as hostname you may get a "13" error (socket / connect / send may consider "localhost" as a broadcast address)
|
||||
|
||||
// {"password":"notepas","coin":"Xcoin","hash":"d2191a8b644c9cd903439edf1d89ee060e196b3e116e0d48a3f11e5e3987a03b"}
|
||||
// simplest connect + send json string to server
|
||||
|
@ -49,37 +51,41 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
strncpy(host,argv[1],(sizeof(host)-1));
|
||||
p=host;
|
||||
strncpy(host,argv[1],(sizeof(host)-1));
|
||||
p=host;
|
||||
|
||||
if ( (arg=strchr(p,':')) )
|
||||
{ *arg='\0';
|
||||
if ( (arg=strchr(p,':')) )
|
||||
{
|
||||
*arg='\0';
|
||||
|
||||
errno=0; // reset errno
|
||||
port=strtol(++arg,&errptr,10);
|
||||
errno=0; // reset errno
|
||||
port=strtol(++arg,&errptr,10);
|
||||
|
||||
if ( (errno != 0) || (errptr == arg) ) { fprintf(stderr, "port number fail [%s]\n",errptr); }
|
||||
// if(strlen(arg) > (errptr-arg) ) also fail, but we ignore it for now
|
||||
// printf("host %s:%d\n",host,port);
|
||||
}
|
||||
if ( (errno != 0) || (errptr == arg) ) { fprintf(stderr, "port number fail [%s]\n",errptr); }
|
||||
// if(strlen(arg) > (errptr-arg) ) also fail, but we ignore it for now
|
||||
// printf("host %s:%d\n",host,port);
|
||||
}
|
||||
|
||||
// printf("pass: %s coin: %s block:[%s]\n",argv[2],argv[3],argv[4]);
|
||||
snprintf(sendline,sizeof(sendline)-1,
|
||||
"{\"password\":\"%s\",\"coin\":\"%s\",\"hash\":\"%s\"}\n",
|
||||
argv[2], argv[3], argv[4]);
|
||||
// printf("pass: %s coin: %s block:[%s]\n",argv[2],argv[3],argv[4]);
|
||||
snprintf(sendline,sizeof(sendline)-1,
|
||||
"{\"password\":\"%s\",\"coin\":\"%s\",\"hash\":\"%s\"}\n",
|
||||
argv[2], argv[3], argv[4]);
|
||||
|
||||
// printf("sendline:[%s]",sendline);
|
||||
|
||||
sockfd=socket(AF_INET,SOCK_STREAM,0);
|
||||
// printf("sendline:[%s]",sendline);
|
||||
|
||||
sockfd=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
bzero(&servaddr,sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
servaddr.sin_addr.s_addr=inet_addr(host);
|
||||
servaddr.sin_port=htons(port);
|
||||
|
||||
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
|
||||
sendto(sockfd,sendline,strlen(sendline),0,
|
||||
(struct sockaddr *)&servaddr,sizeof(servaddr));
|
||||
exit(0);
|
||||
int result = send(sockfd,sendline,strlen(sendline),0);
|
||||
close(sockfd);
|
||||
|
||||
if(result == -1) {
|
||||
printf("Error sending: %i\n",errno);
|
||||
exit(-1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue