k3net
Utility functions for network related operation.
k3net is a component of pykit3 project: a python3 toolkit set.
Install
pip install k3net
Synopsis
import k3net
if __name__ == "__main__":
# Check if an IP is valid IPv4
print(k3net.is_ip4("192.168.0.1")) # True
print(k3net.is_ip4("invalid")) # False
# Check if IP is public or private (INN)
print(k3net.is_pub("1.2.3.4")) # True
print(k3net.is_inn("192.168.0.1")) # True
# Get IP class
print(k3net.ip_class("1.2.3.4")) # PUB
print(k3net.ip_class("192.168.0.1")) # INN
# Select IPs by class
ips = ["1.2.3.4", "192.168.0.1", "10.0.0.1"]
print(k3net.choose_pub(ips)) # ['1.2.3.4']
print(k3net.choose_inn(ips)) # ['192.168.0.1', '10.0.0.1']
# Prefer public or private IPs
print(k3net.ips_prefer(ips, k3net.PUB)) # Public IPs first
print(k3net.ips_prefer(ips, k3net.INN)) # Private IPs first
# Get host IP addresses
host_ips = k3net.get_host_ip4()
print(host_ips) # List of host IPv4 addresses
# IP to number conversion
num = k3net.ip_to_num("192.168.0.1")
print(num) # 3232235521
print(k3net.num_to_ip(num)) # '192.168.0.1'
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Metadata
Release files for k3net 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| k3net-0.1.9.tar.gz | 9.4 kB | Without provenance | Details for k3net-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| k3net-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for k3net-0.1.9-py3-none-any.whl |
Total release size: 16.9 kB
Release files / k3net-0.1.9.tar.gz
| Download URL | k3net-0.1.9.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6782f3112b2915941ae67dd21b5905b80f793f3466691f9ee5eb1e967ae3e895
|
|
BLAKE2b-256 checksum How to use checksums |
0d88814336d2cbaf5f7f46b208ca0f9abfa34b2e0b38ecb2f2bf3b9f36551144
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / k3net-0.1.9-py3-none-any.whl
| Download URL | k3net-0.1.9-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ad7e5bdbc976dc15b6d45cb37d0fd53270653621ac9559d8915c5d6b79e826a
|
|
BLAKE2b-256 checksum How to use checksums |
74dc2c4eff132367455348f14436486cccf47a6f7e9dad96366471c435badd53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for k3net 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.