Skip to content

Commit

Permalink
Change versioning system to comply with PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Jun 26, 2016
1 parent efea3d5 commit 1c1a6f8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
6 changes: 4 additions & 2 deletions js_src/p2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions py_src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`)
Expand Down
11 changes: 5 additions & 6 deletions py_src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,\
Expand All @@ -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"]

Expand Down
8 changes: 5 additions & 3 deletions py_src/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion py_src/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
'Programming Language :: JavaScript',
'Operating System :: OS Independent',
'Topic :: Communications',
'Topic :: Internet'])
'Topic :: Internet'])

0 comments on commit 1c1a6f8

Please sign in to comment.