vping 1.0.1__py3-none-any.whl
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.
- vping/__init__.py +12 -0
- vping/__main__.py +29 -0
- vping/core.py +57 -0
- vping-1.0.1.dist-info/METADATA +51 -0
- vping-1.0.1.dist-info/RECORD +8 -0
- vping-1.0.1.dist-info/WHEEL +5 -0
- vping-1.0.1.dist-info/entry_points.txt +2 -0
- vping-1.0.1.dist-info/top_level.txt +1 -0
vping/__init__.py
ADDED
vping/__main__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# File: vping/__main__.py
|
|
4
|
+
# Author: Hadi Cahyadi <cumulus13@gmail.com>
|
|
5
|
+
# Date: 2026-10-27
|
|
6
|
+
# Description:
|
|
7
|
+
# License: MIT
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
from .core import ping
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
if len(sys.argv) < 2:
|
|
14
|
+
print("Usage: python -m vping <hostname_or_ip>")
|
|
15
|
+
sys.exit(1)
|
|
16
|
+
|
|
17
|
+
host = sys.argv[1]
|
|
18
|
+
print(f"Checking target: {host} ...")
|
|
19
|
+
|
|
20
|
+
alive = ping(host)
|
|
21
|
+
if alive:
|
|
22
|
+
print(f"RESULT: {host} is ALIVE")
|
|
23
|
+
sys.exit(0)
|
|
24
|
+
else:
|
|
25
|
+
print(f"RESULT: {host} is DOWN / UNREACHABLE")
|
|
26
|
+
sys.exit(1)
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
main()
|
vping/core.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# File: vping/core.py
|
|
4
|
+
# Author: Hadi Cahyadi <cumulus13@gmail.com>
|
|
5
|
+
# Date: 2026-10-27
|
|
6
|
+
# Description:
|
|
7
|
+
# License: MIT
|
|
8
|
+
|
|
9
|
+
import socket
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger("vping")
|
|
13
|
+
|
|
14
|
+
def _tcp_fallback(host: str, ports: list = None, timeout: float = 1.0) -> bool:
|
|
15
|
+
"""Fallback method using TCP connect scans across common ports."""
|
|
16
|
+
if ports is None:
|
|
17
|
+
ports = [80, 443, 53]
|
|
18
|
+
|
|
19
|
+
for port in ports:
|
|
20
|
+
try:
|
|
21
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
22
|
+
s.settimeout(timeout)
|
|
23
|
+
if s.connect_ex((host, port)) == 0:
|
|
24
|
+
return True
|
|
25
|
+
except Exception:
|
|
26
|
+
continue
|
|
27
|
+
return False
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def ping(host: str, timeout: float = 1.0, ports: list = None) -> bool:
|
|
31
|
+
"""
|
|
32
|
+
Checks if a host is alive.
|
|
33
|
+
Tries icmplib first; if missing, unprivileged, or errored,
|
|
34
|
+
automatically falls back to robust TCP connect scanning.
|
|
35
|
+
"""
|
|
36
|
+
# Attempt 1: Try using icmplib if available
|
|
37
|
+
try:
|
|
38
|
+
from icmplib import ping as icmp_ping
|
|
39
|
+
try:
|
|
40
|
+
host_info = icmp_ping(host, count=1, timeout=timeout, privileged=False)
|
|
41
|
+
if host_info.is_alive:
|
|
42
|
+
return True
|
|
43
|
+
except Exception:
|
|
44
|
+
try:
|
|
45
|
+
host_info = icmp_ping(host, count=1, timeout=timeout, privileged=True)
|
|
46
|
+
if host_info.is_alive:
|
|
47
|
+
return True
|
|
48
|
+
except Exception:
|
|
49
|
+
pass
|
|
50
|
+
except ImportError:
|
|
51
|
+
logger.debug("icmplib not found. Using TCP fallback.")
|
|
52
|
+
except Exception:
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
# Attempt 2: Bulletproof TCP fallback
|
|
56
|
+
return _tcp_fallback(host, ports=ports, timeout=timeout)
|
|
57
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vping
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Fast, robust host alive checker with icmplib and TCP fallback
|
|
5
|
+
Author-email: Hadi Cahyadi <cumulus13@gmail.com>
|
|
6
|
+
Maintainer-email: cumulus13 <cumulus13@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: ping,network,host-checker,icmplib,tcp-scan,lan
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: System :: Networking
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Requires-Dist: icmplib>=2.1.1; sys_platform != "win32" or python_version >= "3.8"
|
|
20
|
+
|
|
21
|
+
# vping
|
|
22
|
+
|
|
23
|
+
Fast and robust host alive checker for LAN and WAN networks. Tries native ICMP (`icmplib`) first and automatically falls back to high-performance TCP socket checks if ICMP fails or permissions are restricted.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from vping import ping
|
|
29
|
+
|
|
30
|
+
if ping("8.8.8.8"):
|
|
31
|
+
print("Host is alive!")
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
CLI usage:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python -m vping 8.8.8.8
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 👤 Author
|
|
43
|
+
|
|
44
|
+
[Hadi Cahyadi](mailto:cumulus13@gmail.com)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
[](https://www.buymeacoffee.com/cumulus13)
|
|
48
|
+
|
|
49
|
+
[](https://ko-fi.com/cumulus13)
|
|
50
|
+
|
|
51
|
+
[Support me on Patreon](https://www.patreon.com/cumulus13)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
vping/__init__.py,sha256=O9qLcru4zBqRls-KLq9rkQ2SXZBsPJ_OV3ylGwj5li4,221
|
|
2
|
+
vping/__main__.py,sha256=DEYSB_5lzNirdEBbULxJ0K7ZhwxNoxMgWYdAuBIr0p8,625
|
|
3
|
+
vping/core.py,sha256=qrscSJCrR10q89fP02XZ3mwzRnY6jEzzraecp1d2Ffo,1704
|
|
4
|
+
vping-1.0.1.dist-info/METADATA,sha256=2EK4bt6hSBq-J-c26048dYILmCZL6I_3r_-yrIuDzRY,1614
|
|
5
|
+
vping-1.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
vping-1.0.1.dist-info/entry_points.txt,sha256=zwfByyVNsO33vH0gn20ysu_07mqXC75Ao8LkGJAQxs8,46
|
|
7
|
+
vping-1.0.1.dist-info/top_level.txt,sha256=Ii-eMmQxPo-TPAnrzoOKno1HHJDUW8EEJ-rH8VO0jZ4,6
|
|
8
|
+
vping-1.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
vping
|