|
|
@ -38,7 +38,7 @@ def reverse(view_name, urlconf=None, args=None, kwargs=None,
|
|
|
|
|
|
|
|
|
|
|
|
if external:
|
|
|
|
if external:
|
|
|
|
from common.models import common_settings
|
|
|
|
from common.models import common_settings
|
|
|
|
site_url = common_settings.SITE_URL or settings.SITE_URL
|
|
|
|
site_url = common_settings.SITE_URL
|
|
|
|
url = site_url.strip('/') + url
|
|
|
|
url = site_url.strip('/') + url
|
|
|
|
return url
|
|
|
|
return url
|
|
|
|
|
|
|
|
|
|
|
@ -389,53 +389,20 @@ def get_request_ip(request):
|
|
|
|
return login_ip
|
|
|
|
return login_ip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_command_storage_or_create_default_storage():
|
|
|
|
def get_command_storage_setting():
|
|
|
|
from common.models import common_settings, Setting
|
|
|
|
from common.models import common_settings
|
|
|
|
name = 'TERMINAL_COMMAND_STORAGE'
|
|
|
|
default = settings.TERMINAL_COMMAND_STORAGE
|
|
|
|
default = {'default': {'TYPE': 'server'}}
|
|
|
|
value = common_settings.TERMINAL_COMMAND_STORAGE
|
|
|
|
try:
|
|
|
|
value.update(default)
|
|
|
|
command_storage = common_settings.TERMINAL_COMMAND_STORAGE
|
|
|
|
return value
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
return default
|
|
|
|
|
|
|
|
if command_storage is None:
|
|
|
|
def get_replay_storage_setting():
|
|
|
|
obj = Setting()
|
|
|
|
from common.models import common_settings
|
|
|
|
obj.name = name
|
|
|
|
default = settings.TERMINAL_REPLAY_STORAGE
|
|
|
|
obj.encrypted = True
|
|
|
|
value = common_settings.TERMINAL_REPLAY_STORAGE
|
|
|
|
obj.cleaned_value = default
|
|
|
|
value.update(default)
|
|
|
|
obj.save()
|
|
|
|
return value
|
|
|
|
if isinstance(command_storage, dict) and not command_storage:
|
|
|
|
|
|
|
|
obj = Setting.objects.get(name=name)
|
|
|
|
|
|
|
|
value = obj.cleaned_value
|
|
|
|
|
|
|
|
value.update(default)
|
|
|
|
|
|
|
|
obj.cleaned_value = value
|
|
|
|
|
|
|
|
obj.save()
|
|
|
|
|
|
|
|
command_storage = common_settings.TERMINAL_COMMAND_STORAGE
|
|
|
|
|
|
|
|
return command_storage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_replay_storage_or_create_default_storage():
|
|
|
|
|
|
|
|
from common.models import common_settings, Setting
|
|
|
|
|
|
|
|
name = 'TERMINAL_REPLAY_STORAGE'
|
|
|
|
|
|
|
|
default = {'default': {'TYPE': 'server'}}
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
replay_storage = common_settings.TERMINAL_REPLAY_STORAGE
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
return default
|
|
|
|
|
|
|
|
if replay_storage is None:
|
|
|
|
|
|
|
|
obj = Setting()
|
|
|
|
|
|
|
|
obj.name = name
|
|
|
|
|
|
|
|
obj.encrypted = True
|
|
|
|
|
|
|
|
obj.cleaned_value = default
|
|
|
|
|
|
|
|
obj.save()
|
|
|
|
|
|
|
|
replay_storage = common_settings.TERMINAL_REPLAY_STORAGE
|
|
|
|
|
|
|
|
if isinstance(replay_storage, dict) and not replay_storage:
|
|
|
|
|
|
|
|
obj = Setting.objects.get(name=name)
|
|
|
|
|
|
|
|
value = obj.cleaned_value
|
|
|
|
|
|
|
|
value.update(default)
|
|
|
|
|
|
|
|
obj.cleaned_value = value
|
|
|
|
|
|
|
|
obj.save()
|
|
|
|
|
|
|
|
replay_storage = common_settings.TERMINAL_REPLAY_STORAGE
|
|
|
|
|
|
|
|
return replay_storage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TeeObj:
|
|
|
|
class TeeObj:
|
|
|
|