1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-10-07 15:33:51 +03:00

5 Commits
1.9 ... v1.9

Author SHA1 Message Date
Adolfo Gómez García
b5926dec6f Fixed a bug on free edition not allowing to register correctly linux machines 2016-05-03 08:14:14 +02:00
Adolfo Gómez García
bd70a6290e fixed to work correctly on free 2016-04-29 11:15:07 +02:00
Adolfo Gómez García
813764a100 Fixed UDS Client to allow host names with unicode characters 2016-04-27 09:43:08 +02:00
Adolfo Gómez García
09f329db62 Allow UDS behind a proxy 2016-04-22 15:03:06 +02:00
Adolfo Gómez García
6b5f9d266d Allow UDS behind a proxy 2016-04-22 14:59:34 +02:00
8 changed files with 41 additions and 12 deletions

View File

@@ -57,7 +57,7 @@ def _getMacAddr(ifname):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack(str('256s'), ifname[:15])))
return six.text_type(''.join(['%02x:' % char for char in info[18:24]])[:-1])
return six.text_type(''.join(['%02x:' % char for char in info[18:24]])[:-1]).upper()
except Exception:
return None

View File

@@ -137,8 +137,12 @@ class UDSClient(QtGui.QMainWindow):
@QtCore.pyqtSlot()
def getTransportData(self):
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
self.req.get()
try:
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
self.req.get()
except Exception as e:
logger.exception('Got exception: {}'.format(e))
raise e
@QtCore.pyqtSlot(dict)
@@ -232,7 +236,7 @@ if __name__ == "__main__":
except Exception:
logger.debug('Detected execution without valid URI, exiting')
QtGui.QMessageBox.critical(None, 'Notice', 'This program is designed to be used by UDS', QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(None, 'Notice', 'UDS Client Version {}'.format(VERSION), QtGui.QMessageBox.Ok)
sys.exit(1)
# Setup REST api endpoint

View File

@@ -34,7 +34,7 @@ from __future__ import unicode_literals
# On centos, old six release does not includes byte2int, nor six.PY2
import six
VERSION = '1.9.0'
VERSION = '1.9.1'
__title__ = 'udclient'
__version__ = VERSION

View File

@@ -56,7 +56,7 @@ class RestRequest(QObject):
# private
self._manager = QNetworkAccessManager()
if params is not None:
url += '?' + '&'.join('{}={}'.format(k, urllib.quote(six.text_type(v))) for k, v in params.iteritems())
url += '?' + '&'.join('{}={}'.format(k, urllib.quote(six.text_type(v).encode('utf8'))) for k, v in params.iteritems())
self.url = QUrl(RestRequest.restApiUrl + url)

View File

@@ -41,27 +41,36 @@ import stat
import six
import sys
from log import logger
_unlinkFiles = []
_tasksToWait = []
_execBeforeExit = []
sys_fs_enc = sys.getfilesystemencoding() or 'mbcs'
def saveTempFile(content, filename=None):
if filename is None:
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
filename = b''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
filename = filename + '.uds'
if 'win32' in sys.platform:
filename = filename.encode('utf-8')
logger.info('Fixing for win32')
filename = filename.encode(sys_fs_enc)
filename = os.path.join(tempfile.gettempdir(), filename)
with open(filename, 'w') as f:
f.write(content)
logger.info('Returning filename')
return filename
def findApp(appName, extraPath=None):
if 'win32' in sys.platform and isinstance(appName, six.text_type):
appName = six.binary_type(appName)
appName = appName.encode(sys_fs_enc)
searchPath = os.environ['PATH'].split(os.pathsep)
if extraPath is not None:
searchPath += list(extraPath)
@@ -78,7 +87,13 @@ def getHostName():
Returns current host name
In fact, it's a wrapper for socket.gethostname()
'''
return six.text_type(socket.gethostname())
hostname = socket.gethostname()
if 'win32' in sys.platform:
hostname = hostname.decode(sys_fs_enc)
hostname = six.text_type(hostname)
logger.info('Hostname: {}'.format(hostname))
return hostname
# Queing operations (to be executed before exit)

View File

@@ -111,7 +111,7 @@ class Actor(Handler):
logger.debug('Getting User services from ids: {}'.format(self._params.get('id')))
try:
clientIds = self._params.get('id').split(',')[:5]
clientIds = [i.upper() for i in self._params.get('id').split(',')[:5]]
except Exception:
raise RequestError('Invalid request: (no id found)')

View File

@@ -282,6 +282,9 @@ class GlobalConfig(object):
# 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)
# If there is a proxy in front of us
BEHIND_PROXY = Config.section(SECURITY_SECTION).value('Behind a proxy', '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

@@ -32,13 +32,14 @@
from __future__ import unicode_literals
from uds.core.util import OsDetector
from uds.core.util.Config import GlobalConfig
from uds.core.auths.auth import ROOT_ID, USER_KEY, getRootUser
from uds.models import User
import threading
import logging
__updated__ = '2015-05-10'
__updated__ = '2016-04-22'
logger = logging.getLogger(__name__)
@@ -90,6 +91,7 @@ class GlobalRequestMiddleware(object):
Returns the obtained IP, that is always be a valid ip address.
'''
behind_proxy = GlobalConfig.BEHIND_PROXY.getBool(False)
try:
request.ip = request.META['REMOTE_ADDR']
except:
@@ -98,6 +100,11 @@ class GlobalRequestMiddleware(object):
try:
request.ip_proxy = request.META['HTTP_X_FORWARDED_FOR'].split(",")[0]
if behind_proxy is True:
request.ip = request.ip_proxy
request.ip_proxy = request.META['HTTP_X_FORWARDED_FOR'].split(",")[1] # Try to get next proxy
request.is_proxy = True
except:
request.ip_proxy = request.ip