Skip to content

Commit

Permalink
Merge latest working code
Browse files Browse the repository at this point in the history
PR to merge latest working code on branch testingv4
  • Loading branch information
Carlos Requena López authored Dec 3, 2018
2 parents 47daccb + f287b03 commit 69b0f56
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import json
from flask import Flask, render_template, request, redirect
from random import sample
import sys

from common.hash import hash_payload
from crypto.rsa import rsa_encrypt, rsa_decrypt
Expand All @@ -15,10 +14,12 @@
from common.network_info import tracker, node_pool, public_keys, cid_size, get_url, domain_names
from common.encoding import json_to_bytes, bytes_to_json


class SignatureNotMatching(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)


class Client(Flask):

def __init__(self, name, filenames):
Expand Down
5 changes: 0 additions & 5 deletions client/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ <h1>TORrents client</h1>
</a>
</div>
</div>
<a href="">
<button class="btn waves-effect waves-light">Onion disconnect
<i class="material-icons right">lock_closed</i>
</button>
</a>
{% else %}
<a href="/connect">
<button class="btn waves-effect waves-light">Onion connect
Expand Down
11 changes: 5 additions & 6 deletions node.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import traceback
import os
import argparse
import requests
from flask import Flask, request, render_template
from midict import MIDict
import json

from common.encoding import bytes_to_json, json_to_bytes
Expand Down Expand Up @@ -201,10 +199,11 @@ def forward_upstream(self, message, colour):
# for the tracker
if "FSID" in decoded_payload:
return self.transmit_to_bridge(decoded_payload, colour)
# If we pass here, then we should just forward upstream
elif "type" in decoded_payload:
if decoded_payload["type"] == "teardown":
self.teardown(message["CID"])
# If the message is a teardown message
elif "type" in decoded_payload and decoded_payload["type"] == "teardown":
self.teardown(message["CID"])

# If we pass here, then we should just forward upstream

except (UnicodeDecodeError, json.decoder.JSONDecodeError) as e:
# A decoding exception occurred, just forward upstream
Expand Down
3 changes: 2 additions & 1 deletion tracker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import requests
from random import choice
from flask import Flask, render_template, request, abort
from flask import Flask, render_template, request
from common.network_info import cid_size, get_url, domain_names
from common.encoding import json_to_bytes, bytes_to_json
from crypto.random_bytes import generate_bytes
Expand Down Expand Up @@ -138,5 +138,6 @@ def teardown(self, cid):
for file in to_be_removed:
del self.files[file]


tracker = Tracker()
tracker.run(host='0.0.0.0', use_reloader=False)

0 comments on commit 69b0f56

Please sign in to comment.