+++ /dev/null
-import sys
-
-Import("DEBUG")
-Import("env")
-Import("libs")
-Import("libpath")
-
-cpppath = env["CPPPATH"]
-libs = ['swift'] + libs # order is important, crypto needs to be last
-
-if sys.platform == "win32":
- cpppath = ".."
- libpath += '..;'
- if DEBUG:
- env.Append(CXXFLAGS="/Zi /Yd /MTd")
-else:
- cpppath = cpppath + ':..'
- libpath += ':..'
- if DEBUG:
- env.Append(CXXFLAGS="-g")
-
-print "tests: libpath is",libpath
-
-
-#env.Program(
-# target='trial',
-# source=['trial.cpp'],
-# CPPPATH=cpppath,
-# LIBS=libs,
-# LIBPATH=libpath )
-
-env.Program(
- target='seeder',
- source=['seeder.cpp'],
- CPPPATH=cpppath,
- LIBS=libs,
- LIBPATH=libpath )
-
-env.Program(
- target='leecher',
- source=['leecher.cpp'],
- CPPPATH=cpppath,
- LIBS=libs,
- LIBPATH=libpath )
-
-env.Program(
- target='hasher',
- source=['hasher.cpp'],
- CPPPATH=cpppath,
- LIBS=libs,
- LIBPATH=libpath )
-
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include "bin64.h"
-
-int main (int argn, char** args) {
- int lr;
- unsigned long long of;
- sscanf(args[1],"%i,%lli",&lr,&of);
- bin64_t target(lr,of);
- char line[1024];
- while (gets(line)) {
- char* br = strchr(line,'(');
- if (br && 2==sscanf(br,"(%i,%lli)",&lr,&of)) {
- bin64_t found(lr,of);
- if ( found.within(target) || target.within(found))
- printf("%s\n",line);
- }
- }
- return 0;
-}
+++ /dev/null
-/*
- * hasher.cpp
- * swift
- *
- * Created by Victor Grishchenko on 11/8/09.
- * Copyright 2009 Delft University of Technology. All rights reserved.
- *
- */
-#include <stdio.h>
-#include "hashtree.h"
-#include "swift.h"
-
-
-int main (int argn, char** args) {
-
- if (argn<2) {
- fprintf(stderr,"Usage: %s file_name\n",args[0]);
- return 1;
- }
-
- swift::HashTree* ht = new swift::HashTree(args[1]);
-
- printf("SHA1 Merkle tree root hash: %s\n",ht->root_hash().hex().c_str());
-
-}
-
+++ /dev/null
-/*
- * leecher.cpp
- * swift
- *
- * Created by Victor Grishchenko on 11/3/09.
- * Copyright 2009 Delft University of Technology. All rights reserved.
- *
- */
-#include "swift.h"
-#include <time.h>
-
-
-using namespace swift;
-
-
-/** swift downloader. Params: root hash, filename, tracker ip/port, own ip/port */
-int main (int argn, char** args) {
-
- srand(time(NULL));
-
- if (argn<4) {
- fprintf(stderr,"parameters: root_hash filename tracker_ip:port [own_ip:port]\n");
- return -1;
- }
- Sha1Hash root_hash(true,args[1]);
- if (root_hash==Sha1Hash::ZERO) {
- fprintf(stderr,"Sha1 hash format: hex, 40 symbols\n");
- return -2;
- }
-
- swift::LibraryInit();
-
- char* filename = args[2];
-
- Address tracker(args[3]), bindaddr;
-
- if (tracker==Address()) {
- fprintf(stderr,"Tracker address format: [1.2.3.4:]12345, not %s\n",args[3]);
- return -2;
- }
- if (argn>=5)
- bindaddr = Address(args[4]);
- else
- bindaddr = Address((uint32_t)INADDR_ANY,rand()%10000+7000);
-
- if (swift::Listen(bindaddr)<=0) {
- fprintf(stderr,"Cannot listen on %s\n",bindaddr.str());
- return -3;
- }
-
- swift::SetTracker(tracker);
-
- int file = swift::Open(filename,root_hash);
- printf("Downloading %s\n",root_hash.hex().c_str());
-
- tint start = NOW;
-
- while (true){ //!swift::IsComplete(file)){// && NOW-start<TINT_SEC*60) {
- swift::Loop(TINT_SEC);
- eprintf("%s %lli of %lli (seq %lli) %lli dgram %lli bytes up, %lli dgram %lli bytes down\n",
- swift::IsComplete(file) ? "DONE" : "done",
- swift::Complete(file), swift::Size(file), swift::SeqComplete(file),
- Datagram::dgrams_up, Datagram::bytes_up,
- Datagram::dgrams_down, Datagram::bytes_down );
- }
-
- bool complete = swift::IsComplete(file);
-
- swift::Close(file);
-
- swift::Shutdown();
-
- return !complete;
-}
+++ /dev/null
-/*
- * connecttest.cpp
- * serp++
- *
- * Created by Victor Grishchenko on 3/19/09.
- * Copyright 2009 Delft University of Technology. All rights reserved.
- *
- */
-#include "swift.h"
-
-
-using namespace swift;
-
-
-/** swift seeder. Params: filename, own ip/port, tracker ip/port */
-int main (int argn, char** args) {
-
- if (argn<3) {
- fprintf(stderr,"parameters: filename own_ip/port [tracker_ip/port]\n");
- return -1;
- }
-
- swift::LibraryInit();
-
- char* filename = args[1];
-
- if (argn>=4) {
- Address tracker(args[3]);
- swift::SetTracker(tracker);
- }
- Address bindaddr(args[2]);
-
- if (bindaddr==Address()) {
- fprintf(stderr,"Bind address format: [1.2.3.4:]12345\n");
- return -2;
- }
-
- assert(0<swift::Listen(bindaddr));
- printf("seeder bound to %s\n",bindaddr.str());
-
-
- int file = swift::Open(filename);
- printf("seeding %s %s\n",filename,RootMerkleHash(file).hex().c_str());
-
- while (true) {
- swift::Loop(TINT_SEC*60);
- printf("%lli dgram %lli bytes up, %lli dgram %lli bytes down\n",
- Datagram::dgrams_up, Datagram::bytes_up,
- Datagram::dgrams_down, Datagram::bytes_down );
- }
-
- swift::Close(file);
-
- swift::Shutdown();
-
-}
+++ /dev/null
-/*
- * leecher.cpp
- * swift
- *
- * Created by Victor Grishchenko on 11/3/09.
- * Copyright 2009 Delft University of Technology. All rights reserved.
- *
- */
-#include "swift.h"
-#include <time.h>
-#include <string>
-#include "compat/util.h"
-#ifndef _WIN32
-#include <netdb.h>
-#endif
-
-
-using namespace swift;
-
-
-/** swift downloader. Params: root hash, filename, tracker ip/port, own ip/port */
-int main (int argn, char** args) {
- THIS IS NOT TRIAL BRANCH
- srand(time(NULL));
- Sha1Hash root_hash(true,"32e5d9d2d8c0f6073e2820cf47b15b58c2e42a23");
- swift::LibraryInit();
-
- // Arno: use tempdir
- std::string tmpdir = gettmpdir();
- std::string sfn = tmpdir+"team.jpg";
- std::string hfn = tmpdir+"team.jpg.mhash";
- const char* filename = strdup(sfn.c_str());
- unlink(filename);
- unlink(hfn.c_str());
-
- Address tracker("victor.p2p-next.org:12345"),
- bindaddr((uint32_t)INADDR_ANY,10000),
- fallback("victor2.p2p-next.org:12345");
-
- if (0>swift::Listen(bindaddr)) {
- print_error("cannot bind");
- return 1;
- }
- swift::SetTracker(tracker);
- int file = swift::Open(filename,root_hash);
- printf("Downloading %s\n",root_hash.hex().c_str());
- int count = 400;
- while (!swift::IsComplete(file) && count-->0) {
- swift::Loop(TINT_SEC/10);
- if (count==100)
- FileTransfer::file(file)->OnPexIn(fallback);
- printf("done %lli of %lli (seq %lli) %lli dgram %lli bytes up, %lli dgram %lli bytes down\n",
- swift::Complete(file), swift::Size(file), swift::SeqComplete(file),
- Datagram::dgrams_up, Datagram::bytes_up,
- Datagram::dgrams_down, Datagram::bytes_down );
- }
- int ret = !swift::IsComplete(file);
-
- swift::Close(file);
- swift::Shutdown();
-
- return ret;
-
-}