Changeset 189303090586c95b7df7c6dd0b9bcdb8eab2e5a8

Show
Ignore:
Timestamp:
07/02/10 00:26:44 (2 months ago)
Author:
John M. Schanck <john@…>
git-author:
John M. Schanck <john@anomos.info> / 2010-06-23T20:58:37Z-0400
Parents:
c27409d8add39f283ce96c098e8dc42758cc8436
Children:
18f4d42d3f06fb320182ac13cfe640fa240648c9
git-committer:
John M. Schanck <john@anomos.info> / 2010-07-01T20:26:44Z-0400
Message:

couple more 2-byte nid corrections

Location:
Anomos
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • Anomos/AnomosNeighborInitializer.py

    rc27409d r1893030  
    7373        self.socket = None 
    7474    def protocol_extensions(self): 
    75         """Anomos puts [1:nid][6:null char] into the 
     75        """Anomos puts [2:nid][6:null char] into the 
    7676           BitTorrent reserved header bytes""" 
    77         return self.id + '\0\0\0\0\0\0' 
     77        return self.id + '\0'*HDR_EXT_LEN 
    7878    def write_header(self): 
    7979        """Return properly formatted Anomos connection header 
  • Anomos/NeighborManager.py

    rc27409d r1893030  
    5757            if self.nid_collision(id, loc): 
    5858                # Already had neighbor by the given id at a different location 
    59                 log.warning('NID collision - [%s]' % fnid(id)) 
     59                log.warning('NID collision - %s' % fnid(id)) 
    6060                # To be safe, kill connection with the neighbor we already 
    6161                # had with the requested ID and add ID to the failed list 
  • Anomos/TwistedNatCheck.py

    rc27409d r1893030  
    3333    state = "init" 
    3434    nid = NAT_CHECK_ID 
    35     protocol_extensions = '\0'*6 
     35    protocol_extensions = '\0'*HDR_EXT_LEN 
    3636    expecting = 1 
    3737    msgbuf = "" 
  • Anomos/__init__.py

    rc27409d r1893030  
    144144 
    145145def fnid(nid, stream=None): 
    146     if stream: 
     146    if stream is not None: 
    147147        return "[%s:%04x]" % (b2a_hex(nid), stream) 
    148148    return "[%s]" % b2a_hex(nid) 
  • Anomos/btformats.py

    rc27409d r1893030  
    1818from types import IntType, LongType, StringType, DictType 
    1919from Anomos import BTFailure 
     20from Anomos.Protocol import HDR_NID_LEN 
    2021 
    2122allowed_path_re = re.compile(r'^[^/\\.~][^/\\]*$') 
     
    108109        if p.has_key('nid'): 
    109110            nid = p.get('nid') 
    110             if type(nid) != str or len(nid) != 2: 
     111            if type(nid) != str or len(nid) != HDR_NID_LEN: 
    111112                raise BTFailure('invalid entry in peer list') 
    112113        #PeerID only used in BitTorrent