sipinfo-cli 0.1.0__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.
ipinfo_cli/__init__.py
ADDED
|
File without changes
|
ipinfo_cli/main.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
def main():
|
|
2
|
+
# your existing code
|
|
3
|
+
import sys
|
|
4
|
+
import requests
|
|
5
|
+
import ipaddress
|
|
6
|
+
from colorama import init, Fore, Style
|
|
7
|
+
init(autoreset=True)
|
|
8
|
+
|
|
9
|
+
argv = sys.argv
|
|
10
|
+
try:
|
|
11
|
+
if len(argv) != 2:
|
|
12
|
+
raise ValueError("Usage: ipinfo <ip>")
|
|
13
|
+
ip_addr = ipaddress.ip_address(argv[1])
|
|
14
|
+
if ip_addr.is_private:
|
|
15
|
+
raise ValueError(f"{ip_addr} is a private addr")
|
|
16
|
+
if ip_addr.is_loopback:
|
|
17
|
+
raise ValueError(f"{ip_addr} is a loopback addr")
|
|
18
|
+
res = requests.get(f"https://ipinfo.io/{ip_addr}/json", timeout=5)
|
|
19
|
+
res.raise_for_status()
|
|
20
|
+
data = res.json()
|
|
21
|
+
print(f"{Fore.CYAN}──────────────────────────")
|
|
22
|
+
print(f" IP Info")
|
|
23
|
+
print(f"──────────────────────────{Style.RESET_ALL}")
|
|
24
|
+
print(f"{Fore.MAGENTA} ip :{Fore.WHITE} {data.get('ip')}")
|
|
25
|
+
print(f"{Fore.MAGENTA} city :{Fore.WHITE} {data.get('city')}")
|
|
26
|
+
print(f"{Fore.MAGENTA} country :{Fore.WHITE} {data.get('country')}")
|
|
27
|
+
print(f"{Fore.MAGENTA} org :{Fore.WHITE} {data.get('org')}")
|
|
28
|
+
print(f"{Fore.MAGENTA} timezone :{Fore.WHITE} {data.get('timezone')}")
|
|
29
|
+
print(f"{Fore.CYAN}──────────────────────────")
|
|
30
|
+
except requests.exceptions.ConnectionError:
|
|
31
|
+
print(f"{Fore.RED} no internet connection")
|
|
32
|
+
except Exception as e:
|
|
33
|
+
print(f"{Fore.RED} {e}")
|
|
34
|
+
|
|
35
|
+
if __name__ == '__main__':
|
|
36
|
+
main()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sipinfo-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Get IP information from terminal
|
|
5
|
+
Author-email: Mehdi <elmehdiiskandar3@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: requests
|
|
10
|
+
Requires-Dist: colorama
|
|
11
|
+
|
|
12
|
+
# IPInfo
|
|
13
|
+
|
|
14
|
+
A command-line tool to get detailed information about any public IP address.
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git clone https://github.com/Mehdi23-bit/ipinfo
|
|
19
|
+
cd ipinfo
|
|
20
|
+
pip install -r requirements.txt
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python ipinfo.py <ip>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
python ipinfo.py 8.8.8.8
|
|
33
|
+
python ipinfo.py 1.1.1.1
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Error Handling
|
|
37
|
+
|
|
38
|
+
| Input | Response |
|
|
39
|
+
|-------------|-------------------|
|
|
40
|
+
| Private IP | private addr |
|
|
41
|
+
| Loopback | loopback addr |
|
|
42
|
+
| Invalid IP | not a valid IP |
|
|
43
|
+
| No argument | Usage message |
|
|
44
|
+
| No internet | Connection error |
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
requests
|
|
48
|
+
colorama
|
|
49
|
+
## Author
|
|
50
|
+
|
|
51
|
+
**Mehdi** — [@Mehdi23-bit](https://github.com/Mehdi23-bit)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ipinfo_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
ipinfo_cli/main.py,sha256=VRxLVOY6wozyQtg5O04j1fT70XK0puprY_FXTfR9sLg,1577
|
|
3
|
+
sipinfo_cli-0.1.0.dist-info/METADATA,sha256=NxHIalgebRQZ4YPqkziTh0LG_0naWOiOZdgO4OpamAE,978
|
|
4
|
+
sipinfo_cli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
sipinfo_cli-0.1.0.dist-info/entry_points.txt,sha256=S-bfCjNYgsBTRvHKyOnK9inXLKePZX_znWa4DmGzgiU,48
|
|
6
|
+
sipinfo_cli-0.1.0.dist-info/top_level.txt,sha256=-1UIWVhfsWqSl25LsEHiXdaWfeacGhbffnf7nYpx5oc,11
|
|
7
|
+
sipinfo_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ipinfo_cli
|