Few misc changes
This commit is contained in:
parent
9c2acb7099
commit
4ec3d037e9
@ -74,6 +74,10 @@ class OnionrCommunicate:
|
|||||||
# Loads in and starts the enabled plugins
|
# Loads in and starts the enabled plugins
|
||||||
plugins.reload()
|
plugins.reload()
|
||||||
|
|
||||||
|
# Print nice header thing :)
|
||||||
|
if config.get('display_header', True):
|
||||||
|
self.header()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
command = self._core.daemonQueue()
|
command = self._core.daemonQueue()
|
||||||
# Process blocks based on a timer
|
# Process blocks based on a timer
|
||||||
@ -754,6 +758,13 @@ class OnionrCommunicate:
|
|||||||
pass
|
pass
|
||||||
return False
|
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
|
shouldRun = False
|
||||||
debug = True
|
debug = True
|
||||||
developmentMode = False
|
developmentMode = False
|
||||||
|
@ -110,7 +110,8 @@ class Core:
|
|||||||
'''
|
'''
|
||||||
Add an address to the address database (only tor currently)
|
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
|
return False
|
||||||
if self._utils.validateID(address):
|
if self._utils.validateID(address):
|
||||||
conn = sqlite3.connect(self.addressDB)
|
conn = sqlite3.connect(self.addressDB)
|
||||||
@ -138,6 +139,7 @@ class Core:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
logger.debug('Invalid ID')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def removeAddress(self, address):
|
def removeAddress(self, address):
|
||||||
@ -688,11 +690,11 @@ class Core:
|
|||||||
data = data.encode()
|
data = data.encode()
|
||||||
|
|
||||||
retData = ''
|
retData = ''
|
||||||
|
|
||||||
metadata['type'] = header
|
metadata['type'] = header
|
||||||
metadata['powHash'] = powHash
|
metadata['powHash'] = powHash
|
||||||
metadata['powToken'] = powToken
|
metadata['powToken'] = powToken
|
||||||
|
|
||||||
sig = {}
|
sig = {}
|
||||||
|
|
||||||
metadata = json.dumps(metadata)
|
metadata = json.dumps(metadata)
|
||||||
|
@ -611,13 +611,13 @@ class Onionr:
|
|||||||
|
|
||||||
# generate stats table
|
# generate stats table
|
||||||
logger.info(colors['title'] + 'Onionr v%s Statistics' % ONIONR_VERSION + colors['reset'])
|
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():
|
for key, val in messages.items():
|
||||||
if not (type(val) is bool and val is True):
|
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:
|
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:
|
except Exception as e:
|
||||||
logger.error('Failed to generate statistics table.', error = e, timestamp = False)
|
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?')
|
logger.warn('That file does not exist. Improper path?')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(filename, 'rb') as file:
|
blockhash = Block.createChain(file = filename)
|
||||||
contents = file.read().decode()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not contents is None:
|
|
||||||
blockhash = Block('bin', contents).save()
|
|
||||||
logger.info('File %s saved in block %s.' % (filename, blockhash))
|
logger.info('File %s saved in block %s.' % (filename, blockhash))
|
||||||
else:
|
except:
|
||||||
logger.error('Failed to save file in block.', timestamp = False)
|
logger.error('Failed to save file in block.', timestamp = False)
|
||||||
else:
|
else:
|
||||||
logger.error('%s add-file <filename>' % sys.argv[0], timestamp = False)
|
logger.error('%s add-file <filename>' % sys.argv[0], timestamp = False)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"devmode": true,
|
"devmode": true,
|
||||||
"dc_response": true,
|
"dc_response": true,
|
||||||
|
|
||||||
|
"display_header" : true,
|
||||||
"log": {
|
"log": {
|
||||||
"file": {
|
"file": {
|
||||||
"output": true,
|
"output": true,
|
||||||
@ -13,6 +14,7 @@
|
|||||||
"color": true
|
"color": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"i2p":{
|
"i2p":{
|
||||||
"host": false,
|
"host": false,
|
||||||
"connect": true,
|
"connect": true,
|
||||||
|
25
onionr/static-data/header.txt
Normal file
25
onionr/static-data/header.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
# '
|
||||||
|
# ''
|
||||||
|
# :'' '
|
||||||
|
# ''''''
|
||||||
|
# :;''''':
|
||||||
|
# ::;'''::
|
||||||
|
# :::;;:::
|
||||||
|
# ::::::::
|
||||||
|
# ::::::::::::
|
||||||
|
# :::::::::::::::
|
||||||
|
# ::::: :::::
|
||||||
|
# ::::: :::::::: ::::
|
||||||
|
# ::: :::::: ::::::: :::: $:::::: :: :: :: ::::: ::: :: ::::::
|
||||||
|
# ::: :::: :::: ::::: ::: $:: :: ::: :: :: :: :: :::: :: :: ::
|
||||||
|
# ::: ::::: :::::: :::: :::: $:: :: :::::: :: :: :: :::: :: :: ::
|
||||||
|
# ::: :::: ::::::: :::: :::: $:: :: :: ::: :: :: :: :: :::: :::::
|
||||||
|
# ::: ::::: :::::: :::: :::: $:: :: :: ::: :: :: :: :: ::: :: :::
|
||||||
|
# :::: ::::: ::::: ::: $ :::: :: :: :: ::::: :: :: :: ::
|
||||||
|
# :::: :::::: :::::: ::::
|
||||||
|
# :::: :::::::::::: ::::
|
||||||
|
# ::::: :::::::: ::::
|
||||||
|
# ::::: ::::::
|
||||||
|
# ::::::::::::::::
|
||||||
|
# :::::::
|
Loading…
Reference in New Issue
Block a user