nadzoring.network_base.service_on_port module¶
Service name resolution for port numbers.
- nadzoring.network_base.service_on_port.get_service_on_port(port: int) str[source]¶
Get the service name associated with a given port number.
Attempts to determine the standard service name (e.g., ‘http’, ‘https’, ‘ssh’) for the specified port number using the system’s service database.
- Parameters:
port – The port number to look up. Must be in range 0-65535.
- Returns:
The service name if found, otherwise returns “unknown”. Service names are typically lowercase strings like ‘http’, ‘ssh’, etc.
Examples
>>> get_service_on_port(80) 'http' >>> get_service_on_port(22) 'ssh' >>> get_service_on_port(9999) 'unknown'