diff --git a/js_src/p2p.js b/js_src/p2p.js index 7c98a55..b5c70b3 100644 --- a/js_src/p2p.js +++ b/js_src/p2p.js @@ -13,8 +13,10 @@ function p2p() { }; } - m.version = "0.2.1"; - m.build_num = "build.135" + var protocol_version = "0.2"; + var node_policy_version = "136"; + + version = [protocol_version, node_policy_version].join('.'); m.compression = ['gzip']; // User salt generation pulled from: http://stackoverflow.com/a/2117523 diff --git a/py_src/README.md b/py_src/README.md index 97c8a59..5b5f3c0 100644 --- a/py_src/README.md +++ b/py_src/README.md @@ -4,10 +4,10 @@ ## Constants -* `version`: A string containing the major, minor, and patch release number. This version refers to the underlying protocol. -* `build_num`: The build number associated with this version. This refers to the node and its policies. -* `__version__`: A string containing both `version` and `build_num` separated by a `"+"`. This is guarunteed to be unique. +* `__version__`: A string containing the major, minor, and patch release number. This version refers to the underlying protocol. * `version_info`: A `tuple` version of the above +* `protocol_version`: A string containing the major and minor release number. This refers to the underlying protocol +* `node_policy_version`: A string containing the build number associated with this version. This refers to the node and its policies. * `uses_RSA`: This value says whether it is using the underlying `rsa` module. If `None`, it means neither `rsa` nor any of its fallbacks could be imported. Currently `False` means it relies on `PyCrypto`, and `True` means it relies on `rsa`. * `if uses_RSA is not None` * `decryption_error`: The error a call to `decrypt` will throw if decryption of a given ciphertext fails @@ -36,7 +36,8 @@ This is used mostly for inheriting common functions with [`mesh.py`](#meshpy) an ## Constants * `version`: A string containing the major, minor, and patch release number. This version refers to the underlying protocol. -* `build_num`: The build number associated with this version. This refers to the node and its policies. +* `protocol_version`: A string containing the major and minor release number. This refers to the underlying protocol +* `node_policy_version`: A string containing the build number associated with this version. This refers to the node and its policies. * `user_salt`: A `uuid4` which is generated uniquely in each running instance * `compression`: A `list` of the compression methods your instance supports * `default_protocol`: The default [`protocol`](#protocol) definition. This uses an empty string as the subnet and `PKCS1_v1.5` encryption, as supplied by [`net.py`](#netpy) (in alpha releases this will use `Plaintext`) diff --git a/py_src/__init__.py b/py_src/__init__.py index 03df76a..b32f1df 100644 --- a/py_src/__init__.py +++ b/py_src/__init__.py @@ -6,9 +6,9 @@ Constants - * version: A string containing the major, minor, and patch release number. This version refers to the underlying protocol. - * build_num: The build number associated with this version. This refers to the node and its policies. - * __version__: A string containing both version and build_num separated by a "+". This is guarunteed to be unique. + * __version__: A string containing the major, minor, and patch release number. + * protocol_version: A string containing the major and minor release number. This refers to the underlying protocol + * node_policy_version: A string containing the build number associated with this version. This refers to the node and its policies. * version_info: A tuple version of the above * uses_RSA: This value says whether it is using the underlying rsa module. If None, it means neither rsa nor any of its fallbacks could be imported. Currently False means it relies on PyCrypto, and True means it relies on rsa. @@ -48,7 +48,7 @@ from .mesh import mesh_socket # from .chord import chord_socket -from .base import version, build_num +from .base import version as __version__ try: from .net import uses_RSA, decryption_error, verification_error, newkeys,\ @@ -58,8 +58,7 @@ warnings.warn("Could not import encrypted socket module. Please install rsa from pip.", ImportWarning) uses_RSA = None -__version__ = version + "+" + build_num -version_info = tuple(map(int, version.split("."))) + (build_num.split('.')[0],) + tuple(map(int, build_num.split('.')[1:])) +version_info = tuple(map(int, __version__.split("."))) __all__ = ["mesh", "chord", "base"] diff --git a/py_src/base.py b/py_src/base.py index 4d0f0ff..54f6ad8 100644 --- a/py_src/base.py +++ b/py_src/base.py @@ -4,8 +4,10 @@ import bz2, hashlib, json, select, socket, struct, time, threading, traceback, uuid, zlib from collections import namedtuple, deque -version = "0.2.1" -build_num = "build.135" +protocol_version = "0.2" +node_policy_version = "136" + +version = '.'.join([protocol_version, node_policy_version]) class flags(): """A namespace to hold protocol-defined flags""" @@ -120,7 +122,7 @@ class protocol(namedtuple("protocol", ['subnet', 'encryption'])): """Defines service variables so that you can reject connections looking for a different service""" @property def id(self): - h = hashlib.sha256(''.join([str(x) for x in self] + [version]).encode()) + h = hashlib.sha256(''.join([str(x) for x in self] + [protocol_version]).encode()) return to_base_58(int(h.hexdigest(), 16)) default_protocol = protocol('', "Plaintext") # PKCS1_v1.5") diff --git a/py_src/test/test_base.py b/py_src/test/test_base.py index d5ccc3d..4849c3f 100644 --- a/py_src/test/test_base.py +++ b/py_src/test/test_base.py @@ -145,7 +145,7 @@ def test_protocol(iters=200): test = base.protocol(sub, enc) assert test.subnet == test[0] == sub assert test.encryption == test[1] == enc - p_hash = hashlib.sha256(''.join([sub, enc, base.version]).encode()) + p_hash = hashlib.sha256(''.join([sub, enc, base.protocol_version]).encode()) assert int(p_hash.hexdigest(), 16) == base.from_base_58(test.id) def test_message_sans_network(iters=1000): diff --git a/setup.py b/setup.py index 0e372cc..0ce2b1d 100644 --- a/setup.py +++ b/setup.py @@ -25,4 +25,4 @@ 'Programming Language :: JavaScript', 'Operating System :: OS Independent', 'Topic :: Communications', - 'Topic :: Internet']) + 'Topic :: Internet']) \ No newline at end of file