mirror of https://github.com/oxen-io/lokinet
get rid of wizard and autogenerate configs if not present with sane defaults
parent
976ca3015c
commit
48cfdab63c
@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
root=$(dirname $(realpath -L $0))
|
||||
|
||||
if [ ! -d v ] ; then
|
||||
echo "setting up wizard for the first time..."
|
||||
python3 -m venv v && v/bin/pip install -r "$root/requirements.txt" &> /dev/null || echo "failed"
|
||||
fi
|
||||
v/bin/python "$root/lokinet.py" $@
|
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
from configparser import ConfigParser as Config
|
||||
import netifaces
|
||||
import ipaddress
|
||||
import os
|
||||
|
||||
def yield_public_addresses():
|
||||
for ifname in netifaces.interfaces():
|
||||
addrs = netifaces.ifaddresses(ifname)
|
||||
if netifaces.AF_INET in addrs:
|
||||
for addr in addrs[netifaces.AF_INET]:
|
||||
ip = addr['addr']
|
||||
if not ipaddress.ip_address(ip).is_private:
|
||||
yield ifname, ip
|
||||
|
||||
def genconf(rootdir):
|
||||
conf = Config()
|
||||
conf['router'] = {
|
||||
'threads': '2',
|
||||
'net-threads': '1',
|
||||
'contact-file': os.path.join(rootdir, 'self.signed'),
|
||||
'transport-privkey': os.path.join(rootdir, 'transport.key'),
|
||||
'identity-privkey': os.path.join(rootdir, 'identity.key')
|
||||
}
|
||||
conf['netdb'] = {
|
||||
'dir': os.path.join(rootdir, 'netdb')
|
||||
}
|
||||
conf['bind'] = {}
|
||||
found = False
|
||||
for ifname, ip in yield_public_addresses():
|
||||
conf['bind'][ifname] = '1090'
|
||||
print("using public address {}".format(ip))
|
||||
break
|
||||
else:
|
||||
print("This machine has no public network addresses")
|
||||
return conf
|
||||
|
||||
def main(args):
|
||||
fname = 'daemon.ini'
|
||||
if len(args) == 1:
|
||||
fname = args[0]
|
||||
conf = genconf(os.path.realpath('.'))
|
||||
if conf:
|
||||
with open(fname, 'w') as f:
|
||||
conf.write(f)
|
||||
print("wrote config to {}".format(fname))
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
main(sys.argv[1:])
|
||||
|
@ -1 +0,0 @@
|
||||
netifaces==0.10.7
|
Loading…
Reference in New Issue