ipspot 0.0.0__tar.gz → 0.1__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.
- ipspot-0.1/AUTHORS.md +11 -0
- ipspot-0.1/CHANGELOG.md +23 -0
- ipspot-0.1/LICENSE +21 -0
- ipspot-0.1/MANIFEST.in +6 -0
- ipspot-0.1/PKG-INFO +271 -0
- ipspot-0.1/README.md +197 -0
- ipspot-0.1/SECURITY.md +14 -0
- ipspot-0.1/dev-requirements.txt +6 -0
- ipspot-0.1/ipspot/__init__.py +5 -0
- ipspot-0.1/ipspot/__main__.py +7 -0
- ipspot-0.1/ipspot/functions.py +179 -0
- ipspot-0.1/ipspot/params.py +35 -0
- ipspot-0.1/ipspot.egg-info/PKG-INFO +271 -0
- ipspot-0.1/ipspot.egg-info/SOURCES.txt +19 -0
- ipspot-0.1/ipspot.egg-info/entry_points.txt +2 -0
- ipspot-0.1/ipspot.egg-info/requires.txt +2 -0
- ipspot-0.1/requirements.txt +3 -0
- {ipspot-0.0.0 → ipspot-0.1}/setup.cfg +4 -4
- ipspot-0.1/setup.py +75 -0
- ipspot-0.0.0/PKG-INFO +0 -23
- ipspot-0.0.0/ipspot/__init__.py +0 -2
- ipspot-0.0.0/ipspot.egg-info/PKG-INFO +0 -23
- ipspot-0.0.0/ipspot.egg-info/SOURCES.txt +0 -6
- ipspot-0.0.0/ipspot_setup.py +0 -43
- {ipspot-0.0.0 → ipspot-0.1}/ipspot.egg-info/dependency_links.txt +0 -0
- {ipspot-0.0.0 → ipspot-0.1}/ipspot.egg-info/top_level.txt +0 -0
ipspot-0.1/AUTHORS.md
ADDED
ipspot-0.1/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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.1] - 2025-04-25
|
|
9
|
+
### Added
|
|
10
|
+
- Support [ipinfo.io](https://ipinfo.io)
|
|
11
|
+
- Support [ip-api.com](https://ip-api.com)
|
|
12
|
+
- `get_private_ipv4` function
|
|
13
|
+
- `get_public_ipv4` function
|
|
14
|
+
- `--info` and `--version` arguments
|
|
15
|
+
- `--ipv4-api` argument
|
|
16
|
+
- `--no-geo` argument
|
|
17
|
+
- Logo
|
|
18
|
+
|
|
19
|
+
[Unreleased]: https://github.com/openscilab/ipspot/compare/v0.1...dev
|
|
20
|
+
[0.1]: https://github.com/openscilab/ipspot/compare/3216fb7...v0.1
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
ipspot-0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 OpenSciLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ipspot-0.1/MANIFEST.in
ADDED
ipspot-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ipspot
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: IPSpot: A Python Tool to Fetch the System's IP Address
|
|
5
|
+
Home-page: https://github.com/openscilab/ipspot
|
|
6
|
+
Download-URL: https://github.com/openscilab/ipspot/tarball/v0.1
|
|
7
|
+
Author: IPSpot Development Team
|
|
8
|
+
Author-email: ipspot@openscilab.com
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Source, https://github.com/openscilab/ipspot
|
|
11
|
+
Keywords: ip ipv4 geo geolocation network location ipspot cli
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Intended Audience :: Developers
|
|
24
|
+
Classifier: Intended Audience :: Education
|
|
25
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
26
|
+
Classifier: Topic :: System :: Monitoring
|
|
27
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
28
|
+
Classifier: Topic :: Utilities
|
|
29
|
+
Requires-Python: >=3.7
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
License-File: AUTHORS.md
|
|
33
|
+
Requires-Dist: art>=5.3
|
|
34
|
+
Requires-Dist: requests>=2.20.0
|
|
35
|
+
Dynamic: author
|
|
36
|
+
Dynamic: author-email
|
|
37
|
+
Dynamic: classifier
|
|
38
|
+
Dynamic: description
|
|
39
|
+
Dynamic: description-content-type
|
|
40
|
+
Dynamic: download-url
|
|
41
|
+
Dynamic: home-page
|
|
42
|
+
Dynamic: keywords
|
|
43
|
+
Dynamic: license
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
Dynamic: project-url
|
|
46
|
+
Dynamic: requires-dist
|
|
47
|
+
Dynamic: requires-python
|
|
48
|
+
Dynamic: summary
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<div align="center">
|
|
52
|
+
<img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/logo.png" width="350">
|
|
53
|
+
<h1>IPSpot: A Python Tool to Fetch the System's IP Address</h1>
|
|
54
|
+
<br/>
|
|
55
|
+
<a href="https://badge.fury.io/py/ipspot"><img src="https://badge.fury.io/py/ipspot.svg" alt="PyPI version"></a>
|
|
56
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"></a>
|
|
57
|
+
<a href="https://github.com/openscilab/ipspot"><img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/openscilab/ipspot"></a>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
## Overview
|
|
61
|
+
|
|
62
|
+
<p align="justify">
|
|
63
|
+
<b>IPSpot</b> is a Python library for retrieving the current system's IP address and location information. It currently supports public and private <b>IPv4</b> detection using multiple API providers with a fallback mechanism for reliability. Designed with simplicity and modularity in mind, <b>IPSpot</b> offers quick IP and geolocation lookups directly from your machine.
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
<table>
|
|
67
|
+
<tr>
|
|
68
|
+
<td align="center">PyPI Counter</td>
|
|
69
|
+
<td align="center"><a href="http://pepy.tech/project/ipspot"><img src="http://pepy.tech/badge/ipspot"></a></td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td align="center">Github Stars</td>
|
|
73
|
+
<td align="center"><a href="https://github.com/openscilab/ipspot"><img src="https://img.shields.io/github/stars/openscilab/ipspot.svg?style=social&label=Stars"></a></td>
|
|
74
|
+
</tr>
|
|
75
|
+
</table>
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<table>
|
|
80
|
+
<tr>
|
|
81
|
+
<td align="center">Branch</td>
|
|
82
|
+
<td align="center">main</td>
|
|
83
|
+
<td align="center">dev</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td align="center">CI</td>
|
|
87
|
+
<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=main"></td>
|
|
88
|
+
<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=dev"></td>
|
|
89
|
+
</tr>
|
|
90
|
+
</table>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
### Source Code
|
|
96
|
+
- Download [Version 0.1](https://github.com/openscilab/ipspot/archive/v0.1.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
|
|
97
|
+
- `pip install .`
|
|
98
|
+
|
|
99
|
+
### PyPI
|
|
100
|
+
|
|
101
|
+
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
102
|
+
- `pip install ipspot==0.1`
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
### Library
|
|
108
|
+
|
|
109
|
+
#### Public IPv4
|
|
110
|
+
|
|
111
|
+
```pycon
|
|
112
|
+
>>> from ipspot import get_public_ipv4, IPv4API
|
|
113
|
+
>>> get_public_ipv4(api=IPv4API.IPAPI)
|
|
114
|
+
{'status': True, 'data': {'ip': 'xx.xx.xx.xx', 'api': 'ip-api.com'}}
|
|
115
|
+
>>> get_public_ipv4(api=IPv4API.IPAPI, geo=True)
|
|
116
|
+
{'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}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Private IPv4
|
|
120
|
+
|
|
121
|
+
```pycon
|
|
122
|
+
>>> from ipspot import get_private_ipv4
|
|
123
|
+
>>> get_private_ipv4()
|
|
124
|
+
{'status': True, 'data': {'ip': '10.36.18.154'}}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### CLI
|
|
128
|
+
|
|
129
|
+
ℹ️ You can use `ipspot` or `python -m ipspot` to run this program
|
|
130
|
+
|
|
131
|
+
#### Version
|
|
132
|
+
|
|
133
|
+
```console
|
|
134
|
+
> ipspot --version
|
|
135
|
+
|
|
136
|
+
0.1
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Info
|
|
140
|
+
|
|
141
|
+
```console
|
|
142
|
+
> ipspot --info
|
|
143
|
+
|
|
144
|
+
___ ____ ____ _
|
|
145
|
+
|_ _|| _ \ / ___| _ __ ___ | |_
|
|
146
|
+
| | | |_) |\___ \ | '_ \ / _ \ | __|
|
|
147
|
+
| | | __/ ___) || |_) || (_) || |_
|
|
148
|
+
|___||_| |____/ | .__/ \___/ \__|
|
|
149
|
+
|_|
|
|
150
|
+
|
|
151
|
+
__ __ ___ _
|
|
152
|
+
\ \ / / _ / _ \ / |
|
|
153
|
+
\ \ / / (_)| | | | | |
|
|
154
|
+
\ V / _ | |_| | _ | |
|
|
155
|
+
\_/ (_) \___/ (_)|_|
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
IPSpot is a Python library for retrieving the current system's IP address and location information.
|
|
160
|
+
It currently supports public and private IPv4 detection using multiple API providers with a fallback mechanism for reliability.
|
|
161
|
+
Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.
|
|
162
|
+
|
|
163
|
+
Repo : https://github.com/openscilab/ipspot
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Basic
|
|
168
|
+
|
|
169
|
+
```console
|
|
170
|
+
> ipspot
|
|
171
|
+
Private IP:
|
|
172
|
+
|
|
173
|
+
10.36.18.154
|
|
174
|
+
|
|
175
|
+
Public IP and Location Info:
|
|
176
|
+
|
|
177
|
+
API: ip-api.com
|
|
178
|
+
City: Southampton
|
|
179
|
+
Country: United Kingdom
|
|
180
|
+
Country Code: GB
|
|
181
|
+
IP: xx.xx.xx.xx
|
|
182
|
+
Latitude: 50.9097
|
|
183
|
+
Longitude: -1.4043
|
|
184
|
+
Organization: N/A
|
|
185
|
+
Region: England
|
|
186
|
+
Timezone: Europe/London
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### IPv4 API
|
|
190
|
+
|
|
191
|
+
ℹ️ `ipv4-api` valid choices: [`auto`, `ipapi`, `ipinfo`]
|
|
192
|
+
|
|
193
|
+
ℹ️ The default value: `auto`
|
|
194
|
+
|
|
195
|
+
```console
|
|
196
|
+
> ipspot --ipv4-api="ipinfo"
|
|
197
|
+
Private IP:
|
|
198
|
+
|
|
199
|
+
10.36.18.154
|
|
200
|
+
|
|
201
|
+
Public IP and Location Info:
|
|
202
|
+
|
|
203
|
+
API: ipinfo.io
|
|
204
|
+
City: Leatherhead
|
|
205
|
+
Country: N/A
|
|
206
|
+
Country Code: GB
|
|
207
|
+
IP: xx.xx.xx.xx
|
|
208
|
+
Latitude: 51.2965
|
|
209
|
+
Longitude: -0.3338
|
|
210
|
+
Organization: AS212238 Datacamp Limited
|
|
211
|
+
Region: England
|
|
212
|
+
Timezone: Europe/London
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### No Geolocation
|
|
216
|
+
|
|
217
|
+
```console
|
|
218
|
+
> ipspot --no-geo
|
|
219
|
+
Private IP:
|
|
220
|
+
|
|
221
|
+
IP: 10.36.18.154
|
|
222
|
+
|
|
223
|
+
Public IP:
|
|
224
|
+
|
|
225
|
+
API: ipinfo.io
|
|
226
|
+
IP: xx.xx.xx.xx
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Issues & Bug Reports
|
|
230
|
+
|
|
231
|
+
Just fill an issue and describe it. We'll check it ASAP!
|
|
232
|
+
|
|
233
|
+
- Please complete the issue template
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Show Your Support
|
|
237
|
+
|
|
238
|
+
<h3>Star This Repo</h3>
|
|
239
|
+
|
|
240
|
+
Give a ⭐️ if this project helped you!
|
|
241
|
+
|
|
242
|
+
<h3>Donate to Our Project</h3>
|
|
243
|
+
|
|
244
|
+
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-)
|
|
245
|
+
|
|
246
|
+
<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/donation.png" height="90px" width="270px" alt="IPSpot Donation"></a>
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
# Changelog
|
|
250
|
+
All notable changes to this project will be documented in this file.
|
|
251
|
+
|
|
252
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
253
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
254
|
+
|
|
255
|
+
## [Unreleased]
|
|
256
|
+
## [0.1] - 2025-04-25
|
|
257
|
+
### Added
|
|
258
|
+
- Support [ipinfo.io](https://ipinfo.io)
|
|
259
|
+
- Support [ip-api.com](https://ip-api.com)
|
|
260
|
+
- `get_private_ipv4` function
|
|
261
|
+
- `get_public_ipv4` function
|
|
262
|
+
- `--info` and `--version` arguments
|
|
263
|
+
- `--ipv4-api` argument
|
|
264
|
+
- `--no-geo` argument
|
|
265
|
+
- Logo
|
|
266
|
+
|
|
267
|
+
[Unreleased]: https://github.com/openscilab/ipspot/compare/v0.1...dev
|
|
268
|
+
[0.1]: https://github.com/openscilab/ipspot/compare/3216fb7...v0.1
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
ipspot-0.1/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/logo.png" width="350">
|
|
3
|
+
<h1>IPSpot: A Python Tool to Fetch the System's IP Address</h1>
|
|
4
|
+
<br/>
|
|
5
|
+
<a href="https://badge.fury.io/py/ipspot"><img src="https://badge.fury.io/py/ipspot.svg" alt="PyPI version"></a>
|
|
6
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"></a>
|
|
7
|
+
<a href="https://github.com/openscilab/ipspot"><img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/openscilab/ipspot"></a>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
<p align="justify">
|
|
13
|
+
<b>IPSpot</b> is a Python library for retrieving the current system's IP address and location information. It currently supports public and private <b>IPv4</b> detection using multiple API providers with a fallback mechanism for reliability. Designed with simplicity and modularity in mind, <b>IPSpot</b> offers quick IP and geolocation lookups directly from your machine.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<table>
|
|
17
|
+
<tr>
|
|
18
|
+
<td align="center">PyPI Counter</td>
|
|
19
|
+
<td align="center"><a href="http://pepy.tech/project/ipspot"><img src="http://pepy.tech/badge/ipspot"></a></td>
|
|
20
|
+
</tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td align="center">Github Stars</td>
|
|
23
|
+
<td align="center"><a href="https://github.com/openscilab/ipspot"><img src="https://img.shields.io/github/stars/openscilab/ipspot.svg?style=social&label=Stars"></a></td>
|
|
24
|
+
</tr>
|
|
25
|
+
</table>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<table>
|
|
30
|
+
<tr>
|
|
31
|
+
<td align="center">Branch</td>
|
|
32
|
+
<td align="center">main</td>
|
|
33
|
+
<td align="center">dev</td>
|
|
34
|
+
</tr>
|
|
35
|
+
<tr>
|
|
36
|
+
<td align="center">CI</td>
|
|
37
|
+
<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=main"></td>
|
|
38
|
+
<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=dev"></td>
|
|
39
|
+
</tr>
|
|
40
|
+
</table>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
### Source Code
|
|
46
|
+
- Download [Version 0.1](https://github.com/openscilab/ipspot/archive/v0.1.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
|
|
47
|
+
- `pip install .`
|
|
48
|
+
|
|
49
|
+
### PyPI
|
|
50
|
+
|
|
51
|
+
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
52
|
+
- `pip install ipspot==0.1`
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### Library
|
|
58
|
+
|
|
59
|
+
#### Public IPv4
|
|
60
|
+
|
|
61
|
+
```pycon
|
|
62
|
+
>>> from ipspot import get_public_ipv4, IPv4API
|
|
63
|
+
>>> get_public_ipv4(api=IPv4API.IPAPI)
|
|
64
|
+
{'status': True, 'data': {'ip': 'xx.xx.xx.xx', 'api': 'ip-api.com'}}
|
|
65
|
+
>>> get_public_ipv4(api=IPv4API.IPAPI, geo=True)
|
|
66
|
+
{'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}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Private IPv4
|
|
70
|
+
|
|
71
|
+
```pycon
|
|
72
|
+
>>> from ipspot import get_private_ipv4
|
|
73
|
+
>>> get_private_ipv4()
|
|
74
|
+
{'status': True, 'data': {'ip': '10.36.18.154'}}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### CLI
|
|
78
|
+
|
|
79
|
+
ℹ️ You can use `ipspot` or `python -m ipspot` to run this program
|
|
80
|
+
|
|
81
|
+
#### Version
|
|
82
|
+
|
|
83
|
+
```console
|
|
84
|
+
> ipspot --version
|
|
85
|
+
|
|
86
|
+
0.1
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Info
|
|
90
|
+
|
|
91
|
+
```console
|
|
92
|
+
> ipspot --info
|
|
93
|
+
|
|
94
|
+
___ ____ ____ _
|
|
95
|
+
|_ _|| _ \ / ___| _ __ ___ | |_
|
|
96
|
+
| | | |_) |\___ \ | '_ \ / _ \ | __|
|
|
97
|
+
| | | __/ ___) || |_) || (_) || |_
|
|
98
|
+
|___||_| |____/ | .__/ \___/ \__|
|
|
99
|
+
|_|
|
|
100
|
+
|
|
101
|
+
__ __ ___ _
|
|
102
|
+
\ \ / / _ / _ \ / |
|
|
103
|
+
\ \ / / (_)| | | | | |
|
|
104
|
+
\ V / _ | |_| | _ | |
|
|
105
|
+
\_/ (_) \___/ (_)|_|
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
IPSpot is a Python library for retrieving the current system's IP address and location information.
|
|
110
|
+
It currently supports public and private IPv4 detection using multiple API providers with a fallback mechanism for reliability.
|
|
111
|
+
Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.
|
|
112
|
+
|
|
113
|
+
Repo : https://github.com/openscilab/ipspot
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### Basic
|
|
118
|
+
|
|
119
|
+
```console
|
|
120
|
+
> ipspot
|
|
121
|
+
Private IP:
|
|
122
|
+
|
|
123
|
+
10.36.18.154
|
|
124
|
+
|
|
125
|
+
Public IP and Location Info:
|
|
126
|
+
|
|
127
|
+
API: ip-api.com
|
|
128
|
+
City: Southampton
|
|
129
|
+
Country: United Kingdom
|
|
130
|
+
Country Code: GB
|
|
131
|
+
IP: xx.xx.xx.xx
|
|
132
|
+
Latitude: 50.9097
|
|
133
|
+
Longitude: -1.4043
|
|
134
|
+
Organization: N/A
|
|
135
|
+
Region: England
|
|
136
|
+
Timezone: Europe/London
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### IPv4 API
|
|
140
|
+
|
|
141
|
+
ℹ️ `ipv4-api` valid choices: [`auto`, `ipapi`, `ipinfo`]
|
|
142
|
+
|
|
143
|
+
ℹ️ The default value: `auto`
|
|
144
|
+
|
|
145
|
+
```console
|
|
146
|
+
> ipspot --ipv4-api="ipinfo"
|
|
147
|
+
Private IP:
|
|
148
|
+
|
|
149
|
+
10.36.18.154
|
|
150
|
+
|
|
151
|
+
Public IP and Location Info:
|
|
152
|
+
|
|
153
|
+
API: ipinfo.io
|
|
154
|
+
City: Leatherhead
|
|
155
|
+
Country: N/A
|
|
156
|
+
Country Code: GB
|
|
157
|
+
IP: xx.xx.xx.xx
|
|
158
|
+
Latitude: 51.2965
|
|
159
|
+
Longitude: -0.3338
|
|
160
|
+
Organization: AS212238 Datacamp Limited
|
|
161
|
+
Region: England
|
|
162
|
+
Timezone: Europe/London
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### No Geolocation
|
|
166
|
+
|
|
167
|
+
```console
|
|
168
|
+
> ipspot --no-geo
|
|
169
|
+
Private IP:
|
|
170
|
+
|
|
171
|
+
IP: 10.36.18.154
|
|
172
|
+
|
|
173
|
+
Public IP:
|
|
174
|
+
|
|
175
|
+
API: ipinfo.io
|
|
176
|
+
IP: xx.xx.xx.xx
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Issues & Bug Reports
|
|
180
|
+
|
|
181
|
+
Just fill an issue and describe it. We'll check it ASAP!
|
|
182
|
+
|
|
183
|
+
- Please complete the issue template
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## Show Your Support
|
|
187
|
+
|
|
188
|
+
<h3>Star This Repo</h3>
|
|
189
|
+
|
|
190
|
+
Give a ⭐️ if this project helped you!
|
|
191
|
+
|
|
192
|
+
<h3>Donate to Our Project</h3>
|
|
193
|
+
|
|
194
|
+
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-)
|
|
195
|
+
|
|
196
|
+
<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/donation.png" height="90px" width="270px" alt="IPSpot Donation"></a>
|
|
197
|
+
|
ipspot-0.1/SECURITY.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------------- | ------------------ |
|
|
7
|
+
| 0.1 | :white_check_mark: |
|
|
8
|
+
| < 0.1 | :x: |
|
|
9
|
+
|
|
10
|
+
## Reporting a Vulnerability
|
|
11
|
+
|
|
12
|
+
Please report security vulnerabilities by email to [ipspot@openscilab.com](mailto:ipspot@openscilab.com "ipspot@openscilab.com").
|
|
13
|
+
|
|
14
|
+
If the security vulnerability is accepted, a dedicated bugfix release will be issued as soon as possible (depending on the complexity of the fix).
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""ipspot functions."""
|
|
3
|
+
import argparse
|
|
4
|
+
import socket
|
|
5
|
+
from typing import Union, Dict, Any
|
|
6
|
+
import requests
|
|
7
|
+
from art import tprint
|
|
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:
|
|
13
|
+
"""Print ipspot details."""
|
|
14
|
+
tprint("IPSpot")
|
|
15
|
+
tprint("V:" + IPSPOT_VERSION)
|
|
16
|
+
print(IPSPOT_OVERVIEW)
|
|
17
|
+
print(IPSPOT_REPO)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_private_ipv4() -> Dict[str, Union[bool, Dict[str, str], str]]:
|
|
21
|
+
"""Retrieve the private IPv4 address."""
|
|
22
|
+
try:
|
|
23
|
+
hostname = socket.gethostname()
|
|
24
|
+
private_ip = socket.gethostbyname(hostname)
|
|
25
|
+
return {"status": True, "data": {"ip": private_ip}}
|
|
26
|
+
except Exception as e:
|
|
27
|
+
return {"status": False, "error": str(e)}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _ipapi_ipv4(geo: bool=False) -> Dict[str, Union[bool, Dict[str, Union[str, float]], str]]:
|
|
31
|
+
"""
|
|
32
|
+
Get public IP and geolocation using ip-api.com.
|
|
33
|
+
|
|
34
|
+
:param geo: geolocation flag
|
|
35
|
+
"""
|
|
36
|
+
try:
|
|
37
|
+
response = requests.get("http://ip-api.com/json/", timeout=5)
|
|
38
|
+
response.raise_for_status()
|
|
39
|
+
data = response.json()
|
|
40
|
+
|
|
41
|
+
if data.get("status") != "success":
|
|
42
|
+
return {"status": False, "error": "ip-api lookup failed"}
|
|
43
|
+
result = {"status": True, "data": {"ip": data.get("query"), "api": "ip-api.com"}}
|
|
44
|
+
if geo:
|
|
45
|
+
geo_data = {
|
|
46
|
+
"city": data.get("city"),
|
|
47
|
+
"region": data.get("regionName"),
|
|
48
|
+
"country": data.get("country"),
|
|
49
|
+
"country_code": data.get("countryCode"),
|
|
50
|
+
"latitude": data.get("lat"),
|
|
51
|
+
"longitude": data.get("lon"),
|
|
52
|
+
"organization": data.get("org"),
|
|
53
|
+
"timezone": data.get("timezone")
|
|
54
|
+
}
|
|
55
|
+
result["data"].update(geo_data)
|
|
56
|
+
return result
|
|
57
|
+
except Exception as e:
|
|
58
|
+
return {"status": False, "error": str(e)}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _ipinfo_ipv4(geo: bool=False) -> Dict[str, Union[bool, Dict[str, Union[str, float]], str]]:
|
|
62
|
+
"""
|
|
63
|
+
Get public IP and geolocation using ipinfo.io.
|
|
64
|
+
|
|
65
|
+
:param geo: geolocation flag
|
|
66
|
+
"""
|
|
67
|
+
try:
|
|
68
|
+
response = requests.get("https://ipinfo.io/json", timeout=5)
|
|
69
|
+
response.raise_for_status()
|
|
70
|
+
data = response.json()
|
|
71
|
+
result = {"status": True, "data": {"ip": data.get("ip"), "api": "ipinfo.io"}}
|
|
72
|
+
if geo:
|
|
73
|
+
loc = data.get("loc", "").split(",")
|
|
74
|
+
geo_data = {
|
|
75
|
+
"city": data.get("city"),
|
|
76
|
+
"region": data.get("region"),
|
|
77
|
+
"country": None,
|
|
78
|
+
"country_code": data.get("country"),
|
|
79
|
+
"latitude": float(loc[0]) if len(loc) == 2 else None,
|
|
80
|
+
"longitude": float(loc[1]) if len(loc) == 2 else None,
|
|
81
|
+
"organization": data.get("org"),
|
|
82
|
+
"timezone": data.get("timezone")
|
|
83
|
+
}
|
|
84
|
+
result["data"].update(geo_data)
|
|
85
|
+
return result
|
|
86
|
+
except Exception as e:
|
|
87
|
+
return {"status": False, "error": str(e)}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def get_public_ipv4(api: IPv4API=IPv4API.AUTO,
|
|
91
|
+
geo: bool=False) -> Dict[str, Union[bool, Dict[str, Union[str, float]], str]]:
|
|
92
|
+
"""
|
|
93
|
+
Get public IPv4 and geolocation info based on the selected API.
|
|
94
|
+
|
|
95
|
+
:param api: public IPv4 API
|
|
96
|
+
:param geo: geolocation flag
|
|
97
|
+
"""
|
|
98
|
+
api_map = {
|
|
99
|
+
IPv4API.IPAPI: _ipapi_ipv4,
|
|
100
|
+
IPv4API.IPINFO: _ipinfo_ipv4,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if api == IPv4API.AUTO:
|
|
104
|
+
for _, func in api_map.items():
|
|
105
|
+
result = func(geo=geo)
|
|
106
|
+
if result["status"]:
|
|
107
|
+
return result
|
|
108
|
+
return {"status": False, "error": "All attempts failed."}
|
|
109
|
+
else:
|
|
110
|
+
func = api_map.get(api)
|
|
111
|
+
if func:
|
|
112
|
+
return func(geo=geo)
|
|
113
|
+
return {"status": False, "error": "Unsupported API: {api}".format(api=api)}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def filter_parameter(parameter: Any) -> Any:
|
|
117
|
+
"""
|
|
118
|
+
Filter input parameter.
|
|
119
|
+
|
|
120
|
+
:param parameter: input parameter
|
|
121
|
+
"""
|
|
122
|
+
if parameter is None:
|
|
123
|
+
return "N/A"
|
|
124
|
+
if isinstance(parameter, str) and len(parameter.strip()) == 0:
|
|
125
|
+
return "N/A"
|
|
126
|
+
return parameter
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def display_ip_info(ipv4_api: IPv4API = IPv4API.AUTO, geo: bool=False) -> None:
|
|
130
|
+
"""
|
|
131
|
+
Print collected IP and location data.
|
|
132
|
+
|
|
133
|
+
:param ipv4_api: public IPv4 API
|
|
134
|
+
:param geo: geolocation flag
|
|
135
|
+
"""
|
|
136
|
+
private_result = get_private_ipv4()
|
|
137
|
+
print("Private IP:\n")
|
|
138
|
+
print(" IP: {private_result[data][ip]}".format(private_result=private_result) if private_result["status"]
|
|
139
|
+
else " Error: {private_result[error]}".format(private_result=private_result))
|
|
140
|
+
|
|
141
|
+
public_title = "\nPublic IP"
|
|
142
|
+
if geo:
|
|
143
|
+
public_title += " and Location Info"
|
|
144
|
+
public_title += ":\n"
|
|
145
|
+
print(public_title)
|
|
146
|
+
public_result = get_public_ipv4(ipv4_api, geo=geo)
|
|
147
|
+
if public_result["status"]:
|
|
148
|
+
for name, parameter in sorted(public_result["data"].items()):
|
|
149
|
+
print(
|
|
150
|
+
" {name}: {parameter}".format(
|
|
151
|
+
name=PARAMETERS_NAME_MAP[name],
|
|
152
|
+
parameter=filter_parameter(parameter)))
|
|
153
|
+
else:
|
|
154
|
+
print(" Error: {public_result[error]}".format(public_result=public_result))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def main() -> None:
|
|
158
|
+
"""CLI main function."""
|
|
159
|
+
parser = argparse.ArgumentParser()
|
|
160
|
+
parser.add_argument(
|
|
161
|
+
'--ipv4-api',
|
|
162
|
+
help='public IPv4 API',
|
|
163
|
+
type=str.lower,
|
|
164
|
+
choices=[
|
|
165
|
+
x.value for x in IPv4API],
|
|
166
|
+
default=IPv4API.AUTO.value)
|
|
167
|
+
parser.add_argument('--info', help='info', nargs="?", const=1)
|
|
168
|
+
parser.add_argument('--version', help='version', nargs="?", const=1)
|
|
169
|
+
parser.add_argument('--no-geo', help='no geolocation data', nargs="?", const=1, default=False)
|
|
170
|
+
|
|
171
|
+
args = parser.parse_args()
|
|
172
|
+
if args.version:
|
|
173
|
+
print(IPSPOT_VERSION)
|
|
174
|
+
elif args.info:
|
|
175
|
+
ipspot_info()
|
|
176
|
+
else:
|
|
177
|
+
ipv4_api = IPv4API(args.ipv4_api)
|
|
178
|
+
geo = not args.no_geo
|
|
179
|
+
display_ip_info(ipv4_api=ipv4_api, geo=geo)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""ipspot params."""
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
IPSPOT_VERSION = "0.1"
|
|
6
|
+
|
|
7
|
+
IPSPOT_OVERVIEW = '''
|
|
8
|
+
IPSpot is a Python library for retrieving the current system's IP address and location information.
|
|
9
|
+
It currently supports public and private IPv4 detection using multiple API providers with a fallback mechanism for reliability.
|
|
10
|
+
Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.
|
|
11
|
+
'''
|
|
12
|
+
|
|
13
|
+
IPSPOT_REPO = "Repo : https://github.com/openscilab/ipspot"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class IPv4API(Enum):
|
|
17
|
+
"""Public IPv4 API enum."""
|
|
18
|
+
|
|
19
|
+
AUTO = "auto"
|
|
20
|
+
IPAPI = "ipapi"
|
|
21
|
+
IPINFO = "ipinfo"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
PARAMETERS_NAME_MAP = {
|
|
25
|
+
"ip": "IP",
|
|
26
|
+
"city": "City",
|
|
27
|
+
"region": "Region",
|
|
28
|
+
"country": "Country",
|
|
29
|
+
"country_code": "Country Code",
|
|
30
|
+
"timezone": "Timezone",
|
|
31
|
+
"latitude": "Latitude",
|
|
32
|
+
"longitude": "Longitude",
|
|
33
|
+
"organization": "Organization",
|
|
34
|
+
"api": "API"
|
|
35
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ipspot
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: IPSpot: A Python Tool to Fetch the System's IP Address
|
|
5
|
+
Home-page: https://github.com/openscilab/ipspot
|
|
6
|
+
Download-URL: https://github.com/openscilab/ipspot/tarball/v0.1
|
|
7
|
+
Author: IPSpot Development Team
|
|
8
|
+
Author-email: ipspot@openscilab.com
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Source, https://github.com/openscilab/ipspot
|
|
11
|
+
Keywords: ip ipv4 geo geolocation network location ipspot cli
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Intended Audience :: Developers
|
|
24
|
+
Classifier: Intended Audience :: Education
|
|
25
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
26
|
+
Classifier: Topic :: System :: Monitoring
|
|
27
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
28
|
+
Classifier: Topic :: Utilities
|
|
29
|
+
Requires-Python: >=3.7
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
License-File: AUTHORS.md
|
|
33
|
+
Requires-Dist: art>=5.3
|
|
34
|
+
Requires-Dist: requests>=2.20.0
|
|
35
|
+
Dynamic: author
|
|
36
|
+
Dynamic: author-email
|
|
37
|
+
Dynamic: classifier
|
|
38
|
+
Dynamic: description
|
|
39
|
+
Dynamic: description-content-type
|
|
40
|
+
Dynamic: download-url
|
|
41
|
+
Dynamic: home-page
|
|
42
|
+
Dynamic: keywords
|
|
43
|
+
Dynamic: license
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
Dynamic: project-url
|
|
46
|
+
Dynamic: requires-dist
|
|
47
|
+
Dynamic: requires-python
|
|
48
|
+
Dynamic: summary
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<div align="center">
|
|
52
|
+
<img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/logo.png" width="350">
|
|
53
|
+
<h1>IPSpot: A Python Tool to Fetch the System's IP Address</h1>
|
|
54
|
+
<br/>
|
|
55
|
+
<a href="https://badge.fury.io/py/ipspot"><img src="https://badge.fury.io/py/ipspot.svg" alt="PyPI version"></a>
|
|
56
|
+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"></a>
|
|
57
|
+
<a href="https://github.com/openscilab/ipspot"><img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/openscilab/ipspot"></a>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
## Overview
|
|
61
|
+
|
|
62
|
+
<p align="justify">
|
|
63
|
+
<b>IPSpot</b> is a Python library for retrieving the current system's IP address and location information. It currently supports public and private <b>IPv4</b> detection using multiple API providers with a fallback mechanism for reliability. Designed with simplicity and modularity in mind, <b>IPSpot</b> offers quick IP and geolocation lookups directly from your machine.
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
<table>
|
|
67
|
+
<tr>
|
|
68
|
+
<td align="center">PyPI Counter</td>
|
|
69
|
+
<td align="center"><a href="http://pepy.tech/project/ipspot"><img src="http://pepy.tech/badge/ipspot"></a></td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td align="center">Github Stars</td>
|
|
73
|
+
<td align="center"><a href="https://github.com/openscilab/ipspot"><img src="https://img.shields.io/github/stars/openscilab/ipspot.svg?style=social&label=Stars"></a></td>
|
|
74
|
+
</tr>
|
|
75
|
+
</table>
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<table>
|
|
80
|
+
<tr>
|
|
81
|
+
<td align="center">Branch</td>
|
|
82
|
+
<td align="center">main</td>
|
|
83
|
+
<td align="center">dev</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td align="center">CI</td>
|
|
87
|
+
<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=main"></td>
|
|
88
|
+
<td align="center"><img src="https://github.com/openscilab/ipspot/actions/workflows/test.yml/badge.svg?branch=dev"></td>
|
|
89
|
+
</tr>
|
|
90
|
+
</table>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
### Source Code
|
|
96
|
+
- Download [Version 0.1](https://github.com/openscilab/ipspot/archive/v0.1.zip) or [Latest Source](https://github.com/openscilab/ipspot/archive/dev.zip)
|
|
97
|
+
- `pip install .`
|
|
98
|
+
|
|
99
|
+
### PyPI
|
|
100
|
+
|
|
101
|
+
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
102
|
+
- `pip install ipspot==0.1`
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
|
|
107
|
+
### Library
|
|
108
|
+
|
|
109
|
+
#### Public IPv4
|
|
110
|
+
|
|
111
|
+
```pycon
|
|
112
|
+
>>> from ipspot import get_public_ipv4, IPv4API
|
|
113
|
+
>>> get_public_ipv4(api=IPv4API.IPAPI)
|
|
114
|
+
{'status': True, 'data': {'ip': 'xx.xx.xx.xx', 'api': 'ip-api.com'}}
|
|
115
|
+
>>> get_public_ipv4(api=IPv4API.IPAPI, geo=True)
|
|
116
|
+
{'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}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Private IPv4
|
|
120
|
+
|
|
121
|
+
```pycon
|
|
122
|
+
>>> from ipspot import get_private_ipv4
|
|
123
|
+
>>> get_private_ipv4()
|
|
124
|
+
{'status': True, 'data': {'ip': '10.36.18.154'}}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### CLI
|
|
128
|
+
|
|
129
|
+
ℹ️ You can use `ipspot` or `python -m ipspot` to run this program
|
|
130
|
+
|
|
131
|
+
#### Version
|
|
132
|
+
|
|
133
|
+
```console
|
|
134
|
+
> ipspot --version
|
|
135
|
+
|
|
136
|
+
0.1
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Info
|
|
140
|
+
|
|
141
|
+
```console
|
|
142
|
+
> ipspot --info
|
|
143
|
+
|
|
144
|
+
___ ____ ____ _
|
|
145
|
+
|_ _|| _ \ / ___| _ __ ___ | |_
|
|
146
|
+
| | | |_) |\___ \ | '_ \ / _ \ | __|
|
|
147
|
+
| | | __/ ___) || |_) || (_) || |_
|
|
148
|
+
|___||_| |____/ | .__/ \___/ \__|
|
|
149
|
+
|_|
|
|
150
|
+
|
|
151
|
+
__ __ ___ _
|
|
152
|
+
\ \ / / _ / _ \ / |
|
|
153
|
+
\ \ / / (_)| | | | | |
|
|
154
|
+
\ V / _ | |_| | _ | |
|
|
155
|
+
\_/ (_) \___/ (_)|_|
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
IPSpot is a Python library for retrieving the current system's IP address and location information.
|
|
160
|
+
It currently supports public and private IPv4 detection using multiple API providers with a fallback mechanism for reliability.
|
|
161
|
+
Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.
|
|
162
|
+
|
|
163
|
+
Repo : https://github.com/openscilab/ipspot
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Basic
|
|
168
|
+
|
|
169
|
+
```console
|
|
170
|
+
> ipspot
|
|
171
|
+
Private IP:
|
|
172
|
+
|
|
173
|
+
10.36.18.154
|
|
174
|
+
|
|
175
|
+
Public IP and Location Info:
|
|
176
|
+
|
|
177
|
+
API: ip-api.com
|
|
178
|
+
City: Southampton
|
|
179
|
+
Country: United Kingdom
|
|
180
|
+
Country Code: GB
|
|
181
|
+
IP: xx.xx.xx.xx
|
|
182
|
+
Latitude: 50.9097
|
|
183
|
+
Longitude: -1.4043
|
|
184
|
+
Organization: N/A
|
|
185
|
+
Region: England
|
|
186
|
+
Timezone: Europe/London
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### IPv4 API
|
|
190
|
+
|
|
191
|
+
ℹ️ `ipv4-api` valid choices: [`auto`, `ipapi`, `ipinfo`]
|
|
192
|
+
|
|
193
|
+
ℹ️ The default value: `auto`
|
|
194
|
+
|
|
195
|
+
```console
|
|
196
|
+
> ipspot --ipv4-api="ipinfo"
|
|
197
|
+
Private IP:
|
|
198
|
+
|
|
199
|
+
10.36.18.154
|
|
200
|
+
|
|
201
|
+
Public IP and Location Info:
|
|
202
|
+
|
|
203
|
+
API: ipinfo.io
|
|
204
|
+
City: Leatherhead
|
|
205
|
+
Country: N/A
|
|
206
|
+
Country Code: GB
|
|
207
|
+
IP: xx.xx.xx.xx
|
|
208
|
+
Latitude: 51.2965
|
|
209
|
+
Longitude: -0.3338
|
|
210
|
+
Organization: AS212238 Datacamp Limited
|
|
211
|
+
Region: England
|
|
212
|
+
Timezone: Europe/London
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### No Geolocation
|
|
216
|
+
|
|
217
|
+
```console
|
|
218
|
+
> ipspot --no-geo
|
|
219
|
+
Private IP:
|
|
220
|
+
|
|
221
|
+
IP: 10.36.18.154
|
|
222
|
+
|
|
223
|
+
Public IP:
|
|
224
|
+
|
|
225
|
+
API: ipinfo.io
|
|
226
|
+
IP: xx.xx.xx.xx
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Issues & Bug Reports
|
|
230
|
+
|
|
231
|
+
Just fill an issue and describe it. We'll check it ASAP!
|
|
232
|
+
|
|
233
|
+
- Please complete the issue template
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
## Show Your Support
|
|
237
|
+
|
|
238
|
+
<h3>Star This Repo</h3>
|
|
239
|
+
|
|
240
|
+
Give a ⭐️ if this project helped you!
|
|
241
|
+
|
|
242
|
+
<h3>Donate to Our Project</h3>
|
|
243
|
+
|
|
244
|
+
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-)
|
|
245
|
+
|
|
246
|
+
<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/ipspot/raw/main/otherfiles/donation.png" height="90px" width="270px" alt="IPSpot Donation"></a>
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
# Changelog
|
|
250
|
+
All notable changes to this project will be documented in this file.
|
|
251
|
+
|
|
252
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
253
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
254
|
+
|
|
255
|
+
## [Unreleased]
|
|
256
|
+
## [0.1] - 2025-04-25
|
|
257
|
+
### Added
|
|
258
|
+
- Support [ipinfo.io](https://ipinfo.io)
|
|
259
|
+
- Support [ip-api.com](https://ip-api.com)
|
|
260
|
+
- `get_private_ipv4` function
|
|
261
|
+
- `get_public_ipv4` function
|
|
262
|
+
- `--info` and `--version` arguments
|
|
263
|
+
- `--ipv4-api` argument
|
|
264
|
+
- `--no-geo` argument
|
|
265
|
+
- Logo
|
|
266
|
+
|
|
267
|
+
[Unreleased]: https://github.com/openscilab/ipspot/compare/v0.1...dev
|
|
268
|
+
[0.1]: https://github.com/openscilab/ipspot/compare/3216fb7...v0.1
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
AUTHORS.md
|
|
2
|
+
CHANGELOG.md
|
|
3
|
+
LICENSE
|
|
4
|
+
MANIFEST.in
|
|
5
|
+
README.md
|
|
6
|
+
SECURITY.md
|
|
7
|
+
dev-requirements.txt
|
|
8
|
+
requirements.txt
|
|
9
|
+
setup.py
|
|
10
|
+
ipspot/__init__.py
|
|
11
|
+
ipspot/__main__.py
|
|
12
|
+
ipspot/functions.py
|
|
13
|
+
ipspot/params.py
|
|
14
|
+
ipspot.egg-info/PKG-INFO
|
|
15
|
+
ipspot.egg-info/SOURCES.txt
|
|
16
|
+
ipspot.egg-info/dependency_links.txt
|
|
17
|
+
ipspot.egg-info/entry_points.txt
|
|
18
|
+
ipspot.egg-info/requires.txt
|
|
19
|
+
ipspot.egg-info/top_level.txt
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
ipspot-0.1/setup.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Setup module."""
|
|
3
|
+
from typing import List
|
|
4
|
+
try:
|
|
5
|
+
from setuptools import setup
|
|
6
|
+
except ImportError:
|
|
7
|
+
from distutils.core import setup
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_requires() -> List[str]:
|
|
11
|
+
"""Read requirements.txt."""
|
|
12
|
+
requirements = open("requirements.txt", "r").read()
|
|
13
|
+
return list(filter(lambda x: x != "", requirements.split()))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def read_description() -> str:
|
|
17
|
+
"""Read README.md and CHANGELOG.md."""
|
|
18
|
+
try:
|
|
19
|
+
with open("README.md") as r:
|
|
20
|
+
description = "\n"
|
|
21
|
+
description += r.read()
|
|
22
|
+
with open("CHANGELOG.md") as c:
|
|
23
|
+
description += "\n"
|
|
24
|
+
description += c.read()
|
|
25
|
+
return description
|
|
26
|
+
except Exception:
|
|
27
|
+
return '''IPSpot is a Python library for retrieving the current system's IP address and location information.
|
|
28
|
+
It currently supports public and local IPv4 detection using multiple API providers with a fallback mechanism for reliability.
|
|
29
|
+
Designed with simplicity and modularity in mind, IPSpot offers quick IP and geolocation lookups directly from your machine.'''
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
setup(
|
|
33
|
+
name='ipspot',
|
|
34
|
+
packages=['ipspot'],
|
|
35
|
+
version='0.1',
|
|
36
|
+
description='IPSpot: A Python Tool to Fetch the System\'s IP Address',
|
|
37
|
+
long_description=read_description(),
|
|
38
|
+
long_description_content_type='text/markdown',
|
|
39
|
+
include_package_data=True,
|
|
40
|
+
author='IPSpot Development Team',
|
|
41
|
+
author_email='ipspot@openscilab.com',
|
|
42
|
+
url='https://github.com/openscilab/ipspot',
|
|
43
|
+
download_url='https://github.com/openscilab/ipspot/tarball/v0.1',
|
|
44
|
+
keywords="ip ipv4 geo geolocation network location ipspot cli",
|
|
45
|
+
project_urls={
|
|
46
|
+
'Source': 'https://github.com/openscilab/ipspot'
|
|
47
|
+
},
|
|
48
|
+
install_requires=get_requires(),
|
|
49
|
+
python_requires='>=3.7',
|
|
50
|
+
classifiers=[
|
|
51
|
+
'Development Status :: 2 - Pre-Alpha',
|
|
52
|
+
'Natural Language :: English',
|
|
53
|
+
'License :: OSI Approved :: MIT License',
|
|
54
|
+
'Operating System :: OS Independent',
|
|
55
|
+
'Programming Language :: Python :: 3.7',
|
|
56
|
+
'Programming Language :: Python :: 3.8',
|
|
57
|
+
'Programming Language :: Python :: 3.9',
|
|
58
|
+
'Programming Language :: Python :: 3.10',
|
|
59
|
+
'Programming Language :: Python :: 3.11',
|
|
60
|
+
'Programming Language :: Python :: 3.12',
|
|
61
|
+
'Programming Language :: Python :: 3.13',
|
|
62
|
+
'Intended Audience :: Developers',
|
|
63
|
+
'Intended Audience :: Education',
|
|
64
|
+
'Intended Audience :: End Users/Desktop',
|
|
65
|
+
'Topic :: System :: Monitoring',
|
|
66
|
+
'Topic :: System :: Networking :: Monitoring',
|
|
67
|
+
'Topic :: Utilities',
|
|
68
|
+
],
|
|
69
|
+
license='MIT',
|
|
70
|
+
entry_points={
|
|
71
|
+
'console_scripts': [
|
|
72
|
+
'ipspot = ipspot.functions:main',
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
ipspot-0.0.0/PKG-INFO
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: ipspot
|
|
3
|
-
Version: 0.0.0
|
|
4
|
-
Summary: This name has been reserved using Reserver
|
|
5
|
-
Home-page: https://url.com
|
|
6
|
-
Download-URL: https://download_url.com
|
|
7
|
-
Author: Development Team
|
|
8
|
-
Author-email: test@test.com
|
|
9
|
-
License: MIT
|
|
10
|
-
Project-URL: Source, https://github.com/source
|
|
11
|
-
Keywords: python3 python reserve reserver reserved
|
|
12
|
-
Classifier: Development Status :: 1 - Planning
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
-
Requires-Python: >=3.6
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-
This name has been reserved using [Reserver](https://github.com/openscilab/reserver).
|
ipspot-0.0.0/ipspot/__init__.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: ipspot
|
|
3
|
-
Version: 0.0.0
|
|
4
|
-
Summary: This name has been reserved using Reserver
|
|
5
|
-
Home-page: https://url.com
|
|
6
|
-
Download-URL: https://download_url.com
|
|
7
|
-
Author: Development Team
|
|
8
|
-
Author-email: test@test.com
|
|
9
|
-
License: MIT
|
|
10
|
-
Project-URL: Source, https://github.com/source
|
|
11
|
-
Keywords: python3 python reserve reserver reserved
|
|
12
|
-
Classifier: Development Status :: 1 - Planning
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
-
Requires-Python: >=3.6
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-
This name has been reserved using [Reserver](https://github.com/openscilab/reserver).
|
ipspot-0.0.0/ipspot_setup.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
from setuptools import setup
|
|
6
|
-
except ImportError:
|
|
7
|
-
from distutils.core import setup
|
|
8
|
-
|
|
9
|
-
# invalid email
|
|
10
|
-
# download url
|
|
11
|
-
# url
|
|
12
|
-
# project urls
|
|
13
|
-
|
|
14
|
-
setup(
|
|
15
|
-
name ="ipspot",
|
|
16
|
-
packages=["ipspot",],
|
|
17
|
-
version='0.0.0',
|
|
18
|
-
description="This name has been reserved using Reserver",
|
|
19
|
-
long_description= "This name has been reserved using [Reserver](https://github.com/openscilab/reserver).",
|
|
20
|
-
long_description_content_type='text/markdown',
|
|
21
|
-
author="Development Team",
|
|
22
|
-
author_email="test@test.com",
|
|
23
|
-
url="https://url.com",
|
|
24
|
-
download_url="https://download_url.com",
|
|
25
|
-
keywords="python3 python reserve reserver reserved",
|
|
26
|
-
project_urls={
|
|
27
|
-
'Source':"https://github.com/source",
|
|
28
|
-
},
|
|
29
|
-
install_requires="",
|
|
30
|
-
python_requires='>=3.6',
|
|
31
|
-
classifiers=[
|
|
32
|
-
'Development Status :: 1 - Planning',
|
|
33
|
-
'Programming Language :: Python :: 3.6',
|
|
34
|
-
'Programming Language :: Python :: 3.7',
|
|
35
|
-
'Programming Language :: Python :: 3.8',
|
|
36
|
-
'Programming Language :: Python :: 3.9',
|
|
37
|
-
'Programming Language :: Python :: 3.10',
|
|
38
|
-
'Programming Language :: Python :: 3.11',
|
|
39
|
-
'Programming Language :: Python :: 3.12',
|
|
40
|
-
],
|
|
41
|
-
license="MIT",
|
|
42
|
-
)
|
|
43
|
-
|
|
File without changes
|
|
File without changes
|