Module and script to test local network membership (IPv4)
===========================================================
A set of utility functions and a command-line script useful in testing local
machine membership in IPv4 networks. Requires no external modules
("batteries-included" only).
Command-line usage
++++++++++++++++++
#. Sample usage
Test all network interfaces, and return success if any interface has an IP
address in the 10.100.3.0/24 network:
.. code-block:: bash
user@localhost$ local_net 10.100.3.0/24; echo $?
0
user@localhost$
Specific interfaces may be tested by inclusion of the -i/--iface flag, which
may be repeated:
.. code-block:: bash
user@localhost$ local_net -i etho -i wlan2 192.168.1.0/24
Asserting that no local interface is a member of a given network is also
possible by using the -n/--negate flag:
.. code-block:: bash
user@localhost$ local_net -n 10.1.0.0/16
Test success or failure is indicated by exit status code - 0 for success, 1
for failure. This allows for ease of use in conditional statements and other
tests (e.g. ssh config 'exec' testing). Exit status 64 is returned if an
unrecoverable error occurs (e.g. an interface was passed that does not exist),
and error information may be written to stderr. Otherwise, no output is made.
Requirements and compatibility
++++++++++++++++++++++++++++++
The code should work on any POSIX-compatible system, but has only been tested
on modern Linux installs. Pull requests and bug reports for other operating
systems are welcome. Supports Python versions 2.6+. Python versions < 3.3
require a system libc which supports if_nameindex() to get around lack of same
in socket module.
=========
Changelog
=========
All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
[0.2.0] - 2018-09-30
++++++++++++++++++++
Changed
-------
- Don't import ctypes until we need it.
- Catch exception from all_ifaces() in _main so we can exit correctly.
- Add LICENSE file
- Fix this CHANGELOG
[0.1.0] - 2018-09-30
++++++++++++++++++++
Added
-----
- CHANGELOG.rst
- MANIFEST.in
- README.rst
- localnet.py
- setup.cfg
- setup.py
- .gitignore
===========================================================
A set of utility functions and a command-line script useful in testing local
machine membership in IPv4 networks. Requires no external modules
("batteries-included" only).
Command-line usage
++++++++++++++++++
#. Sample usage
Test all network interfaces, and return success if any interface has an IP
address in the 10.100.3.0/24 network:
.. code-block:: bash
user@localhost$ local_net 10.100.3.0/24; echo $?
0
user@localhost$
Specific interfaces may be tested by inclusion of the -i/--iface flag, which
may be repeated:
.. code-block:: bash
user@localhost$ local_net -i etho -i wlan2 192.168.1.0/24
Asserting that no local interface is a member of a given network is also
possible by using the -n/--negate flag:
.. code-block:: bash
user@localhost$ local_net -n 10.1.0.0/16
Test success or failure is indicated by exit status code - 0 for success, 1
for failure. This allows for ease of use in conditional statements and other
tests (e.g. ssh config 'exec' testing). Exit status 64 is returned if an
unrecoverable error occurs (e.g. an interface was passed that does not exist),
and error information may be written to stderr. Otherwise, no output is made.
Requirements and compatibility
++++++++++++++++++++++++++++++
The code should work on any POSIX-compatible system, but has only been tested
on modern Linux installs. Pull requests and bug reports for other operating
systems are welcome. Supports Python versions 2.6+. Python versions < 3.3
require a system libc which supports if_nameindex() to get around lack of same
in socket module.
=========
Changelog
=========
All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.
[0.2.0] - 2018-09-30
++++++++++++++++++++
Changed
-------
- Don't import ctypes until we need it.
- Catch exception from all_ifaces() in _main so we can exit correctly.
- Add LICENSE file
- Fix this CHANGELOG
[0.1.0] - 2018-09-30
++++++++++++++++++++
Added
-----
- CHANGELOG.rst
- MANIFEST.in
- README.rst
- localnet.py
- setup.cfg
- setup.py
- .gitignore
Release files for localnet 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| localnet-0.2.0.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| localnet-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / localnet-0.2.0.tar.gz
| Download URL | localnet-0.2.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac4c4b1bbef5577f10a8c4889fcd31d6af89bcf40b26e297f2fb8abe45ef58e7
|
|
BLAKE2b-256 checksum How to use checksums |
fc8f24137b07a29488b6c09d7e47a870c27c85caafc85e3f425d4882fe5e997e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
|
Release files / localnet-0.2.0-py3-none-any.whl
| Download URL | localnet-0.2.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58c1c88e609bbc132fa89f51069e39b370455b9b8a2a48725a029c87614c6341
|
|
BLAKE2b-256 checksum How to use checksums |
f3f8023d3477fc1388760c4f3d8bbc0aa39be6244e1151c060b136180750da7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4
|