portune 0.1.19__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of portune might be problematic. Click here for more details.
- {portune-0.1.19/portune.egg-info → portune-1.0.0}/PKG-INFO +2 -2
- {portune-0.1.19 → portune-1.0.0}/README.md +1 -1
- {portune-0.1.19 → portune-1.0.0}/portune/portune.py +33 -21
- {portune-0.1.19 → portune-1.0.0}/portune/version.py +2 -2
- {portune-0.1.19 → portune-1.0.0/portune.egg-info}/PKG-INFO +2 -2
- {portune-0.1.19 → portune-1.0.0}/.github/workflows/python-publish.yml +0 -0
- {portune-0.1.19 → portune-1.0.0}/.gitignore +0 -0
- {portune-0.1.19 → portune-1.0.0}/LICENSE +0 -0
- {portune-0.1.19 → portune-1.0.0}/portune/__init__.py +0 -0
- {portune-0.1.19 → portune-1.0.0}/portune.egg-info/SOURCES.txt +0 -0
- {portune-0.1.19 → portune-1.0.0}/portune.egg-info/dependency_links.txt +0 -0
- {portune-0.1.19 → portune-1.0.0}/portune.egg-info/entry_points.txt +0 -0
- {portune-0.1.19 → portune-1.0.0}/portune.egg-info/top_level.txt +0 -0
- {portune-0.1.19 → portune-1.0.0}/pyproject.toml +0 -0
- {portune-0.1.19 → portune-1.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: portune
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Simple Python HTTP Exec Server
|
|
5
5
|
Author: Franck Jouvanceau
|
|
6
6
|
Maintainer: Franck Jouvanceau
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
[](https://shields.io/)
|
|
37
37
|
[](https://pepy.tech/project/portune)
|
|
38
38
|
[](https://shields.io/)
|
|
39
|
-
[]()
|
|
40
40
|
|
|
41
41
|
# portune
|
|
42
42
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://shields.io/)
|
|
4
4
|
[](https://pepy.tech/project/portune)
|
|
5
5
|
[](https://shields.io/)
|
|
6
|
-
[]()
|
|
7
7
|
|
|
8
8
|
# portune
|
|
9
9
|
|
|
@@ -32,6 +32,9 @@ from email.mime.application import MIMEApplication
|
|
|
32
32
|
from typing import List, Dict, Tuple, Any, Optional, Union
|
|
33
33
|
|
|
34
34
|
# Constants and global variables
|
|
35
|
+
|
|
36
|
+
# Use system ping command based on the OS
|
|
37
|
+
# as raw socket ICMP ping requires privileges
|
|
35
38
|
OS = platform.system().lower()
|
|
36
39
|
if OS == "windows":
|
|
37
40
|
PING = "ping -n 1 -w {timeoutms} {ip}"
|
|
@@ -40,9 +43,9 @@ elif OS == "darwin": # macOS
|
|
|
40
43
|
elif OS == "sunos": # SunOS
|
|
41
44
|
PING = "ping {ip} {timeout}"
|
|
42
45
|
elif OS == "aix": # IBM AIX
|
|
43
|
-
PING = "ping -c 1 -w
|
|
44
|
-
elif OS.startswith("hp-ux"): # HP-UX
|
|
45
|
-
PING = "ping -n 1 -
|
|
46
|
+
PING = "ping -c 1 -w {timeout} {ip}"
|
|
47
|
+
elif OS.startswith("hp-ux"): # HP-UX 11.11+
|
|
48
|
+
PING = "ping -n 1 -m {timeout} {ip}"
|
|
46
49
|
else:
|
|
47
50
|
PING = "ping -c 1 -W {timeout} {ip}"
|
|
48
51
|
|
|
@@ -729,6 +732,24 @@ def ping_host(ip: str, timeout: int = 2) -> bool:
|
|
|
729
732
|
except Exception:
|
|
730
733
|
return False
|
|
731
734
|
|
|
735
|
+
def is_ip(hostname: str) -> bool:
|
|
736
|
+
"""Check if a given hostname is an IP address.
|
|
737
|
+
|
|
738
|
+
Uses inet_aton to determine if the input string is a valid
|
|
739
|
+
IPv4 address.
|
|
740
|
+
|
|
741
|
+
Args:
|
|
742
|
+
hostname: The hostname or IP address to check
|
|
743
|
+
|
|
744
|
+
Returns:
|
|
745
|
+
True if the hostname is an IP address, False otherwise
|
|
746
|
+
"""
|
|
747
|
+
try:
|
|
748
|
+
socket.inet_aton(hostname)
|
|
749
|
+
return True
|
|
750
|
+
except socket.error:
|
|
751
|
+
return False
|
|
752
|
+
|
|
732
753
|
def resolve_and_ping_host(hostname: str, timeout: int = 2, noping: bool = False) -> Tuple[str, Dict[str, Union[str, bool]]]:
|
|
733
754
|
"""Resolve a hostname to IP and optionally check if it responds to ping.
|
|
734
755
|
|
|
@@ -749,25 +770,17 @@ def resolve_and_ping_host(hostname: str, timeout: int = 2, noping: bool = False)
|
|
|
749
770
|
- 'hostname': Original resolved hostname (only if different from input)
|
|
750
771
|
"""
|
|
751
772
|
try:
|
|
752
|
-
# Check if hostname is already an IP address
|
|
753
|
-
try:
|
|
754
|
-
# Try to create an IP address object to validate format
|
|
755
|
-
socket.inet_aton(hostname)
|
|
756
|
-
is_ip = True
|
|
757
|
-
except socket.error:
|
|
758
|
-
is_ip = False
|
|
759
|
-
|
|
760
773
|
# If it's an IP, try to get hostname from reverse DNS
|
|
761
|
-
if is_ip:
|
|
774
|
+
if is_ip(hostname):
|
|
762
775
|
try:
|
|
763
|
-
|
|
776
|
+
ip = hostname
|
|
777
|
+
resolved_hosts = socket.gethostbyaddr(ip)
|
|
764
778
|
if resolved_hosts and resolved_hosts[0]:
|
|
765
779
|
hostname = resolved_hosts[0] # Use the resolved hostname
|
|
766
780
|
except (socket.herror, socket.gaierror):
|
|
767
781
|
pass # Keep the IP as hostname if reverse lookup fails
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
ip = socket.gethostbyname(hostname)
|
|
782
|
+
else:
|
|
783
|
+
ip = socket.gethostbyname(hostname)
|
|
771
784
|
if noping:
|
|
772
785
|
return hostname, {'ip': ip, 'ping': False}
|
|
773
786
|
ping_status = ping_host(ip, timeout)
|
|
@@ -1101,12 +1114,10 @@ def compute_stats(
|
|
|
1101
1114
|
})
|
|
1102
1115
|
|
|
1103
1116
|
for hostname, ip, port, status, _, _ in results:
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
socket.inet_aton(hostname)
|
|
1107
|
-
# It's a valid IP address, use VLAN/16
|
|
1117
|
+
if is_ip(hostname):
|
|
1118
|
+
# For IP addresses, use VLAN/16 as domain
|
|
1108
1119
|
domain = '.'.join(hostname.split('.')[:2]) + '.0.0'
|
|
1109
|
-
|
|
1120
|
+
else:
|
|
1110
1121
|
# Not an IP address, extract domain normally
|
|
1111
1122
|
parts = hostname.split('.')
|
|
1112
1123
|
if len(parts) > 1:
|
|
@@ -1410,6 +1421,7 @@ def print_statistics(stats, timeout, parallelism):
|
|
|
1410
1421
|
first_row = False
|
|
1411
1422
|
if not first_row: # Only print separator between domains if domain had data
|
|
1412
1423
|
print(separator, file=sys.stderr)
|
|
1424
|
+
|
|
1413
1425
|
def format_table_output(
|
|
1414
1426
|
results: List[Tuple[str, str, int, str, bool]],
|
|
1415
1427
|
noping: bool
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: portune
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Simple Python HTTP Exec Server
|
|
5
5
|
Author: Franck Jouvanceau
|
|
6
6
|
Maintainer: Franck Jouvanceau
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
[](https://shields.io/)
|
|
37
37
|
[](https://pepy.tech/project/portune)
|
|
38
38
|
[](https://shields.io/)
|
|
39
|
-
[]()
|
|
40
40
|
|
|
41
41
|
# portune
|
|
42
42
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|