Changeset 189303090586c95b7df7c6dd0b9bcdb8eab2e5a8
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rc27409d
|
r1893030
|
|
| 73 | 73 | self.socket = None |
| 74 | 74 | def protocol_extensions(self): |
| 75 | | """Anomos puts [1:nid][6:null char] into the |
| | 75 | """Anomos puts [2:nid][6:null char] into the |
| 76 | 76 | BitTorrent reserved header bytes""" |
| 77 | | return self.id + '\0\0\0\0\0\0' |
| | 77 | return self.id + '\0'*HDR_EXT_LEN |
| 78 | 78 | def write_header(self): |
| 79 | 79 | """Return properly formatted Anomos connection header |
-
|
rc27409d
|
r1893030
|
|
| 57 | 57 | if self.nid_collision(id, loc): |
| 58 | 58 | # 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)) |
| 60 | 60 | # To be safe, kill connection with the neighbor we already |
| 61 | 61 | # had with the requested ID and add ID to the failed list |
-
|
rc27409d
|
r1893030
|
|
| 33 | 33 | state = "init" |
| 34 | 34 | nid = NAT_CHECK_ID |
| 35 | | protocol_extensions = '\0'*6 |
| | 35 | protocol_extensions = '\0'*HDR_EXT_LEN |
| 36 | 36 | expecting = 1 |
| 37 | 37 | msgbuf = "" |
-
|
rc27409d
|
r1893030
|
|
| 144 | 144 | |
| 145 | 145 | def fnid(nid, stream=None): |
| 146 | | if stream: |
| | 146 | if stream is not None: |
| 147 | 147 | return "[%s:%04x]" % (b2a_hex(nid), stream) |
| 148 | 148 | return "[%s]" % b2a_hex(nid) |
-
|
rc27409d
|
r1893030
|
|
| 18 | 18 | from types import IntType, LongType, StringType, DictType |
| 19 | 19 | from Anomos import BTFailure |
| | 20 | from Anomos.Protocol import HDR_NID_LEN |
| 20 | 21 | |
| 21 | 22 | allowed_path_re = re.compile(r'^[^/\\.~][^/\\]*$') |
| … |
… |
|
| 108 | 109 | if p.has_key('nid'): |
| 109 | 110 | nid = p.get('nid') |
| 110 | | if type(nid) != str or len(nid) != 2: |
| | 111 | if type(nid) != str or len(nid) != HDR_NID_LEN: |
| 111 | 112 | raise BTFailure('invalid entry in peer list') |
| 112 | 113 | #PeerID only used in BitTorrent |