Few misc changes

This commit is contained in:
Arinerron 2018-06-04 22:26:11 -07:00
parent 9c2acb7099
commit 4ec3d037e9
5 changed files with 49 additions and 15 deletions

View File

@ -74,6 +74,10 @@ class OnionrCommunicate:
# Loads in and starts the enabled plugins
plugins.reload()
# Print nice header thing :)
if config.get('display_header', True):
self.header()
while True:
command = self._core.daemonQueue()
# Process blocks based on a timer
@ -754,6 +758,13 @@ class OnionrCommunicate:
pass
return False
def header(self, message = logger.colors.fg.pink + logger.colors.bold + 'Onionr' + logger.colors.reset + logger.colors.fg.pink + ' has started.'):
if os.path.exists('static-data/header.txt'):
with open('static-data/header.txt', 'rb') as file:
# only to stdout, not file or log or anything
print(file.read().decode().replace('#', logger.colors.fg.pink).replace('$', logger.colors.reset + logger.colors.bold).replace('\n', logger.colors.reset + '\n'))
logger.info(logger.colors.fg.lightgreen + '-> ' + str(message) + logger.colors.reset + logger.colors.fg.lightgreen + ' <-\n')
shouldRun = False
debug = True
developmentMode = False

View File

@ -110,7 +110,8 @@ class Core:
'''
Add an address to the address database (only tor currently)
'''
if (not (config.is_set('i2p') and 'ownAddr' in config.get('i2p'))) or address == config.get('i2p')['ownAddr']:
if address == config.get('i2p', {'ownAddr' : None})['ownAddr']:
return False
if self._utils.validateID(address):
conn = sqlite3.connect(self.addressDB)
@ -138,6 +139,7 @@ class Core:
return True
else:
logger.debug('Invalid ID')
return False
def removeAddress(self, address):
@ -688,11 +690,11 @@ class Core:
data = data.encode()
retData = ''
metadata['type'] = header
metadata['powHash'] = powHash
metadata['powToken'] = powToken
sig = {}
metadata = json.dumps(metadata)

View File

@ -611,13 +611,13 @@ class Onionr:
# generate stats table
logger.info(colors['title'] + 'Onionr v%s Statistics' % ONIONR_VERSION + colors['reset'])
logger.info(colors['border'] + '' * (maxlength + 1) + '' + colors['reset'])
logger.info(colors['border'] + '-' * (maxlength + 1) + '+' + colors['reset'])
for key, val in messages.items():
if not (type(val) is bool and val is True):
logger.info(colors['key'] + str(key).rjust(maxlength) + colors['reset'] + colors['border'] + ' ' + colors['reset'] + colors['val'] + str(val) + colors['reset'])
logger.info(colors['key'] + str(key).rjust(maxlength) + colors['reset'] + colors['border'] + ' | ' + colors['reset'] + colors['val'] + str(val) + colors['reset'])
else:
logger.info(colors['border'] + '' * (maxlength + 1) + '' + colors['reset'])
logger.info(colors['border'] + '' * (maxlength + 1) + '' + colors['reset'])
logger.info(colors['border'] + '-' * (maxlength + 1) + '+' + colors['reset'])
logger.info(colors['border'] + '-' * (maxlength + 1) + '+' + colors['reset'])
except Exception as e:
logger.error('Failed to generate statistics table.', error = e, timestamp = False)
@ -664,15 +664,9 @@ class Onionr:
logger.warn('That file does not exist. Improper path?')
try:
with open(filename, 'rb') as file:
contents = file.read().decode()
except:
pass
if not contents is None:
blockhash = Block('bin', contents).save()
blockhash = Block.createChain(file = filename)
logger.info('File %s saved in block %s.' % (filename, blockhash))
else:
except:
logger.error('Failed to save file in block.', timestamp = False)
else:
logger.error('%s add-file <filename>' % sys.argv[0], timestamp = False)

View File

@ -2,6 +2,7 @@
"devmode": true,
"dc_response": true,
"display_header" : true,
"log": {
"file": {
"output": true,
@ -13,6 +14,7 @@
"color": true
}
},
"i2p":{
"host": false,
"connect": true,

View File

@ -0,0 +1,25 @@
# '
# ''
# :'' '
# ''''''
# :;''''':
# ::;'''::
# :::;;:::
# ::::::::
# ::::::::::::
# :::::::::::::::
# ::::: :::::
# ::::: :::::::: ::::
# ::: :::::: ::::::: :::: $:::::: :: :: :: ::::: ::: :: ::::::
# ::: :::: :::: ::::: ::: $:: :: ::: :: :: :: :: :::: :: :: ::
# ::: ::::: :::::: :::: :::: $:: :: :::::: :: :: :: :::: :: :: ::
# ::: :::: ::::::: :::: :::: $:: :: :: ::: :: :: :: :: :::: :::::
# ::: ::::: :::::: :::: :::: $:: :: :: ::: :: :: :: :: ::: :: :::
# :::: ::::: ::::: ::: $ :::: :: :: :: ::::: :: :: :: ::
# :::: :::::: :::::: ::::
# :::: :::::::::::: ::::
# ::::: :::::::: ::::
# ::::: ::::::
# ::::::::::::::::
# :::::::