Skip to content

Commit

Permalink
move default ports constants to net module
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 1, 2023
1 parent 02abb68 commit 96412aa
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
3 changes: 2 additions & 1 deletion xpra/client/gtk_base/client_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
add_close_accel, scaled_image, color_parse,
choose_file, imagebutton, get_icon_pixbuf,
)
from xpra.util import DEFAULT_PORT, csv, repr_ellipsized
from xpra.util import csv, repr_ellipsized
from xpra.os_util import WIN32, OSX
from xpra.net.common import DEFAULT_PORT
from xpra.make_thread import start_thread
from xpra.gtk_common.about import about
from xpra.scripts.main import (
Expand Down
3 changes: 2 additions & 1 deletion xpra/client/gtk_base/sessions_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
imagebutton, get_icon_pixbuf,
)
from xpra.gtk_common.gobject_compat import register_os_signals
from xpra.net.common import DEFAULT_PORTS
from xpra.net.net_util import if_indextoname
from xpra.util import typedict, DEFAULT_PORTS
from xpra.util import typedict
from xpra.os_util import bytestostr, WIN32
from xpra.log import Logger

Expand Down
14 changes: 14 additions & 0 deletions xpra/net/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
from xpra.log import Logger
log = Logger("network")


DEFAULT_PORT = 14500

DEFAULT_PORTS = {
"ws" : 80,
"wss" : 443,
"ssl" : DEFAULT_PORT, #could also default to 443?
"ssh" : 22,
"tcp" : DEFAULT_PORT,
"vnc" : 5900,
"quic" : 20000,
}


class ConnectionClosedException(Exception):
pass

Expand Down
2 changes: 1 addition & 1 deletion xpra/net/socket_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from xpra.common import GROUP
from xpra.scripts.config import InitException, InitExit, TRUE_OPTIONS
from xpra.exit_codes import ExitCode
from xpra.net.common import DEFAULT_PORT
from xpra.net.bytestreams import set_socket_timeout, pretty_socket, SOCKET_TIMEOUT
from xpra.os_util import (
getuid, get_username_for_uid, get_groups, get_group_id, osexpand,
Expand All @@ -20,7 +21,6 @@
from xpra.util import (
envint, envbool, csv, parse_simple_dict, print_nested_dict, std,
ellipsizer, noerr,
DEFAULT_PORT,
)
from xpra.make_thread import start_thread

Expand Down
2 changes: 1 addition & 1 deletion xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from xpra.util import (
csv, envbool, envint, nonl, pver, engs,
noerr, sorted_nicely, typedict,
DEFAULT_PORTS,
)
from xpra.exit_codes import ExitCode, RETRY_EXIT_CODES, exit_str
from xpra.os_util import (
Expand All @@ -51,6 +50,7 @@
dict_to_validated_config, get_xpra_defaults_dirs, get_defaults, read_xpra_conf,
make_defaults_struct, parse_bool, has_sound_support, name_to_field,
)
from xpra.net.common import DEFAULT_PORTS
from xpra.log import is_debug_enabled, Logger, get_debug_args
assert callable(error), "used by modules importing this function from here"

Expand Down
3 changes: 2 additions & 1 deletion xpra/scripts/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from urllib import parse

from xpra.version_util import full_version_str
from xpra.util import envbool, csv, parse_simple_dict, DEFAULT_PORT, DEFAULT_PORTS
from xpra.util import envbool, csv, parse_simple_dict
from xpra.net.common import DEFAULT_PORT, DEFAULT_PORTS
from xpra.os_util import WIN32, OSX, POSIX, get_user_uuid
from xpra.scripts.config import (
OPTION_TYPES, TRUE_OPTIONS,
Expand Down
8 changes: 4 additions & 4 deletions xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from xpra.scripts.server import deadly_signal, clean_session_files, rm_session_dir
from xpra.server.server_util import write_pidfile, rm_pidfile
from xpra.scripts.config import parse_bool, parse_with_unit, TRUE_OPTIONS, FALSE_OPTIONS
from xpra.net.common import may_log_packet, SOCKET_TYPES, MAX_PACKET_SIZE
from xpra.net.common import may_log_packet, SOCKET_TYPES, MAX_PACKET_SIZE, DEFAULT_PORTS
from xpra.net.socket_util import (
hosts, mdns_publish, peek_connection,
PEEK_TIMEOUT_MS, SOCKET_PEEK_TIMEOUT_MS,
Expand All @@ -47,7 +47,7 @@
from xpra.platform.info import get_username
from xpra.platform.paths import (
get_app_dir, get_system_conf_dirs, get_user_conf_dirs,
get_icon_filename, get_python_exec_command,
get_icon_filename,
)
from xpra.platform.dotxpra import DotXpra
from xpra.os_util import (
Expand All @@ -58,7 +58,7 @@
getuid, hexstr,
POSIX, OSX,
parse_encoded_bin_data, load_binary_file,
osexpand, which, get_saved_env, OSEnvContext,
osexpand, which, get_saved_env,
)
from xpra.server.background_worker import stop_worker, get_worker, add_work_item
from xpra.server.menu_provider import get_menu_provider
Expand All @@ -70,7 +70,7 @@
csv, merge_dicts, typedict, notypedict, flatten_dict,
ellipsizer, repr_ellipsized,
dump_all_frames, envint, envbool, envfloat,
ConnectionMessage, DEFAULT_PORTS,
ConnectionMessage,
)
from xpra.log import Logger, get_info as get_log_info

Expand Down
13 changes: 0 additions & 13 deletions xpra/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@ class ConnectionMessage(StrEnum):
CLIENT_EXIT = "client exit"


DEFAULT_PORT = 14500

DEFAULT_PORTS = {
"ws" : 80,
"wss" : 443,
"ssl" : DEFAULT_PORT, #could also default to 443?
"ssh" : 22,
"tcp" : DEFAULT_PORT,
"vnc" : 5900,
"quic" : 20000,
}


#magic value for "workspace" window property, means unset
WORKSPACE_UNSET = 65535
WORKSPACE_ALL = 0xffffffff
Expand Down

0 comments on commit 96412aa

Please sign in to comment.