1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

* Updated notification so, by default, is broker which "deduces" the

client IP and not the client who notifies it (this is left just for
"trusted" environments)
This commit is contained in:
Adolfo Gómez García 2015-02-22 09:31:56 +01:00
parent 8de49e5e94
commit c075ae5a9c
2 changed files with 15 additions and 7 deletions

View File

@ -279,6 +279,9 @@ class GlobalConfig(object):
# Allowed "trusted sources" for request
TRUSTED_SOURCES = Config.section(SECURITY_SECTION).value('Trusted Hosts', '*', type=Config.TEXT_FIELD)
# Allow clients to notify their own ip (if set), or use always the request extracted IP
HONOR_CLIENT_IP_NOTIFY = Config.section(SECURITY_SECTION).value('honorClientNotifyIP', '0', type=Config.BOOLEAN_FIELD)
# Clusters related vars
# Maximum desired CPU Load. If cpu is over this value, a migration of a service is "desirable"

View File

@ -37,13 +37,14 @@ from django.views.decorators.cache import cache_page
from uds.core.auths.auth import webLoginRequired, webPassword
from uds.core.services.Exceptions import ServiceInMaintenanceMode
from uds.models import DeployedService, Transport, UserService, Image
from uds.core.ui.images import DEFAULT_IMAGE
from uds.core.managers.UserServiceManager import UserServiceManager
from uds.core.ui.images import DEFAULT_IMAGE
from uds.core.ui import theme
from uds.core.util.Config import GlobalConfig
from uds.core.util.stats import events
from uds.core.util import log
from uds.core.util import OsDetector
from uds.core.util.stats import events
from uds.core.ui import theme
from uds.models import DeployedService, Transport, UserService, Image
import uds.web.errors as errors
@ -51,7 +52,7 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2015-02-18'
__updated__ = '2015-02-22'
@webLoginRequired
@ -121,8 +122,12 @@ def transcomp(request, idTransport, componentId):
def sernotify(request, idUserService, notification):
try:
if notification == 'hostname':
hostname = request.GET.get('hostname', None)
ip = request.GET.get('ip', None)
hostname = request.GET.get('hostname', None)[:64] # Cuts host name to 64 chars
ip = request.ip
if GlobalConfig.HONOR_CLIENT_IP_NOTIFY.getBool(True) is True:
ip = request.GET.get('ip', ip)
if ip is not None and hostname is not None:
us = UserService.objects.get(uuid=idUserService)
us.setConnectionSource(ip, hostname)