bug: Fix documentation compile and config dumps #2

Merged
lash merged 21 commits from lash/docs-and-dumps into master 2021-12-21 16:00:02 +01:00
6 changed files with 28 additions and 6 deletions
Showing only changes of commit becd6744f6 - Show all commits

View File

@ -1,4 +1,6 @@
- 0.0.5-pending - 0.0.14
* Add option to skip ssl verification on rpc
- 0.0.5
* Move eth code to separate package * Move eth code to separate package
- 0.0.4-unreleased - 0.0.4-unreleased
* Add pack tx from already signed tx struct * Add pack tx from already signed tx struct

View File

@ -186,10 +186,17 @@ class ChainSpec:
return r return r
def __str__(self): def as_string(self, skip_optional=False):
s = '{}:{}:{}'.format(self.o['arch'], self.o['fork'], self.o['network_id']) s = '{}:{}:{}'.format(self.o['arch'], self.o['fork'], self.o['network_id'])
if skip_optional:
return s
if self.o.get('common_name'): if self.o.get('common_name'):
s += ':' + self.o['common_name'] s += ':' + self.o['common_name']
if self.o.get('custom'): if self.o.get('custom'):
s += ':' + ':'.join(self.o['custom']) s += ':' + ':'.join(self.o['custom'])
return s return s
def __str__(self):
return self.as_string()

View File

@ -61,7 +61,7 @@ class Rpc:
self.id_generator = IntSequenceGenerator() self.id_generator = IntSequenceGenerator()
self.chain_spec = config.get('CHAIN_SPEC') self.chain_spec = config.get('CHAIN_SPEC')
self.conn = self.constructor(url=config.get('RPC_PROVIDER'), chain_spec=self.chain_spec, auth=auth) self.conn = self.constructor(url=config.get('RPC_PROVIDER'), chain_spec=self.chain_spec, auth=auth, verify_identity=config.true('RPC_VERIFY'))
return self.conn return self.conn

View File

@ -102,10 +102,13 @@ class RPCConnection:
} }
__constructors_for_chains = {} __constructors_for_chains = {}
def __init__(self, url=None, chain_spec=None, auth=None): def __init__(self, url=None, chain_spec=None, auth=None, verify_identity=True):
self.chain_spec = chain_spec self.chain_spec = chain_spec
self.location = None self.location = None
self.basic = None self.basic = None
self.verify_identity = verify_identity
if not self.verify_identity:
logg.warning('RPC host identity verification is OFF. Beware, you will be easy to cheat')
if url == None: if url == None:
return return
self.auth = auth self.auth = auth
@ -287,6 +290,11 @@ class JSONRPCHTTPConnection(HTTPConnection):
:returns: Result value part of JSON RPC response :returns: Result value part of JSON RPC response
:todo: Invalid response exception from invalid json response :todo: Invalid response exception from invalid json response
""" """
ssl_ctx = None
if not self.verify_identity:
import ssl
ssl_ctx = ssl.SSLContext()
ssl_ctx.verify_mode = ssl.CERT_NONE
req = Request( req = Request(
self.location, self.location,
method='POST', method='POST',
@ -313,7 +321,11 @@ class JSONRPCHTTPConnection(HTTPConnection):
install_opener(ho) install_opener(ho)
try: try:
r = urlopen(req, data=data.encode('utf-8')) r = urlopen(
req,
data=data.encode('utf-8'),
context=ssl_ctx,
)
except URLError as e: except URLError as e:
raise RPCException(e) raise RPCException(e)

View File

@ -4,6 +4,7 @@ auth =
credentials = credentials =
dialect = default dialect = default
scheme = http scheme = http
verify = 1
[chain] [chain]
spec = spec =

View File

@ -6,7 +6,7 @@ name=chainlib
license=WTFPL2 license=WTFPL2
author_email=dev@holbrook.no author_email=dev@holbrook.no
description=Generic blockchain access library and tooling description=Generic blockchain access library and tooling
version=0.0.12 version=0.0.14
url=https://gitlab.com/chaintools/chainlib url=https://gitlab.com/chaintools/chainlib
author=Louis Holbrook author=Louis Holbrook