|
58 | 58 | PORT = 6666 |
59 | 59 | """Default GraphServ port""" |
60 | 60 |
|
61 | | -CLIENT_PROTOCOL_VERSION = 3 |
62 | | -"""Expected GraphServ protocol version. If GraphServ (resp. GraphCore) |
63 | | - reports a different protocol version, the conenction will be aborted.""" |
| 61 | +CLIENT_PROTOCOL_VERSION = 4 |
| 62 | +"""Implemented GraphServ protocol version. May be used to determin which |
| 63 | + features are supported. Is not used to validate the peer's protocol version, |
| 64 | + see MIN_PROTOCOL_VERSION and MAX_PROTOCOL_VERSION for that.""" |
| 65 | + |
| 66 | +MIN_PROTOCOL_VERSION = 2.0 |
| 67 | +"""Minimum GraphServ protocol version. If GraphServ (resp. GraphCore) |
| 68 | + reports a lower protocol version, the connection will be aborted.""" |
| 69 | + |
| 70 | +MAX_PROTOCOL_VERSION = 4.99 |
| 71 | +"""Maximum GraphServ protocol version. If GraphServ (resp. GraphCore) |
| 72 | + reports a higher protocol version, the connection will be aborted.""" |
64 | 73 |
|
65 | 74 |
|
66 | 75 | def __function__ (shift = 1): #XXX: wtf? |
@@ -1283,23 +1292,34 @@ def setDebug(self, debug): #OK |
1283 | 1292 |
|
1284 | 1293 | def getProtocolVersion(self): |
1285 | 1294 | """Return the protocol version reported by the peer.""" |
1286 | | - self.protocol_version() |
1287 | | - version = self.statusMessage.strip() |
1288 | | - return version |
| 1295 | + |
| 1296 | + if not _protocol_version: |
| 1297 | + self.protocol_version() |
| 1298 | + _protocol_version = self.statusMessage.strip() |
| 1299 | + |
| 1300 | + return self._protocol_version |
1289 | 1301 |
|
1290 | 1302 |
|
1291 | 1303 | def checkProtocolVersion(self): |
1292 | 1304 | """Can raise a gpProtocolException. |
1293 | 1305 |
|
1294 | 1306 | It raises a gpProtocolException if the protocol version reported by the |
1295 | | - peer is not compatible with CLIENT_PROTOCOL_VERSION. |
| 1307 | + peer is not compatible with MIN_PROTOCOL_VERSION and MAX_PROTOCOL_VERSION. |
1296 | 1308 | |
1297 | 1309 | """ |
1298 | 1310 | version = self.getProtocolVersion() |
1299 | | - if int(version) != int(CLIENT_PROTOCOL_VERSION): |
| 1311 | + version = float(version) |
| 1312 | + |
| 1313 | + if version < MIN_PROTOCOL_VERSION: |
| 1314 | + raise gpProtocolException( |
| 1315 | + "Bad protocol version: expected at least " |
| 1316 | + + str(MIN_PROTOCOL_VERSION) |
| 1317 | + + ", but peer uses %s" % str(version) ) |
| 1318 | + |
| 1319 | + if version > MAX_PROTOCOL_VERSION: |
1300 | 1320 | raise gpProtocolException( |
1301 | | - "Bad protocol version: expected " |
1302 | | - + str(CLIENT_PROTOCOL_VERSION) |
| 1321 | + "Bad protocol version: expected at most " |
| 1322 | + + str(MAX_PROTOCOL_VERSION) |
1303 | 1323 | + ", but peer uses %s" % str(version) ) |
1304 | 1324 |
|
1305 | 1325 |
|
|
0 commit comments