Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.

Commit

Permalink
Add peer_addr param
Browse files Browse the repository at this point in the history
  • Loading branch information
whtsky committed Aug 15, 2016
1 parent 7d8cf7d commit f15506c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
12 changes: 9 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Usage
logging.info(addr)
logging.info(infohash)
async def handle_announce_peer(self, infohash, addr):
async def handle_announce_peer(self, infohash, addr, peer_addr):
logging.info(addr)
logging.info(infohash)
Expand All @@ -40,8 +40,14 @@ Usage
ChangeLog
----------

Version 3.0.0
~~~~~~~~~~~~~~~

+ Add `peer_addr` param to `handle_announce_peer` method.
+ Don't raise NotImplementedError on `handler`

Version 2.0.0
~~~~~~~~~~~~~~~

+ Add `handle_get_peers`, `handle_announce_peer` function.
+ Add `addr` param in `handler`
+ Add `handle_get_peers`, `handle_announce_peer` method.
+ Add `addr` param to `handler`
13 changes: 9 additions & 4 deletions maga.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def split_nodes(nodes):
yield nid, ip, port


__version__ = '2.0.0'
__version__ = '3.0.0'


BOOTSTRAP_NODES = (
Expand Down Expand Up @@ -146,7 +146,12 @@ async def handle_query(self, msg, addr):
"id": self.fake_node_id(node_id)
}
}, addr=addr)
await self.handle_announce_peer(proper_infohash(infohash), addr)
peer_addr = [addr[0], addr[1]]
try:
peer_addr[1] = args[b"port"]
except KeyError:
pass
await self.handle_announce_peer(proper_infohash(infohash), addr, peer_addr)
elif query_type == b"find_node":
tid = msg[b"t"]
self.send_message({
Expand Down Expand Up @@ -209,8 +214,8 @@ def find_node(self, addr, node_id=None, target=None):
async def handle_get_peers(self, infohash, addr):
await self.handler(infohash, addr)

async def handle_announce_peer(self, infohash, addr):
async def handle_announce_peer(self, infohash, addr, peer_addr):
await self.handler(infohash, addr)

async def handler(self, infohash, addr):
raise NotImplementedError()
pass
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='Maga',
version='2.0.1',
version='3.0.0',
description='A DHT crawler framework using asyncio.',
long_description=open('README.rst', 'r').read(),
author='whtsky',
Expand All @@ -20,7 +20,6 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Cython',
'Programming Language :: Python',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: Implementation :: CPython',
Expand Down

0 comments on commit f15506c

Please sign in to comment.