Skip to main content

A Python package for performing network-related tasks

Project description

NetPack

NetPack is a Python package that can be used to get information from IP addresses and CIDR ranges. This package uses the whois protocol to fetch the information from the relevant whois server.
This package is based on my personal use in real environment.

Usage

For now, it's only one method in here. I hope I can add more function when I develop further.

from NetPack import NetPack

# Query information about an IPv4 address
ipv4_address = '8.8.8.8'
response = NetPack.inr(NetPack.ServerLocation.AFRINIC, ipv4_address)
print(response)

Classes and Methods

The NetPack package contains the following classes and methods:

NetPack.inr(server: str, ipv4v6: str, query_flags: str = None) -> str

  • This is a static method that takes the following parameters, and return the check result from the INR whois server:
    • server: The whois server address
      • Pre-set NetPack.ServerLocation
        • AFRINIC: The AFRINIC whois server address
        • ARIN: The ARIN whois server address
        • APNIC: The APNIC whois server address
        • LACNIC: The LACNIC whois server address
        • RIPE_NCC: The RIPE NCC whois server address
        • IANA: The IANA whois server address
        • RADB: The RADB website URL
    • ipv4v6: The IP address or CIDR range
    • query_flags: Optional parameter that specifies query flags for certain whois servers
    • (The method returns the response received from the whois server as a string.)

NetPack.radb(ip: str) -> str

  • This is a static method that takes an IPv4 address as an input and return the result from RADB

NetPack.ping(host, packet_size=64, protocol="icmp", interval=0.2, timeout=1, packet_num=5) -> tuple

  • The ping() method can be used to ping a single host:
    • Arguments
      • host: the hostname or IP address of the host to ping.
      • packet_size: the size of the packets to send (in bytes). Default is 64.
      • protocol: the protocol to use for the ping test. Must be either "icmp" or "tcp". Default is "icmp".
      • interval: the time (in seconds) to wait between sending each packet. Default is 0.2.
      • timeout: the time (in seconds) to wait for a response before considering the packet lost. Default is 1.
      • packet_num: the number of packets to send. Default is 5.

NetPack.multiple_ping(hosts, packet_size=64, protocol="icmp", interval=0.2, timeout=1, packet_num=5) -> dict

  • The multiple_ping() method can be used to ping multiple hosts in parallel, This will return a dictionary where each key is a host from the hosts list and each value is a dictionary containing the average latency and success rate of the ping test.
    • Arguments
      • The arguments for multiple_ping() are the same as for ping(), except that they are used for all hosts in the hosts list.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netpackAIO-0.0.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

netpackAIO-0.0.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file netpackAIO-0.0.4.tar.gz.

File metadata

  • Download URL: netpackAIO-0.0.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for netpackAIO-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f5940e40bf8b8d736be0abe3e7fc3b5b83489b77fb8beca4200e93658409dc2d
MD5 c75d5c76ed8e2d2ac48fd2452b70f34c
BLAKE2b-256 8b413c43e07d7e2f1ed89eef0f69865beec596bf1255c25e026a25b4797aafa0

See more details on using hashes here.

Provenance

File details

Details for the file netpackAIO-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: netpackAIO-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for netpackAIO-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e312001cc75073328d32b88dd6008b96d4af461a1659c29ec2f96e9fdcf807e8
MD5 8777937e3ad8459fdf436e445a66fa3f
BLAKE2b-256 c7d6a272688fef0d979e86efafac0cd7007400d9eb16f0ca9bd532e9bff9b479

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page