sirup.utils
Classes
Custom list for IP rotation. |
Functions
|
Query the current IP address of the computer. |
|
Scan a list of strings for presence of one or multiple strings in the same element. |
|
Wait and test for established connection until timeout. |
|
Read a file with root permission to a list. |
|
Run simple command to see if password is correct |
|
Collect all files in a directory and return a list of them with their full path. |
Extract all openvpn process ids on the machine. |
|
|
Kill all openvpn connections on the machine |
Module Contents
- sirup.utils.get_ip(echo=False, config_file=None)[source]
Query the current IP address of the computer.
The function calls https://ifconfig.me and retrieves the IP address.
- sirup.utils.lookup_strings_in_list(strings_to_check, list_of_strings)[source]
Scan a list of strings for presence of one or multiple strings in the same element.
- Parameters:
- Returns:
True if there is at least one element in list_of_strings that contains all strings in strings_to_check.
- Return type:
Example
>>> from sirup.utils import lookup_strings_in_list >>> lookup_strings_in_list(["hello", "world"], ["hello, wonderful world", "hello universe"]) True
- sirup.utils.check_connection(log_file, timeout, pwd, waiting_time=2)[source]
Wait and test for established connection until timeout.
The function repeatedly scans the log file of the openvpn process and looks for a string that indicates that the vpn connection was established. It exits when the string is found or timeout is reached.
- Parameters:
- Returns:
indicates whether connection is established.
- Return type:
- sirup.utils.sudo_read_file(file, pwd=None)[source]
Read a file with root permission to a list.
- Parameters:
file (str or TemporaryFileWithRootPermission) – the file to read
pwd (str, optional) – root password for the file. If file is a TemporaryFileWithRootPermission and no password is provided, the password is taken from the TemporaryFileWithRootPermission object.
- Returns:
Content of the file, each line is one element in the list.
- Return type:
- sirup.utils.list_files_with_full_path(directory, rule=None)[source]
Collect all files in a directory and return a list of them with their full path.
- class sirup.utils.RotationList(*args)[source]
Bases:
listCustom list for IP rotation.
- shuffle(randomizer)[source]
Randomly shuffle the list of proxies. This changes the order by which we iterate through them.
- Parameters:
randomizer (random.Random) – pseudo-random number generator.