mirror of https://github.com/oxen-io/lokinet
more
This commit is contained in:
parent
c69d4e7389
commit
a1596e3604
|
@ -12,6 +12,8 @@ import os
|
|||
import sys
|
||||
import requests
|
||||
|
||||
from pylokinet import rc
|
||||
|
||||
lib_file = os.path.join(os.path.realpath('.'), 'liblokinet-shared.so')
|
||||
|
||||
|
||||
|
@ -30,6 +32,8 @@ class LokiNET(threading.Thread):
|
|||
|
||||
def configure(self, lib, conf, ip=None, port=None, ifname=None):
|
||||
log("configure lib={} conf={}".format(lib, conf))
|
||||
if not os.path.exists(os.path.dirname(conf)):
|
||||
os.mkdir(os.path.dirname(conf))
|
||||
try:
|
||||
self.lib = CDLL(lib)
|
||||
except OSError as ex:
|
||||
|
@ -111,6 +115,10 @@ def main(args):
|
|||
print("LOKINET_SUBMIT_URL was not set")
|
||||
return
|
||||
|
||||
bootstrap = getconf("LOKINET_BOOTSTRAP_URL")
|
||||
if bootstrap is None:
|
||||
print("LOKINET_BOOTSTRAP_URL was not set")
|
||||
|
||||
lib = getconf("LOKINET_LIB", lib_file)
|
||||
timeout = int(getconf("LOKINET_TIMEOUT", "5"))
|
||||
ping_interval = int(getconf("LOKINET_PING_INTERVAL", "60"))
|
||||
|
@ -123,8 +131,28 @@ def main(args):
|
|||
return
|
||||
conf = os.path.join(root, "daemon.ini")
|
||||
loki = LokiNET()
|
||||
log("bootstrapping...")
|
||||
try:
|
||||
r = requests.get(bootstrap)
|
||||
if r.status_code == 404:
|
||||
log("bootstrap gave no RCs, we are the seed node")
|
||||
elif r.status_code != 200:
|
||||
raise Exception("http {}".format(r.status_code))
|
||||
else:
|
||||
data = r.content
|
||||
if rc.validate(data):
|
||||
log("valid RC obtained")
|
||||
with open(os.path.join(root, "bootstrap.signed"), "wb") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
raise Exception("invalid RC")
|
||||
except Exception as ex:
|
||||
log("failed to bootstrap: {}".format(ex))
|
||||
loki.close()
|
||||
return
|
||||
if loki.configure(lib, conf, ip, port, ifname):
|
||||
log("configured")
|
||||
|
||||
loki.start()
|
||||
try:
|
||||
log("waiting for spawn")
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# lokinet cluster setup
|
||||
|
||||
clustering lokinet with python 3
|
||||
|
||||
# python3 setup.py install
|
||||
|
||||
## bootserv
|
||||
|
||||
bootserv is a bootstrap server for accepting and serving RCs
|
||||
|
||||
$ gunicorn -b 0.0.0.0:8000 pylokinet.bootserv:app
|
||||
|
||||
## pylokinet instance
|
||||
|
||||
obtain `liblokinet-shared.so` from a lokinet build
|
||||
|
||||
run (root):
|
||||
|
||||
# export LOKINET_LIB=/path/to/liblokinet-shared.so
|
||||
# export LOKINET_BOOTSTRAP_URL=http://bootserv.ip.address.here:8000/bootstrap.signed
|
||||
# export LOKINET_PING_URL=http://bootserv.ip.address.here:8000/ping
|
||||
# export LOKINET_SUBMIT_URL=http://bootserv.ip.address.here:8000/
|
||||
# export LOKINET_IP=public.ip.goes.here
|
||||
# export LOKINET_PORT=1090
|
||||
# export LOKINET_IFNAME=eth0
|
||||
# python3 -m pylokinet.instance
|
|
@ -10,5 +10,5 @@ setup(
|
|||
author_email="jeff@i2p.rocks",
|
||||
description="lokinet python bindings",
|
||||
url="https://github.com/loki-project/loki-network",
|
||||
install_requires=["pysodium"],
|
||||
install_requires=["pysodium", "requests"],
|
||||
packages=find_packages())
|
Loading…
Reference in New Issue