1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-14 19:24:27 +03:00

small fixes for tunnel

This commit is contained in:
Adolfo Gómez García 2021-01-25 12:47:00 +01:00
parent 50660d92e5
commit 4313368f78
5 changed files with 9 additions and 12 deletions
server/src/uds/REST/methods
tunnel-server/src

@ -80,7 +80,7 @@ class Tunnel(Handler):
extra = extra or {}
now = models.getSqlDatetimeAsUnix()
totalTime = now - extra.get('b', now-1)
msg = f'User {user.name} stopped tunnel {extra.get("t", "")[:8]}... to {host}:{port}: s:{sent}/r:{recv}/t:{totalTime}.'
msg = f'User {user.name} stopped tunnel {extra.get("t", "")[:8]}... to {host}:{port}: u:{sent}/d:{recv}/t:{totalTime}.'
log.doLog(user.manager, log.INFO, msg)
log.doLog(userService, log.INFO, msg)
else:

@ -61,8 +61,6 @@ class ConfigurationType(typing.NamedTuple):
secret: str
allow: typing.Set[str]
storage: str
def read() -> ConfigurationType:
with open(CONFIGFILE, 'r') as f:
@ -106,7 +104,6 @@ def read() -> ConfigurationType:
uds_server=uds_server,
secret=secret,
allow=set(uds.get('allow', '127.0.0.1').split(',')),
storage=uds.get('storage', '')
)
except ValueError as e:
raise Exception(f'Mandatory configuration file in incorrect format: {e.args[0]}. Please, revise {CONFIGFILE}')

@ -11,7 +11,7 @@
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# * Neither the name of Virtual Cable S.L.U. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
@ -28,18 +28,16 @@
'''
@author: Adolfo Gómez, dkmaster at dkmon dot com
'''
import string
DEBUG = True
if DEBUG:
CONFIGFILE = 'udstunnel.cfg'
CONFIGFILE = 'udstunnel.conf'
LOGFORMAT = '%(levelname)s %(asctime)s %(message)s'
else:
CONFIGFILE = '/etc/udstunnel.cfg'
CONFIGFILE = '/etc/udstunnel.conf'
LOGFORMAT = '%(levelname)s %(asctime)s %(message)s'
# MAX Length of read buffer for proxy
# MAX Length of read buffer for proxyed requests
BUFFER_SIZE = 1024 * 16
# Handshake for conversation start
HANDSHAKE_V1 = b'\x5AMGB\xA5\x01\x00'
@ -50,11 +48,11 @@ PASSWORD_LENGTH = 64
# Bandwidth calc time lapse
BANDWIDTH_TIME = 10
# Commands LENGTH (all same lenght)
# Commands LENGTH (all same length)
COMMAND_LENGTH = 4
# Valid commands
COMMAND_OPEN = b'OPEN'
COMMAND_TEST = b'TEST'
COMMAND_STAT = b'STAT' # full stats
COMMAND_INFO = b'INFO' # Basic stats, currently same as FULL
COMMAND_INFO = b'INFO' # Basic stats, currently same as FULL

@ -199,6 +199,8 @@ def tunnel_main():
# Wait for socket incoming connections and spread them
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
# We will not reuse port, we only want a UDS tunnel server running on a port
# but this may change on future...
# try: