mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-18 13:09:08 +02:00
Use real port for peer get offer request (#2213)
* Use real port number for peer in saved sent offer * Fix get remote client port
This commit is contained in:
parent
0c0ce30006
commit
163837a7bc
2 changed files with 4 additions and 3 deletions
|
|
@ -77,8 +77,9 @@ def create_app(handler):
|
|||
@app.route('/offer/<hash>')
|
||||
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({
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue