diff --git a/protocol.md b/protocol.md --- a/protocol.md +++ b/protocol.md @@ -1,6 +1,6 @@ # Protocol # -[Communication protocol proposal. Not yet fully implemented and expected to change.] +[Communication protocol proposal. Not yet fully implemented and still expected to change.] Nodes communicate by exchanging messages through network sockets. Basic message format is simple: @@ -19,7 +19,7 @@ The client sends a request (a message) a Initiates communication between the client and the server. Checks that the nodes can meaningfully talk to each other. #### Params #### -- (str) version: program version. Both the client and the server are to check for compatibility with their partner. +- [(int) major, (int) minor, (int) tiny] version version: program version. Both the client and the server are to check for compatibility with their partner. - {push, pull} action: what the client desires to do - (str) filename: name of the file to be synchronized - (int) blockSize @@ -74,7 +74,7 @@ Cease talking and close the connection. See [the init command](#init). If the client doesn't like server's protocol version, it is free to [end](#end) the connection. #### Params #### -- (str) version +- [(int) major, (int) minor, (int) tiny] version ### deny ### @@ -82,6 +82,7 @@ The server refuses connection. It might #### Params #### - (int) retry: suggested delay in seconds before another attempt at connection +- (int) status - (str) msg diff --git a/src/client.py b/src/client.py --- a/src/client.py +++ b/src/client.py @@ -5,10 +5,11 @@ import logging as log from datetime import datetime import config as conf +import status import stats from util import Progress from hashtree import HashTree,hashBlock -from netnode import BaseConnection,NetNode,FailedConnection,LockedException +from netnode import BaseConnection,NetNode,FailedConnection,LockedException,IncompatibleException class DeniedConnection(Exception): pass @@ -50,8 +51,12 @@ class Client(NetNode): self._outcoming.writeMsg(jsonData) jsonData,binData=self._incoming.readMsg() if jsonData["command"]=="deny": + if jsonData["status"]==status.incompatible.version: + raise DeniedConnection("Incompatible client version. Consider upgrading it.") raise DeniedConnection() assert jsonData["command"]=="init" + if jsonData["version"]