ipspot 0.2__tar.gz → 0.4__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.
@@ -1,6 +1,8 @@
1
1
  # Core Developers
2
2
  ----------
3
3
  - Sepand Haghighi - Open Science Laboratory ([Github](https://github.com/sepandhaghighi)) **
4
+ - Sadra Sabouri - Open Science Laboratory ([Github](https://github.com/sadrasabouri))
5
+ - AmirHosein Rostami - Open Science Laboratory ([Github](https://github.com/AHReccese))
4
6
 
5
7
  ** **Maintainer**
6
8
 
@@ -0,0 +1,74 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ## [0.4] - 2025-06-09
9
+ ### Added
10
+ - Support [ipapi.co](https://ipapi.co/json/)
11
+ - Support [ipleak.net](https://ipleak.net/json/)
12
+ - Support [my-ip.io](https://www.my-ip.io/)
13
+ - Support [ifconfig.co](https://ifconfig.co/json)
14
+ - Support [reallyfreegeoip.org](https://reallyfreegeoip.org/json/)
15
+ - Support [myip.la](https://api.myip.la/en?json)
16
+ - Support [freeipapi.com](https://freeipapi.com/api/json/)
17
+ - `AUTO_SAFE` mode
18
+ - `_get_json_standard` function
19
+ - `_get_json_ipv4_forced` function
20
+ - `--max-retries` argument
21
+ - `--retry-delay` argument
22
+ ### Changed
23
+ - `IPv4API.IPAPI` renamed to `IPv4API.IP_API_COM`
24
+ - `IPv4API.IPINFO` renamed to `IPv4API.IPINFO_IO`
25
+ - `IPv4API.IPSB` renamed to `IPv4API.IP_SB`
26
+ - `IPv4API.IDENTME` renamed to `IPv4API.IDENT_ME`
27
+ - `IPv4API.TNEDIME` renamed to `IPv4API.TNEDI_ME`
28
+ - `get_public_ipv4` function modified
29
+ - `filter_parameter` function renamed to `_filter_parameter`
30
+ - `README.md` updated
31
+ ## [0.3] - 2025-05-19
32
+ ### Added
33
+ - `is_ipv4` function
34
+ - `is_loopback` function
35
+ - `IPv4HTTPAdapter` class
36
+ - Support [ident.me](https://ident.me/json)
37
+ - Support [tnedi.me](https://tnedi.me/json)
38
+ ### Changed
39
+ - `get_private_ipv4` function modified
40
+ - `get_public_ipv4` function modified
41
+ - `_ipsb_ipv4` function modified
42
+ - `_ipapi_ipv4` function modified
43
+ - `_ipinfo_ipv4` function modified
44
+ - `functions.py` renamed to `utils.py`
45
+ - CLI functions moved to `cli.py`
46
+ - IPv4 functions moved to `ipv4.py`
47
+ - Test system modified
48
+ ## [0.2] - 2025-05-04
49
+ ### Added
50
+ - Support [ip.sb](https://api.ip.sb/geoip)
51
+ - `--timeout` argument
52
+ ### Changed
53
+ - `README.md` updated
54
+ - Requests header updated
55
+ - Test system modified
56
+ ## [0.1] - 2025-04-25
57
+ ### Added
58
+ - Support [ipinfo.io](https://ipinfo.io)
59
+ - Support [ip-api.com](https://ip-api.com)
60
+ - `get_private_ipv4` function
61
+ - `get_public_ipv4` function
62
+ - `--info` and `--version` arguments
63
+ - `--ipv4-api` argument
64
+ - `--no-geo` argument
65
+ - Logo
66
+
67
+ [Unreleased]: https://github.com/openscilab/ipspot/compare/v0.4...dev
68
+ [0.4]: https://github.com/openscilab/ipspot/compare/v0.3...v0.4
69
+ [0.3]: https://github.com/openscilab/ipspot/compare/v0.2...v0.3
70
+ [0.2]: https://github.com/openscilab/ipspot/compare/v0.1...v0.2
71
+ [0.1]: https://github.com/openscilab/ipspot/compare/3216fb7...v0.1
72
+
73
+
74
+
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipspot
3
- Version: 0.2
3
+ Version: 0.4
4
4
  Summary: IPSpot: A Python Tool to Fetch the System's IP Address
5
5
  Home-page: https://github.com/openscilab/ipspot
6
- Download-URL: https://github.com/openscilab/ipspot/tarball/v0.2
6
+ Download-URL: https://github.com/openscilab/ipspot/tarball/v0.4
7
7
  Author: IPSpot Development Team
8
8
  Author-email: ipspot@openscilab.com
9
9
  License: MIT
@@ -102,13 +102,13 @@ Dynamic: summary
102
102
  ## Installation
103
103
 
104
104
  ### Source Code
105
- - Download [Version 0.2](https://github.com/openscilab/ipspot/archive/v0.2.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
105
+ - Download [Version 0.4](https://github.com/openscilab/ipspot/archive/v0.4.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
106
106
  - `pip install .`
107
107
 
108
108
  ### PyPI
109
109
 
110
110
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
111
- - `pip install ipspot==0.2`
111
+ - `pip install ipspot==0.4`
112
112
 
113
113
 
114
114
  ## Usage
@@ -119,9 +119,11 @@ Dynamic: summary
119
119
 
120
120
  ```pycon
121
121
  >>> from ipspot import get_public_ipv4, IPv4API
122
- >>> get_public_ipv4(api=IPv4API.IPAPI)
122
+ >>> get_public_ipv4(api=IPv4API.IP_API_COM)
123
123
  {'status': True, 'data': {'ip': 'xx.xx.xx.xx', 'api': 'ip-api.com'}}
124
- >>> get_public_ipv4(api=IPv4API.IPAPI, geo=True, timeout=10)
124
+ >>> get_public_ipv4(api=IPv4API.IP_API_COM, geo=True, timeout=10)
125
+ {'data': {'country_code': 'GB', 'latitude': 50.9097, 'longitude': -1.4043, 'api': 'ip-api.com', 'country': 'United Kingdom', 'timezone': 'Europe/London', 'organization': '', 'region': 'England', 'ip': 'xx.xx.xx.xx', 'city': 'Southampton'}, 'status': True}
126
+ >>> get_public_ipv4(api=IPv4API.IP_API_COM, geo=True, timeout=10, max_retries=5, retry_delay=4)
125
127
  {'data': {'country_code': 'GB', 'latitude': 50.9097, 'longitude': -1.4043, 'api': 'ip-api.com', 'country': 'United Kingdom', 'timezone': 'Europe/London', 'organization': '', 'region': 'England', 'ip': 'xx.xx.xx.xx', 'city': 'Southampton'}, 'status': True}
126
128
  ```
127
129
 
@@ -142,7 +144,7 @@ Dynamic: summary
142
144
  ```console
143
145
  > ipspot --version
144
146
 
145
- 0.2
147
+ 0.4
146
148
  ```
147
149
 
148
150
  #### Info
@@ -157,11 +159,11 @@ Dynamic: summary
157
159
  |___||_| |____/ | .__/ \___/ \__|
158
160
  |_|
159
161
 
160
- __ __ ___ ____
161
- \ \ / / _ / _ \ |___ \
162
- \ \ / / (_)| | | | __) |
163
- \ V / _ | |_| | _ / __/
164
- \_/ (_) \___/ (_)|_____|
162
+ __ __ ___ _ _
163
+ \ \ / / _ / _ \ | || |
164
+ \ \ / / (_)| | | | | || |_
165
+ \ V / _ | |_| | _ |__ _|
166
+ \_/ (_) \___/ (_) |_|
165
167
 
166
168
 
167
169
 
@@ -197,12 +199,12 @@ Public IP and Location Info:
197
199
 
198
200
  #### IPv4 API
199
201
 
200
- ℹ️ `ipv4-api` valid choices: [`auto`, `ipapi`, `ipinfo`, `ipsb`]
202
+ ℹ️ `ipv4-api` valid choices: [`auto-safe`, `auto`, `ip-api.com`, `ipinfo.io`, `ip.sb`, `ident.me`, `tnedi.me`, `ipapi.co`, `ipleak.net`, `my-ip.io`, `ifconfig.co`, `reallyfreegeoip.org`, `freeipapi.com`, `myip.la`]
201
203
 
202
- ℹ️ The default value: `auto`
204
+ ℹ️ The default value: `auto-safe`
203
205
 
204
206
  ```console
205
- > ipspot --ipv4-api="ipinfo"
207
+ > ipspot --ipv4-api="ipinfo.io"
206
208
  Private IP:
207
209
 
208
210
  10.36.18.154
@@ -267,6 +269,46 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
267
269
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
268
270
 
269
271
  ## [Unreleased]
272
+ ## [0.4] - 2025-06-09
273
+ ### Added
274
+ - Support [ipapi.co](https://ipapi.co/json/)
275
+ - Support [ipleak.net](https://ipleak.net/json/)
276
+ - Support [my-ip.io](https://www.my-ip.io/)
277
+ - Support [ifconfig.co](https://ifconfig.co/json)
278
+ - Support [reallyfreegeoip.org](https://reallyfreegeoip.org/json/)
279
+ - Support [myip.la](https://api.myip.la/en?json)
280
+ - Support [freeipapi.com](https://freeipapi.com/api/json/)
281
+ - `AUTO_SAFE` mode
282
+ - `_get_json_standard` function
283
+ - `_get_json_ipv4_forced` function
284
+ - `--max-retries` argument
285
+ - `--retry-delay` argument
286
+ ### Changed
287
+ - `IPv4API.IPAPI` renamed to `IPv4API.IP_API_COM`
288
+ - `IPv4API.IPINFO` renamed to `IPv4API.IPINFO_IO`
289
+ - `IPv4API.IPSB` renamed to `IPv4API.IP_SB`
290
+ - `IPv4API.IDENTME` renamed to `IPv4API.IDENT_ME`
291
+ - `IPv4API.TNEDIME` renamed to `IPv4API.TNEDI_ME`
292
+ - `get_public_ipv4` function modified
293
+ - `filter_parameter` function renamed to `_filter_parameter`
294
+ - `README.md` updated
295
+ ## [0.3] - 2025-05-19
296
+ ### Added
297
+ - `is_ipv4` function
298
+ - `is_loopback` function
299
+ - `IPv4HTTPAdapter` class
300
+ - Support [ident.me](https://ident.me/json)
301
+ - Support [tnedi.me](https://tnedi.me/json)
302
+ ### Changed
303
+ - `get_private_ipv4` function modified
304
+ - `get_public_ipv4` function modified
305
+ - `_ipsb_ipv4` function modified
306
+ - `_ipapi_ipv4` function modified
307
+ - `_ipinfo_ipv4` function modified
308
+ - `functions.py` renamed to `utils.py`
309
+ - CLI functions moved to `cli.py`
310
+ - IPv4 functions moved to `ipv4.py`
311
+ - Test system modified
270
312
  ## [0.2] - 2025-05-04
271
313
  ### Added
272
314
  - Support [ip.sb](https://api.ip.sb/geoip)
@@ -286,7 +328,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
286
328
  - `--no-geo` argument
287
329
  - Logo
288
330
 
289
- [Unreleased]: https://github.com/openscilab/ipspot/compare/v0.2...dev
331
+ [Unreleased]: https://github.com/openscilab/ipspot/compare/v0.4...dev
332
+ [0.4]: https://github.com/openscilab/ipspot/compare/v0.3...v0.4
333
+ [0.3]: https://github.com/openscilab/ipspot/compare/v0.2...v0.3
290
334
  [0.2]: https://github.com/openscilab/ipspot/compare/v0.1...v0.2
291
335
  [0.1]: https://github.com/openscilab/ipspot/compare/3216fb7...v0.1
292
336
 
@@ -52,13 +52,13 @@
52
52
  ## Installation
53
53
 
54
54
  ### Source Code
55
- - Download [Version 0.2](https://github.com/openscilab/ipspot/archive/v0.2.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
55
+ - Download [Version 0.4](https://github.com/openscilab/ipspot/archive/v0.4.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
56
56
  - `pip install .`
57
57
 
58
58
  ### PyPI
59
59
 
60
60
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
61
- - `pip install ipspot==0.2`
61
+ - `pip install ipspot==0.4`
62
62
 
63
63
 
64
64
  ## Usage
@@ -69,9 +69,11 @@
69
69
 
70
70
  ```pycon
71
71
  >>> from ipspot import get_public_ipv4, IPv4API
72
- >>> get_public_ipv4(api=IPv4API.IPAPI)
72
+ >>> get_public_ipv4(api=IPv4API.IP_API_COM)
73
73
  {'status': True, 'data': {'ip': 'xx.xx.xx.xx', 'api': 'ip-api.com'}}
74
- >>> get_public_ipv4(api=IPv4API.IPAPI, geo=True, timeout=10)
74
+ >>> get_public_ipv4(api=IPv4API.IP_API_COM, geo=True, timeout=10)
75
+ {'data': {'country_code': 'GB', 'latitude': 50.9097, 'longitude': -1.4043, 'api': 'ip-api.com', 'country': 'United Kingdom', 'timezone': 'Europe/London', 'organization': '', 'region': 'England', 'ip': 'xx.xx.xx.xx', 'city': 'Southampton'}, 'status': True}
76
+ >>> get_public_ipv4(api=IPv4API.IP_API_COM, geo=True, timeout=10, max_retries=5, retry_delay=4)
75
77
  {'data': {'country_code': 'GB', 'latitude': 50.9097, 'longitude': -1.4043, 'api': 'ip-api.com', 'country': 'United Kingdom', 'timezone': 'Europe/London', 'organization': '', 'region': 'England', 'ip': 'xx.xx.xx.xx', 'city': 'Southampton'}, 'status': True}
76
78
  ```
77
79
 
@@ -92,7 +94,7 @@
92
94
  ```console
93
95
  > ipspot --version
94
96
 
95
- 0.2
97
+ 0.4
96
98
  ```
97
99
 
98
100
  #### Info
@@ -107,11 +109,11 @@
107
109
  |___||_| |____/ | .__/ \___/ \__|
108
110
  |_|
109
111
 
110
- __ __ ___ ____
111
- \ \ / / _ / _ \ |___ \
112
- \ \ / / (_)| | | | __) |
113
- \ V / _ | |_| | _ / __/
114
- \_/ (_) \___/ (_)|_____|
112
+ __ __ ___ _ _
113
+ \ \ / / _ / _ \ | || |
114
+ \ \ / / (_)| | | | | || |_
115
+ \ V / _ | |_| | _ |__ _|
116
+ \_/ (_) \___/ (_) |_|
115
117
 
116
118
 
117
119
 
@@ -147,12 +149,12 @@ Public IP and Location Info:
147
149
 
148
150
  #### IPv4 API
149
151
 
150
- ℹ️ `ipv4-api` valid choices: [`auto`, `ipapi`, `ipinfo`, `ipsb`]
152
+ ℹ️ `ipv4-api` valid choices: [`auto-safe`, `auto`, `ip-api.com`, `ipinfo.io`, `ip.sb`, `ident.me`, `tnedi.me`, `ipapi.co`, `ipleak.net`, `my-ip.io`, `ifconfig.co`, `reallyfreegeoip.org`, `freeipapi.com`, `myip.la`]
151
153
 
152
- ℹ️ The default value: `auto`
154
+ ℹ️ The default value: `auto-safe`
153
155
 
154
156
  ```console
155
- > ipspot --ipv4-api="ipinfo"
157
+ > ipspot --ipv4-api="ipinfo.io"
156
158
  Private IP:
157
159
 
158
160
  10.36.18.154
@@ -4,8 +4,8 @@
4
4
 
5
5
  | Version | Supported |
6
6
  | ------------- | ------------------ |
7
- | 0.2 | :white_check_mark: |
8
- | < 0.2 | :x: |
7
+ | 0.4 | :white_check_mark: |
8
+ | < 0.4 | :x: |
9
9
 
10
10
  ## Reporting a Vulnerability
11
11
 
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """ipspot modules."""
3
3
  from .params import IPSPOT_VERSION, IPv4API
4
- from .functions import get_private_ipv4, get_public_ipv4
4
+ from .ipv4 import get_private_ipv4, get_public_ipv4, is_ipv4
5
+ from .utils import is_loopback
5
6
  __version__ = IPSPOT_VERSION
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """ipspot main."""
3
- from .functions import main
3
+ from .cli import main
4
4
 
5
5
 
6
6
  if __name__ == "__main__":
@@ -0,0 +1,88 @@
1
+ # -*- coding: utf-8 -*-
2
+ """ipspot CLI."""
3
+ import argparse
4
+ from typing import Union, Tuple
5
+ from art import tprint
6
+ from .ipv4 import get_public_ipv4, get_private_ipv4
7
+ from .utils import _filter_parameter
8
+ from .params import IPv4API, PARAMETERS_NAME_MAP
9
+ from .params import IPSPOT_OVERVIEW, IPSPOT_REPO, IPSPOT_VERSION
10
+
11
+
12
+ def ipspot_info() -> None: # pragma: no cover
13
+ """Print ipspot details."""
14
+ tprint("IPSpot")
15
+ tprint("V:" + IPSPOT_VERSION)
16
+ print(IPSPOT_OVERVIEW)
17
+ print("Repo : " + IPSPOT_REPO)
18
+
19
+
20
+ def display_ip_info(ipv4_api: IPv4API = IPv4API.AUTO_SAFE, geo: bool=False,
21
+ timeout: Union[float, Tuple[float, float]]=5,
22
+ max_retries: int = 0, retry_delay: float = 1.0) -> None: # pragma: no cover
23
+ """
24
+ Print collected IP and location data.
25
+
26
+ :param ipv4_api: public IPv4 API
27
+ :param geo: geolocation flag
28
+ :param timeout: timeout value for API
29
+ :param max_retries: number of retries
30
+ :param retry_delay: delay between retries (in seconds)
31
+ """
32
+ private_result = get_private_ipv4()
33
+ print("Private IP:\n")
34
+ print(" IP: {private_result[data][ip]}".format(private_result=private_result) if private_result["status"]
35
+ else " Error: {private_result[error]}".format(private_result=private_result))
36
+
37
+ public_title = "\nPublic IP"
38
+ if geo:
39
+ public_title += " and Location Info"
40
+ public_title += ":\n"
41
+ print(public_title)
42
+ public_result = get_public_ipv4(
43
+ ipv4_api,
44
+ geo=geo,
45
+ timeout=timeout,
46
+ max_retries=max_retries,
47
+ retry_delay=retry_delay)
48
+ if public_result["status"]:
49
+ for name, parameter in sorted(public_result["data"].items()):
50
+ print(
51
+ " {name}: {parameter}".format(
52
+ name=PARAMETERS_NAME_MAP[name],
53
+ parameter=_filter_parameter(parameter)))
54
+ else:
55
+ print(" Error: {public_result[error]}".format(public_result=public_result))
56
+
57
+
58
+ def main() -> None: # pragma: no cover
59
+ """CLI main function."""
60
+ parser = argparse.ArgumentParser()
61
+ parser.add_argument(
62
+ '--ipv4-api',
63
+ help='public IPv4 API',
64
+ type=str.lower,
65
+ choices=[
66
+ x.value for x in IPv4API],
67
+ default=IPv4API.AUTO_SAFE.value)
68
+ parser.add_argument('--info', help='info', nargs="?", const=1)
69
+ parser.add_argument('--version', help='version', nargs="?", const=1)
70
+ parser.add_argument('--no-geo', help='no geolocation data', nargs="?", const=1, default=False)
71
+ parser.add_argument('--timeout', help='timeout for the API request', type=float, default=5.0)
72
+ parser.add_argument('--max-retries', help='number of retries', type=int, default=0)
73
+ parser.add_argument('--retry-delay', help='delay between retries (in seconds)', type=float, default=1.0)
74
+
75
+ args = parser.parse_args()
76
+ if args.version:
77
+ print(IPSPOT_VERSION)
78
+ elif args.info:
79
+ ipspot_info()
80
+ else:
81
+ ipv4_api = IPv4API(args.ipv4_api)
82
+ geo = not args.no_geo
83
+ display_ip_info(
84
+ ipv4_api=ipv4_api,
85
+ geo=geo,
86
+ timeout=args.timeout,
87
+ max_retries=args.max_retries,
88
+ retry_delay=args.retry_delay)