added timestamp to logger & removed debug prints

This commit is contained in:
Kevin Froman 2018-04-18 12:50:20 -05:00
parent 97baec453c
commit edce30ea20
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 7 additions and 6 deletions

View File

@ -226,11 +226,9 @@ class API:
host = self.host
if hostType == 'private':
if not request.host.startswith('127') and not self._utils.checkIsIP(request.host):
print("WHAT")
abort(403)
elif hostType == 'public':
if not request.host.endswith('onion') and not request.host.endswith('i2p'):
print("WHAT2")
abort(403)
# Validate x-requested-with, to protect against CSRF/metadata leaks
if not self._developmentMode:

View File

@ -18,7 +18,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import re, sys
import re, sys, time
class colors:
'''
@ -134,15 +134,18 @@ def raw(data):
with open(_outputfile, "a+") as f:
f.write(colors.filter(data) + '\n')
def log(prefix, data, color = ''):
def log(prefix, data, color = '', timestamp=True):
'''
Logs the data
prefix : The prefix to the output
data : The actual data to output
color : The color to output before the data
'''
output = colors.reset + str(color) + '[' + colors.bold + str(prefix) + colors.reset + str(color) + '] ' + str(data) + colors.reset
if timestamp:
curTime = time.strftime("%m-%d %H:%M:%S")
else:
curTime = ''
output = colors.reset + str(color) + '[' + colors.bold + str(prefix) + colors.reset + str(color) + '] ' + curTime + ' ' + str(data) + colors.reset
if not get_settings() & USE_ANSI:
output = colors.filter(output)