Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the default port numbers #374

Merged
merged 2 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Pipfile.lock

.pytest_cache
.python-version
.*rc

.DS_Store
._.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Monitor has context manager interface:

Now from separate terminal it is possible to connect to the application::

$ telnet localhost 50101
$ telnet localhost 20101

or the included python client::

Expand Down Expand Up @@ -113,7 +113,7 @@ Let's save this code in file ``simple_srv.py``, so we can run it with the follow
And now one can connect to a running application from a separate terminal, with
the ``telnet`` command, and ``aiomonitor`` will immediately respond with prompt::

$ telnet localhost 50101
$ telnet localhost 20101
Asyncio Monitor: 1 tasks running
Type help for commands
monitor >>>
Expand Down
6 changes: 4 additions & 2 deletions aiomonitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

loop = asyncio.get_event_loop()
with aiomonitor.start_monitor():
print("Now you can connect with: nc localhost 50101")
print("Now you can connect with: nc localhost 20101")
loop.run_forever()

Alternatively you can use more verbose try/finally approach::
Expand All @@ -22,16 +22,18 @@

from importlib.metadata import version

from .monitor import MONITOR_TERMUI_PORT # for backward compatibility
from .monitor import (
CONSOLE_PORT,
MONITOR_HOST,
MONITOR_TERMUI_PORT,
MONITOR_WEBUI_PORT,
Monitor,
start_monitor,
)
from .termui.commands import monitor_cli

MONITOR_PORT = MONITOR_TERMUI_PORT # for backward compatibility

__all__ = (
"Monitor",
"start_monitor",
Expand Down
6 changes: 3 additions & 3 deletions aiomonitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
log = logging.getLogger(__name__)

MONITOR_HOST: Final = "127.0.0.1"
MONITOR_TERMUI_PORT: Final = 50101
CONSOLE_PORT: Final = 50102
MONITOR_WEBUI_PORT: Final = 50201
MONITOR_TERMUI_PORT: Final = 20101
MONITOR_WEBUI_PORT: Final = 20102
CONSOLE_PORT: Final = 20103

T = TypeVar("T")
T_co = TypeVar("T_co", covariant=True)
Expand Down
1 change: 1 addition & 0 deletions changes/374.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace the default port numbers for the terminal UI, the web UI, and the console access (50101, 50201, 50102 -> 20101, 20102, 20103 respectively)
26 changes: 17 additions & 9 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ simple as opening a file.

loop = asyncio.get_event_loop()
with aiomonitor.start_monitor(loop):
print("Now you can connect with: nc localhost 50101")
print("Now you can connect with: nc localhost 20101")
loop.run_forever()

Alternatively you can use more verbose try/finally approach but do not forget
Expand Down Expand Up @@ -40,14 +40,22 @@ Reference

.. data:: MONITOR_HOST = '127.0.0.1'

Specifies the default host for monitor, by default monitor binded to
``localhost``.
Specifies the default host to bind the services for the monitor

.. data:: MONITOR_PORT = 50101
.. warning::

Specifies the default port for monitor, you can connect using telnet client
Since aiomonitor exposes the internal states of the traced process, never bind it to
publicly accessible address to prevent potential security breaches and denial of services!

.. data:: CONSOLE_PORT = 50102
.. data:: MONITOR_TERMUI_PORT = 20101

Specifies the default telnet port for teh monitor where you can connect using a telnet client

.. data:: MONITOR_WEBUI_PORT = 20102

Specifies the default HTTP port for the monitor where you can connect using a web browser

.. data:: CONSOLE_PORT = 20103

Specifies the default port for asynchronous python REPL

Expand All @@ -59,9 +67,9 @@ Reference

:param Type[Monitor] monitor: Monitor class to use
:param str host: hostname to serve monitor telnet server
:param int port: monitor port (terminal UI), by default 50101
:param int webui_port: monitor port (web UI), by default 50201
:param int console_port: python REPL port, by default 50102
:param int port: monitor port (terminal UI), by default 20101
:param int webui_port: monitor port (web UI), by default 20102
:param int console_port: python REPL port, by default 20103
:param bool console_enabled: flag indicates if python REPL is requred
to start with instance of monitor.
:param dict locals: dictionary with variables exposed in python console
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ And now it is possible to connect to the running application from separate
terminal, by execution ``nc`` command, immediately ``aiomonitor`` will
respond with prompt::

$ nc localhost 50101
$ telnet localhost 20101
Asyncio Monitor: 1 tasks running
Type help for commands
monitor >>>
Expand Down
Loading