Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jl777 committed Nov 5, 2015
1 parent 6e5c275 commit 5caa8b1
Show file tree
Hide file tree
Showing 33 changed files with 182 additions and 121 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,27 @@ randvals.7
randvals.5

randvals.8

libs/libboost_filesystem.a

libs/libboost_program_options.a

libs/libboost_system.a

libs/libboost_system.a

libs/libboost_thread.a

libs/libdb_cxx.a

libs/libjl777.a

libs/libjl777.a

libs/libleveldb.a

libs/libdb.a

libs/libsnappy.a

src/obj/scrypt-arm.d
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
# The PNaCl workflow uses both an unstripped and finalized/stripped binary.
# On NaCl, only produce a stripped binary for Release configs (not Debug).
ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG))))
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))

$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)));
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
Expand Down
Binary file modified Release/SuperNET_API.pexe
Binary file not shown.
Binary file modified Release/SuperNET_API_unstripped.bc
Binary file not shown.
Binary file modified Release/SuperNET_API_unstripped.bc---linked.pre_opt.pexe
Binary file not shown.
Binary file modified Release/SuperNET_API_unstripped.pexe
Binary file not shown.
130 changes: 68 additions & 62 deletions SuperNET.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,63 @@ char *SuperNET_install(char *plugin,char *jsonstr,cJSON *json)
return(retstr);
}

int32_t SuperNET_saveconf(char *jsonstr)
{
FILE *fp;
if ( (fp= fopen(os_compatible_path("SuperNET.conf"),"w")) != 0 )
{
fprintf(fp,"%s\n",jsonstr);
fclose(fp);
PostMessage("SuperNET_saveconf (%s)\n",jsonstr);
return(0);
}
return(-1);
}

char *SuperNET_setconf(char *field,int32_t val)
{
char *confstr; uint64_t allocsize; cJSON *json;
printf("save.(\"%s\":%d)\n",field,val);
if ( (confstr= loadfile(&allocsize,os_compatible_path("SuperNET.conf"))) == 0 )
json = cJSON_CreateObject();
else
{
json = cJSON_Parse(confstr);
free(confstr);
}
if ( json == 0 )
json = cJSON_CreateObject();
if ( jobj(json,field) != 0 )
cJSON_DeleteItemFromObject(json,field);
jaddnum(json,field,val);
confstr = jprint(json,1);
if ( confstr != 0 )
SuperNET_saveconf(confstr);
return(confstr);
}

char *SuperNET_setconfstr(char *field,char *valstr)
{
char *confstr; uint64_t allocsize; cJSON *json;
printf("save.(\"%s\":\"%s\")\n",field,valstr);
if ( (confstr= loadfile(&allocsize,os_compatible_path("SuperNET.conf"))) == 0 )
json = cJSON_CreateObject();
else
{
json = cJSON_Parse(confstr);
free(confstr);
}
if ( json == 0 )
json = cJSON_CreateObject();
if ( jobj(json,field) != 0 )
cJSON_DeleteItemFromObject(json,field);
jaddstr(json,field,valstr);
confstr = jprint(json,1);
if ( confstr != 0 )
SuperNET_saveconf(confstr);
return(confstr);
}

int32_t got_newpeer(const char *ip_port) { if ( Debuglevel > 2 ) printf("got_newpeer.(%s)\n",ip_port); return(0); }

void *issue_cgicall(void *_ptr)
Expand Down Expand Up @@ -223,6 +280,12 @@ char *process_jl777_msg(char *buf,int32_t bufsize,char *previpaddr,char *jsonstr
free_json(json);
return(retstr);
}
else if ( strcmp(request.buf,"setconf") == 0 )
{
if ( SuperNET_saveconf(jsonstr) == 0 )
return(clonestr("{\"success\":\"SuperNET.conf saved\"}"));
else return(clonestr("{\"error\":\"couldnt save SuperNET.conf\"}"));
} //else printf("request.(%s)\n",request.buf);
tag = get_API_nxt64bits(cJSON_GetObjectItem(json,"tag"));
daemonid = get_API_nxt64bits(cJSON_GetObjectItem(json,"daemonid"));
instanceid = get_API_nxt64bits(cJSON_GetObjectItem(json,"instanceid"));
Expand All @@ -243,7 +306,7 @@ char *process_jl777_msg(char *buf,int32_t bufsize,char *previpaddr,char *jsonstr
// sprintf(buf + strlen(buf)-1,",\"rand\":\"%d\"}",rand());
return(process_nn_message(-1,buf));
} else printf("jsonstr too big %d vs %d\n",(int32_t)strlen(jsonstr),bufsize);
}
} else PostMessage("parse error\n");
sprintf(buf,"{\"error\":\"couldnt parse JSON\",\"args\":[\"%s\"]}",jsonstr);
return(clonestr(buf));
}
Expand Down Expand Up @@ -643,63 +706,6 @@ void nanotests(int32_t numiters)
printf("finished nanotests\n");
}

int32_t SuperNET_saveconf(char *jsonstr)
{
FILE *fp;
if ( (fp= fopen(os_compatible_path("SuperNET.conf"),"w")) != 0 )
{
fprintf(fp,"%s\n",jsonstr);
fclose(fp);
PostMessage("SuperNET_saveconf (%s)\n",jsonstr);
return(0);
}
return(-1);
}

char *SuperNET_setconf(char *field,int32_t val)
{
char *confstr; uint64_t allocsize; cJSON *json;
printf("save.(\"%s\":%d)\n",field,val);
if ( (confstr= loadfile(&allocsize,os_compatible_path("SuperNET.conf"))) == 0 )
json = cJSON_CreateObject();
else
{
json = cJSON_Parse(confstr);
free(confstr);
}
if ( json == 0 )
json = cJSON_CreateObject();
if ( jobj(json,field) != 0 )
cJSON_DeleteItemFromObject(json,field);
jaddnum(json,field,val);
confstr = jprint(json,1);
if ( confstr != 0 )
SuperNET_saveconf(confstr);
return(confstr);
}

char *SuperNET_setconfstr(char *field,char *valstr)
{
char *confstr; uint64_t allocsize; cJSON *json;
printf("save.(\"%s\":\"%s\")\n",field,valstr);
if ( (confstr= loadfile(&allocsize,os_compatible_path("SuperNET.conf"))) == 0 )
json = cJSON_CreateObject();
else
{
json = cJSON_Parse(confstr);
free(confstr);
}
if ( json == 0 )
json = cJSON_CreateObject();
if ( jobj(json,field) != 0 )
cJSON_DeleteItemFromObject(json,field);
jaddstr(json,field,valstr);
confstr = jprint(json,1);
if ( confstr != 0 )
SuperNET_saveconf(confstr);
return(confstr);
}

int32_t SuperNET_isactivated(char *agent)
{
cJSON *array; int32_t n;
Expand All @@ -720,9 +726,9 @@ int SuperNET_start(char *fname,char *myip)
parse_ipaddr(ipaddr,myip);
Debuglevel = 2;
printf("%p myip.(%s) rand.%llx fname.(%s)\n",myip,myip,(long long)i,fname);
#ifdef __PNACL
SuperNET_saveconf(DEFAULT_SUPERNET_CONF);
#endif
//#ifdef __PNACL
// SuperNET_saveconf(DEFAULT_SUPERNET_CONF);
//#endif
if ( (jsonargs= loadfile(&allocsize,os_compatible_path(fname))) == 0 )
{
printf("ERROR >>>>>>>>>>> (%s) SuperNET.conf file doesnt exist\n",fname);
Expand Down Expand Up @@ -761,7 +767,7 @@ int SuperNET_start(char *fname,char *myip)
if ( SuperNET_isactivated("teleport") != 0 )
strs[n++] = SuperNET_launch_agent("teleport",jsonargs,&TELEPORT.readyflag);
if ( SuperNET_isactivated("cashier") != 0 )
strs[n++] = SuperNET_launch_agent("cashier",jsonargs,&CASHIER.readyflag);
strs[n++] = SuperNET_launch_agent("cashier",jsonargs,0);
if ( SuperNET_isactivated("InstantDEX") != 0 )
{
strs[n++] = SuperNET_launch_agent("InstantDEX",jsonargs,&INSTANTDEX.readyflag);
Expand Down
2 changes: 1 addition & 1 deletion chrome.localhost
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open -a "Google Chrome" --args --allow-nacl-socket-api=localhost --new-window http://localhost:7777
open -a "Google Chrome" --args --allow-nacl-socket-api=127.0.0.1
#open -a "Google Chrome" --args --allow-nacl-socket-api=127.0.0.1 --no-sandbox
#open -a "Google Chrome" --args --allow-nacl-socket-api=commondatastorage.googleapis.com --no-sandbox
#"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -allow-nacl-socket-api=localhost
5 changes: 5 additions & 0 deletions clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
make clean
cd src; make -f Makefile.unix clean; cd ..
make -f makefile.libs clean
make -f makefile.unix clean

2 changes: 1 addition & 1 deletion js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function readBlob(opt_startByte, opt_stopByte) {

var confString = e.target.result;

postCall("SuperNET", '{setConf: ' + confString + '}', function(result){
postCall("SuperNET",confString, function(result){
console.log(result);
});

Expand Down
Binary file modified lib/pnacl/Release/libjl777.a
Binary file not shown.
Binary file modified lib/pnacl/Release/libnanoagent.a
Binary file not shown.
Binary file modified lib/pnacl/Release/libnanomsg.a
Binary file not shown.
6 changes: 5 additions & 1 deletion m_unix
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

rm SuperNET
pkill -15 SuperNET
./BitcoinDarkd stop
sleep 2
rm SuperNET
rm BitcoinDarkd
git pull
make -f makefile.libs
make
make -f makefile.unix
make -f makefile.unix btcd

6 changes: 5 additions & 1 deletion makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ LIBS = -lcurl -lssl -lcrypto -lpthread -lz -lm

CC = gcc
OS := $(shell uname -s)
CFLAGS += -Ipicocoin/include -Wno-unused-but-set-variable -O2
ifeq ($(OSNAME),Linux)
CFLAGS += -Wno-unused-but-set-variable
endif

CFLAGS += -Ipicocoin/include -O2

ALLSOURCES = plugins/InstantDEX/InstantDEX_main.c plugins/common/prices777.c plugins/peggy/quotes777.c plugins/peggy/peggy777.c plugins/common/opreturn777.c plugins/common/txind777.c plugins/common/teleport777.c plugins/KV/ramkv777.c plugins/agents/shuffle777.c $(SOURCES) $(ASOURCES) $(CSOURCES) $(GSOURCES) $(LSOURCES) $(PSOURCES)

Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"name": "My Sockets app",
"sockets": {
"tcp": { "connect": "" },
"tcpServer": { "listen": ":*" }
"tcpServer": { "listen": "127.0.0.1:*" }
},
"permissions": [
"unlimitedStorage",
"nativeMessaging",
"nativeMessaging","networking.config",
"dns", "browser", "filesystem", "storage",
"system.storage", "system.display", "system.network"
"system.storage", "system.display", "system.network","system.cpu"
]
}
4 changes: 2 additions & 2 deletions n
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cp pnacl/Release/SuperNET_API.pexe pnacl/Release/SuperNET_API.nmf ../SuperNET/pnacl/Release
cp index.html *.js ../SuperNET
cp chrome.localhost index.html *.js ../SuperNET
cp js/* ../SuperNET/js
cp css/* ../SuperNET/css

cp tools/httpd.py ../SuperNET/tools
10 changes: 6 additions & 4 deletions nanosrc/aio/usock_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ static void nn_usock_shutdown (struct nn_fsm *self, int src, int type,
void nn_usock_init (struct nn_usock *self, int src, struct nn_fsm *owner)
{
/* Initalise the state machine. */
nn_fsm_init (&self->fsm, nn_usock_handler, nn_usock_shutdown,
src, self, owner);
nn_fsm_init (&self->fsm, nn_usock_handler, nn_usock_shutdown,src, self, owner);
self->state = NN_USOCK_STATE_IDLE;

/* Choose a worker thread to handle this socket. */
Expand Down Expand Up @@ -163,7 +162,7 @@ int nn_usock_start (struct nn_usock *self, int domain, int type, int protocol,co
s = socket (domain, type, protocol);
if (nn_slow (s < 0))
return -errno;
PostMessage("got socket s.%d for (%s) type.%d protocol.%d\n",s,addr,type,protocol);
PostMessage("got socket self.%p s.%d for (%s) type.%d protocol.%d\n",self,s,addr,type,protocol);
nn_usock_init_from_fd (self, s);
/* Start the state machine. */
nn_fsm_start (&self->fsm);
Expand All @@ -184,6 +183,7 @@ static void nn_usock_init_from_fd(struct nn_usock *self,int s)
// Store the file descriptor
nn_assert (self->s == -1);
self->s = s;
PostMessage("set s.%p <- %d for (%s)\n",self,s,self->addr);
/* Setting FD_CLOEXEC option immediately after socket creation is the
second best option after using SOCK_CLOEXEC. There is a race condition
here (if process is forked between socket creation and setting
Expand Down Expand Up @@ -271,7 +271,9 @@ int nn_usock_bind (struct nn_usock *self,const struct sockaddr *addr,size_t addr
rc = bind(self->s,addr,(socklen_t)addrlen);
PostMessage("usock.%d %x -> bind rc.%d errno.%d (%s) \n",self->s,*(int32_t *)addr,rc,errno,self->addr);
if ( nn_slow (rc != 0) )
{
return -errno;
}
return 0;
}

Expand Down Expand Up @@ -306,7 +308,7 @@ void nn_usock_accept(struct nn_usock *self, struct nn_usock *listener)
#else
s = accept (listener->s, NULL, NULL);
#endif
PostMessage("usock.%d -> accept errno.%d s.%d %s\n",self->s,errno,s,self->addr);
PostMessage("self.%p usock.%d -> accept errno.%d s.%d %s\n",self,self->s,errno,s,self->addr);

/* Immediate success. */
if (nn_fast (s >= 0)) {
Expand Down
1 change: 1 addition & 0 deletions nanosrc/nn_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#define NN_HAVE_MSG_CONTROL 1
//#define STANDALONE 1
//#define FD_CLOEXEC 1
//#define NN_USE_IFADDRS 1

#ifdef __PNACL

Expand Down
24 changes: 15 additions & 9 deletions nanosrc/transports/tcp/ctcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ static void nn_ctcp_destroy (struct nn_epbase *self)
nn_free (ctcp);
}

static void nn_ctcp_shutdown (struct nn_fsm *self, int src, int type,
NN_UNUSED void *srcptr)
static void nn_ctcp_shutdown (struct nn_fsm *self, int src, int type,NN_UNUSED void *srcptr)
{
struct nn_ctcp *ctcp;

Expand Down Expand Up @@ -270,8 +269,7 @@ static void nn_ctcp_shutdown (struct nn_fsm *self, int src, int type,
nn_fsm_bad_state (ctcp->state, src, type);
}

static void nn_ctcp_handler (struct nn_fsm *self, int src, int type,
NN_UNUSED void *srcptr)
static void nn_ctcp_handler (struct nn_fsm *self, int src, int type,NN_UNUSED void *srcptr)
{
struct nn_ctcp *ctcp;

Expand Down Expand Up @@ -519,8 +517,7 @@ static void nn_ctcp_start_resolving (struct nn_ctcp *self)

/* Check whether IPv6 is to be used. */
ipv4onlylen = sizeof (ipv4only);
nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY,
&ipv4only, &ipv4onlylen);
nn_epbase_getopt (&self->epbase, NN_SOL_SOCKET, NN_IPV4ONLY,&ipv4only, &ipv4onlylen);
nn_assert (ipv4onlylen == sizeof (ipv4only));

/* TODO: Get the actual value of IPV4ONLY option. */
Expand Down Expand Up @@ -606,9 +603,18 @@ static void nn_ctcp_start_connecting (struct nn_ctcp *self,struct sockaddr_stora

/* Bind the socket to the local network interface. */
rc = nn_usock_bind (&self->usock, (struct sockaddr*) &local, locallen);
if (nn_slow (rc != 0)) {
nn_backoff_start (&self->retry);
self->state = NN_CTCP_STATE_WAITING;
if (nn_slow (rc != 0))
{
if ( errno == EACCESS )
{
nn_usock_stop (&self->usock);
self->state = NN_CTCP_STATE_STOPPING_USOCK;
}
else
{
nn_backoff_start (&self->retry);
self->state = NN_CTCP_STATE_WAITING;
}
return;
}

Expand Down
3 changes: 1 addition & 2 deletions nanosrc/transports/utils/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ void nn_dns_init (struct nn_dns *self, int src, struct nn_fsm *owner);
void nn_dns_term (struct nn_dns *self);

int nn_dns_isidle (struct nn_dns *self);
void nn_dns_start (struct nn_dns *self, const char *addr, size_t addrlen,
int ipv4only, struct nn_dns_result *result);
void nn_dns_start (struct nn_dns *self, const char *addr, size_t addrlen,int ipv4only, struct nn_dns_result *result);
void nn_dns_stop (struct nn_dns *self);

#endif
Loading

0 comments on commit 5caa8b1

Please sign in to comment.