diff --git a/rhizome.h b/rhizome.h index ce265234..94318c96 100644 --- a/rhizome.h +++ b/rhizome.h @@ -475,6 +475,11 @@ rhizome_direct_sync_request int rhizome_direct_continue_sync_request(rhizome_direct_sync_request *r); int rhizome_direct_conclude_sync_request(rhizome_direct_sync_request *r); +typedef struct rhizome_direct_transport_state_http { + int port; + char host[1024]; +} rhizome_direct_transport_state_http; + void rhizome_direct_http_dispatch(rhizome_direct_sync_request *); extern unsigned char favicon_bytes[]; diff --git a/rhizome_direct.c b/rhizome_direct.c index 99d21b55..bdc3796a 100644 --- a/rhizome_direct.c +++ b/rhizome_direct.c @@ -270,9 +270,22 @@ int app_rhizome_direct_sync(int argc, const char *const *argv, /* Get iterator capable of 64KB buffering. In future we should parse the sync URL and base the buffer size on the transport and allowable traffic volumes. */ + rhizome_direct_transport_state_http + *state=calloc(sizeof(rhizome_direct_transport_state_http),1); + if (strlen(argv[3])>1020) + { + DEBUG("rhizome direct URI too long"); + return -1; + } + if (sscanf(argv[3],"%[^:]:%d",state->host,&state->port)!=2) + { + DEBUG("could not parse rhizome direct URI"); + return -1; + } + rhizome_direct_sync_request *s = rhizome_direct_new_sync_request(rhizome_direct_http_dispatch, - 65536,0,mode,NULL); + 65536,0,mode,state); rhizome_direct_start_sync_request(s); diff --git a/rhizome_direct_http.c b/rhizome_direct_http.c index e67a9661..599fb303 100644 --- a/rhizome_direct_http.c +++ b/rhizome_direct_http.c @@ -480,6 +480,10 @@ int rhizome_direct_parse_http_request(rhizome_http_request *r) void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r) { DEBUGF("Dispatch size_high=%lld",r->cursor->size_high); + + + + int sock; /* Warning: tail recursion when done this way. Should be triggered by an asynchronous event.