diff --git a/squeaknode/server/app.py b/squeaknode/server/app.py index 891eda3e..0fe6b88b 100644 --- a/squeaknode/server/app.py +++ b/squeaknode/server/app.py @@ -77,8 +77,9 @@ def create_app(handler): @app.route('/offer/') def offer(hash): client_host = request.remote_addr + client_port = request.environ.get('REMOTE_PORT') or 0 try: - offer = handler.handle_get_offer(hash, client_host) + offer = handler.handle_get_offer(hash, client_host, client_port) except NotFoundError: return "Not found", 404 return jsonify({ diff --git a/squeaknode/server/squeak_peer_server_handler.py b/squeaknode/server/squeak_peer_server_handler.py index e0adfd87..f66543a4 100644 --- a/squeaknode/server/squeak_peer_server_handler.py +++ b/squeaknode/server/squeak_peer_server_handler.py @@ -75,12 +75,12 @@ class SqueakPeerServerHandler(object): raise NotFoundError() return secret_key - def handle_get_offer(self, squeak_hash_str, client_host) -> Offer: + def handle_get_offer(self, squeak_hash_str, client_host, client_port) -> Offer: squeak_hash = bytes.fromhex(squeak_hash_str) client_addr = PeerAddress( network=Network.IPV4, host=client_host, - port=0, + port=client_port, ) offer = self.squeak_controller.get_packaged_offer( squeak_hash,