rehabilitate socket server

This commit is contained in:
nolash 2021-10-15 22:40:22 +02:00
parent 7f113d1cdc
commit 760ff71632
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
8 changed files with 17 additions and 14 deletions

View File

@ -1 +1 @@
include *requirements* include *requirements* funga/eth/data/config/**

0
README Normal file
View File

View File

@ -5,7 +5,7 @@ import socket
import stat import stat
# local imports # local imports
from crypto_dev_signer.error import SignerError from funga.error import SignerError
from .handle import SignRequestHandler from .handle import SignRequestHandler
logg = logging.getLogger(__name__) logg = logging.getLogger(__name__)

View File

@ -140,7 +140,6 @@ def from_dict(o, passphrase=''):
pk = m(ciphertext_bytes, decryption_key[:16], iv) pk = m(ciphertext_bytes, decryption_key[:16], iv)
except AssertionError as e: except AssertionError as e:
raise DecryptError('could not decrypt keyfile: {}'.format(e)) raise DecryptError('could not decrypt keyfile: {}'.format(e))
logg.debug('bar')
return pk return pk

View File

@ -12,14 +12,16 @@ import confini
from jsonrpc.exceptions import * from jsonrpc.exceptions import *
# local imports # local imports
from crypto_dev_signer.eth.signer import ReferenceSigner from funga.eth.signer import EIP155Signer
from crypto_dev_signer.keystore.reference import ReferenceKeystore from funga.eth.keystore.sql import SQLKeystore
from crypto_dev_signer.cli.handle import SignRequestHandler from funga.eth.cli.handle import SignRequestHandler
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger() logg = logging.getLogger()
config_dir = '.' script_dir = os.path.dirname(os.path.realpath(__file__))
data_dir = os.path.join(script_dir, '..', 'data')
config_dir = os.path.join(data_dir, 'config')
db = None db = None
signer = None signer = None
@ -27,6 +29,7 @@ session = None
chainId = 8995 chainId = 8995
socket_path = '/run/crypto-dev-signer/jsonrpc.ipc' socket_path = '/run/crypto-dev-signer/jsonrpc.ipc'
argparser = argparse.ArgumentParser() argparser = argparse.ArgumentParser()
argparser.add_argument('-c', type=str, default=config_dir, help='config file') argparser.add_argument('-c', type=str, default=config_dir, help='config file')
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration') argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
@ -85,8 +88,8 @@ def main():
kw = { kw = {
'symmetric_key': secret, 'symmetric_key': secret,
} }
SignRequestHandler.keystore = ReferenceKeystore(dsn, **kw) SignRequestHandler.keystore = SQLKeystore(dsn, **kw)
SignRequestHandler.signer = ReferenceSigner(SignRequestHandler.keystore) SignRequestHandler.signer = EIP155Signer(SignRequestHandler.keystore)
arg = None arg = None
try: try:
@ -97,19 +100,19 @@ def main():
if socket_url.scheme != '': if socket_url.scheme != '':
scheme = socket_url.scheme scheme = socket_url.scheme
if re.match(re_tcp, socket_url.scheme): if re.match(re_tcp, socket_url.scheme):
from crypto_dev_signer.cli.socket import start_server_tcp from funga.eth.cli.socket import start_server_tcp
socket_spec = socket_url.netloc.split(':') socket_spec = socket_url.netloc.split(':')
host = socket_spec[0] host = socket_spec[0]
port = int(socket_spec[1]) port = int(socket_spec[1])
start_server_tcp((host, port)) start_server_tcp((host, port))
elif re.match(re_http, socket_url.scheme): elif re.match(re_http, socket_url.scheme):
from crypto_dev_signer.cli.http import start_server_http from funga.eth.cli.http import start_server_http
socket_spec = socket_url.netloc.split(':') socket_spec = socket_url.netloc.split(':')
host = socket_spec[0] host = socket_spec[0]
port = int(socket_spec[1]) port = int(socket_spec[1])
start_server_http((host, port)) start_server_http((host, port))
else: else:
from crypto_dev_signer.cli.socket import start_server_unix from funga.eth.cli.socket import start_server_unix
start_server_unix(socket_url.path) start_server_unix(socket_url.path)
sys.exit(0) sys.exit(0)

View File

@ -1,6 +1,6 @@
from setuptools import setup from setuptools import setup
f = open('README.md', 'r') f = open('README', 'r')
long_description = f.read() long_description = f.read()
f.close() f.close()
@ -33,7 +33,7 @@ f.close()
setup( setup(
name="funga-eth", name="funga-eth",
version="0.5.1a1", version="0.5.1a2",
description="Ethereum implementation of the funga keystore and signer", description="Ethereum implementation of the funga keystore and signer",
author="Louis Holbrook", author="Louis Holbrook",
author_email="dev@holbrook.no", author_email="dev@holbrook.no",
@ -58,4 +58,5 @@ setup(
], ],
}, },
url='https://gitlab.com/chaintool/funga-eth', url='https://gitlab.com/chaintool/funga-eth',
include_package_data=True,
) )