d1502706c46779d361a1d562a10da0a45c4c40e5 -f \
trailer.ogg
- ...to retrieve video and save it to a file, or...
+ ...to retrieve video and save it to a file.
- ./swift -t mfold.libswift.org:20000 -h \
- d1502706c46779d361a1d562a10da0a45c4c40e5 -r . \
- -h 8080
-
- ...and then point your browser at
-
- http://localhost:8080/d1502706c46779d361a1d562a10da0a45c4c40e5
+ Alternatively, you might play with the HTTP gateway, the preliminary
+ version. First, run the seeder-tracker:
+
+ $ ./swift -f ~/Downloads/big_buck_bunny_480p_stereo.ogg -l 0.0.0.0:20000
+ Root hash: 7c462ad1d980ba44ab4b819e29004eb0bf6e6d5f
+
+ ...then you may try running the swift-HTTP gateway...
+
+ ./swift -t localhost:20000 -g 0.0.0.0:8080 -w
+
+ ...and finally you may point your browser at the gateway...
+
+ http://localhost:8080/7c462ad1d980ba44ab4b819e29004eb0bf6e6d5f
+
+ If you use an HTML5 browser (Chrome preferred), you are likely to see
+ the bunny trailer at this point...
} else {
if (req->tosend==0) { // done; wait for new request
dprintf("%s @%i done\n",tintstr(),req->id);
- sckrwecb_t wait_new_req(req->sink,HttpGwNewRequestCallback,NULL,HttpGwCloseConnection);
+ sckrwecb_t wait_new_req
+ (req->sink,HttpGwNewRequestCallback,NULL,HttpGwCloseConnection);
swift::Datagram::Listen3rdPartySocket (wait_new_req);
} else { // wait for data
dprintf("%s @%i waiting for data\n",tintstr(),req->id);
if ( (bin.base_offset()<<10) == http_requests[httpc].offset ) {
dprintf("%s @%i progress: %s\n",tintstr(),http_requests[httpc].id,bin.str());
sckrwecb_t maywrite_callbacks
- (http_requests[httpc].sink,NULL,HttpGwMayWriteCallback,HttpGwCloseConnection);
+ (http_requests[httpc].sink,NULL,
+ HttpGwMayWriteCallback,HttpGwCloseConnection);
Datagram::Listen3rdPartySocket (maywrite_callbacks);
}
}
"HTTP/1.1 200 OK\r\n"\
"Connection: keep-alive\r\n"\
"Content-Type: video/ogg\r\n"\
- "X-Content-Duration: 32\r\n"\
+ /*"X-Content-Duration: 32\r\n"*/\
"Content-Length: %lli\r\n"\
"Accept-Ranges: bytes\r\n"\
"\r\n",
Address bindaddr;
Address tracker;
Address http_gw;
- tint wait_time = -1;
+ tint wait_time = 0;
LibraryInit();
bindaddr = Address(optarg);
if (bindaddr==Address())
quit("address must be hostname:port, ip:port or just port\n");
- if (wait_time==-1)
- wait_time = TINT_NEVER; // seed
+ wait_time = TINT_NEVER;
break;
case 't':
tracker = Address(optarg);
wait_time = TINT_NEVER; // seed
break;
case 'w':
- wait_time = TINT_NEVER;
if (optarg) {
char unit = 'u';
if (sscanf(optarg,"%lli%c",&wait_time,&unit)!=2)
case 'u': break;
default: quit("time format: 1234[umsMHD], e.g. 1D = one day\n");
}
- }
+ } else
+ wait_time = TINT_NEVER;
break;
}
printf("Root hash: %s\n", RootMerkleHash(file).hex().c_str());
}
- if (bindaddr==Address() && file==-1) {
+ if (bindaddr==Address() && file==-1 && http_gw==Address()) {
fprintf(stderr,"Usage:\n");
fprintf(stderr," -h, --hash\troot Merkle hash for the transmission\n");
fprintf(stderr," -f, --file\tname of file to use (root hash by default)\n");
fprintf(stderr," -p, --progress\treport transfer progress\n");
fprintf(stderr," -g, --http\t[ip:|host:]port to bind HTTP gateway to (default localhost:8080)\n");
fprintf(stderr," -w, --wait\tlimit running time, e.g. 1[DHMs] (default: infinite with -l, -g)\n");
+ return 1;
}
tint start_time = NOW;
- while ( bindaddr!=Address() &&
- ( ( file>=0 && !IsComplete(file) ) ||
- ( start_time+wait_time > NOW ) ) ) {
+ while ( (file>=0 && !IsComplete(file)) ||
+ (start_time+wait_time>NOW) ) {
swift::Loop(TINT_SEC);
if (report_progress && file>=0) {
fprintf(stderr,