Convert an IPv4/IPv6 subnet in string format (e.g. into an ipaddress.IPv4Network or ipaddress.IPv6Network object.

Parameters:subnet_str (str) – subnet in string format.
Returns:ipaddress.IPv4Network or ipaddress.IPv6Network object depends on input subnet address type, or None if input invalid.[source]

Check whether the file at file_path exists.

Parameters:file_path (str) – full path to the file checked.
Returns:a boolean value indicating whether the file exists.[source]

Given the path to a file, returns the full path containing the file by expanding any user prefixes. This does not require the target file to exist.

Parameters:file_path (str) – full or user-prefix path to file.
Returns:the path to the directory containing the specified file. None if the directory does not exist.[source]
Convert an IPv4/IPv6 address in bytes to a valid IP address in string format,
if it is indeed valid.
Parameters:ip_bytes (bytes) – bytes of IPv4/IPv6 address.
Returns:IP address in string format, None if input invalid.[source]

Parse flags of a TCP packet.

Parameters:flag_bytes (bytes) – a byte of bits containing TCP packet flag, only the first 8 bits are in use.
Returns:a dict of TCP flags and their values.[source]

Reads and returns mongo credentials stored in mongo-auth.json.

Returns:a dict containing ‘username’ and ‘password’ specified if read was successful, as well as ‘auth_source’ for the authentication databse. Returns None if the JSON file does not exist or is invalid.