{"id":23822462,"url":"https://github.com/littleatarixe/onionsfarmer","last_synced_at":"2025-04-13T17:40:23.529Z","repository":{"id":225690209,"uuid":"766600211","full_name":"LittleAtariXE/OnionsFarmer","owner":"LittleAtariXE","description":"Onion Farmer for planting onions. A python class to manage multiple instances of Tor. ","archived":false,"fork":false,"pushed_at":"2024-03-09T11:53:05.000Z","size":3175,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T08:22:23.999Z","etag":null,"topics":["farmer","linux","multiple","onion","onions","proxy","python","socks5","tor"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LittleAtariXE.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-03T17:53:46.000Z","updated_at":"2024-10-18T01:22:56.000Z","dependencies_parsed_at":"2024-03-03T18:55:11.537Z","dependency_job_id":null,"html_url":"https://github.com/LittleAtariXE/OnionsFarmer","commit_stats":null,"previous_names":["littleatarixe/onionsfarmer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleAtariXE%2FOnionsFarmer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleAtariXE%2FOnionsFarmer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleAtariXE%2FOnionsFarmer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LittleAtariXE%2FOnionsFarmer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LittleAtariXE","download_url":"https://codeload.github.com/LittleAtariXE/OnionsFarmer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248755096,"owners_count":21156541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["farmer","linux","multiple","onion","onions","proxy","python","socks5","tor"],"created_at":"2025-01-02T09:19:24.836Z","updated_at":"2025-04-13T17:40:23.494Z","avatar_url":"https://github.com/LittleAtariXE.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"intro\" align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003eOnions Farmer\u003c/h1\u003e\n  \u003cp\u003eA powerful utility for managing multiple Tor instances\u003c/p\u003e\n  \u003cimg src=\"img/f1.png\" alt=\"OnionFarmer Intro\"\u003e\n\u003c/div\u003e\n\u003cdiv id=\"description\"\u003e\n  \u003ch2\u003eAbout OnionsFarmer\u003c/h2\u003e\n  \u003cp\u003eOnionsFarmer empowers users to cultivate \"Onions\" — a playful metaphor for independent Tor network instances. This sophisticated Python utility facilitates the simultaneous management of multiple Tor processes. For optimal functionality, it requires the Tor software installation on the user's system and proper user permissions. OnionsFarmer streamlines the initiation and supervision of Tor network connections, enhancing both security and usability.\u003c/p\u003e\n  \u003ch2\u003eKey Features\u003c/h2\u003e\n  \u003cul\u003e\n    \u003cli\u003e\u003cstrong\u003eCreate Tor Instances:\u003c/strong\u003e With the \u003ccode\u003eplantOnion\u003c/code\u003e method, users can seed new, individually manageable Tor instances.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eIndependent Operation:\u003c/strong\u003e Each Onion instance operates independently, providing detailed control over its respective Tor process.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eGraceful Shutdown:\u003c/strong\u003e For orderly Tor process termination, employing the \u003ccode\u003eOnion.stop()\u003c/code\u003e method is advised before exiting the application.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eDirect Control and Termination:\u003c/strong\u003e The \u003ccode\u003eplantOnion\u003c/code\u003e method returns an Onion instance along with an external stop event, enabling straightforward control and shutdown operations.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003ePersistent Configuration:\u003c/strong\u003e OnionsFarmer auto-generates a \"ONIONS\" directory for storing logs, configuration, and Tor library files. Reutilizing the same Tor instance names can speed up subsequent startups by leveraging existing files.\u003c/li\u003e\n    \u003cli\u003e\u003cstrong\u003eOnionsBag - Bulk Management:\u003c/strong\u003e A convenient feature for handling multiple Tor instances collectively. It allows for the swift creation and management of several Onions, simplifying the orchestration of numerous Tor connections.\u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"toc\"\u003e\n  \u003ch2 align=\"center\"\u003eContents\u003c/h2\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003ca href=\"#requirements\"\u003eRequirements\u003c/a\u003e \u0026nbsp;|\u0026nbsp;\n    \u003ca href=\"#installation\"\u003eInstall\u003c/a\u003e  \u0026nbsp;|\u0026nbsp;\n    \u003ca href=\"#methods\"\u003e Onion Farmer Methods\u003c/a\u003e  \u0026nbsp;|\u0026nbsp;\n    \u003cbr\u003e\n    \u003ca href=\"#onionobj\"\u003e Onion\u003c/a\u003e  \u0026nbsp;|\u0026nbsp;\n    \u003ca href=\"#onionsBag\"\u003e Onions Bag\u003c/a\u003e  \u0026nbsp;|\u0026nbsp;\n    \u003ca href=\"#examples\"\u003e Examples\u003c/a\u003e  \u0026nbsp;|\u0026nbsp;\n    \u003cbr/\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"requirements\"\u003e\n    \u003ch2\u003eRequirements\u003c/h2\u003e\n    \u003cp\u003eTo ensure the proper functioning of Onions Farmer, the following requirements must be met:\u003c/p\u003e\n    \u003cul\u003e\n        \u003cli\u003eTor Software Installed - Onions Farmer relies on direct interactions with the Tor network, requiring the Tor software to be installed on the user's system.\u003c/li\u003e\n        \u003cli\u003ePython 3.11 or Newer - Utilizes features and syntax introduced in Python 3.11, necessitating this or a newer version of Python.\u003c/li\u003e\n        \u003cli\u003ePython 'socks' Library - This dependency is crucial for managing SOCKS protocol interactions, allowing Onions Farmer to communicate over Tor network connections effectively.\u003c/li\u003e\n    \u003c/ul\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"installation\"\u003e\n    \u003ch2\u003eInstallation\u003c/h2\u003e\n    \u003cp\u003eOnionsFarmer is versatile and can function both as a standalone application or as an imported module in your projects. The choice of how you wish to use it is yours.\u003c/p\u003e\n    \u003ch3\u003eDownloading OnionsFarmer:\u003c/h3\u003e\n    \u003cp\u003eTo get started with OnionsFarmer, clone the repository using Git:\u003c/p\u003e\n    \u003cpre\u003e\u003ccode\u003egit clone https://github.com/LittleAtariXE/OnionsFarmer.git\u003c/code\u003e\u003c/pre\u003e\n    \u003ch3\u003eInstalling Dependencies:\u003c/h3\u003e\n    \u003cp\u003eAfter cloning the repository, navigate to the OnionsFarmer directory and install the necessary Python libraries by running:\u003c/p\u003e\n    \u003cpre\u003e\u003ccode\u003epip install -r requirements.txt\u003c/code\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"methods\"\u003e\n  \u003ch2 align=\"center\"\u003eOnions Farmer Methods\u003c/h2\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"img/f2.png\" alt=\"Onions Market\"\u003e\n  \u003c/div\u003e\n  \u003cdiv id=\"method-plantOnion\"\u003e\n      \u003ch2\u003eOnionsFarmer.plantOnion() Method\u003c/h2\u003e\n      \u003cp\u003eThe \u003ccode\u003eplantOnion()\u003c/code\u003e method, literally \"plant an onion\", is responsible for creating a new \u003ccode\u003eOnion\u003c/code\u003e object, which represents an instance of Tor. This method offers a variety of parameters for customization:\u003c/p\u003e\n      \u003cul\u003e\n          \u003cli\u003e\u003cstrong\u003ename\u003c/strong\u003e: An optional parameter that assigns a reference name to the Onion instance. This name can be used later with the \u003ccode\u003egetOnion()\u003c/code\u003e method to retrieve the object. If not provided, a default name is generated.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003elocal_socks_port\u003c/strong\u003e: Specifies the local port for the Tor SOCKS proxy. This parameter determines on which local port the SOCKS proxy will be created.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eoutside_socks_ip\u003c/strong\u003e: Indicates the IP address and port (in the format \"192.168.0.23:8000\") to be used for creating a Tor SOCKS proxy accessible from other machines.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003etorrc\u003c/strong\u003e: An optional parameter that allows specifying a path to a custom \u003ccode\u003etorrc\u003c/code\u003e file. If this parameter is omitted, a new torrc file will be generated automatically.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eprint_log\u003c/strong\u003e: Enables direct printing of Tor logs to the console. This is not recommended for multiple instances due to potential text flooding on the screen. Note: Each \u003ccode\u003eOnion\u003c/code\u003e object maintains its own log file.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003ehttp_bridge\u003c/strong\u003e: Creates a special HTTP Proxy server linked to the Tor SOCKS proxy. This parameter accepts three types of values:\n              \u003cul\u003e\n                  \u003cli\u003eA specific IP and port (e.g., \"192.168.0.22:5000\") will create an HTTP -\u003e SOCKS bridge on the specified port, accessible from other machines.\u003c/li\u003e\n                  \u003cli\u003eA port number only (e.g., \"5000\") will create the HTTP proxy on the local port 5000.\u003c/li\u003e\n                  \u003cli\u003eThe value \"random\" will establish the HTTP proxy on a randomly selected port.\u003c/li\u003e\n              \u003c/ul\u003e\n          \u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003econfig\u003c/strong\u003e: A dictionary that may contain additional optional parameters, which will be detailed further in this documentation.\u003c/li\u003e\n      \u003c/ul\u003e\n      \u003cp\u003eThis method allows for flexible creation and management of Tor instances, catering to a wide range of use cases and preferences.\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cdiv id=\"instance-naming\"\u003e\n    \u003ch2\u003eOptimizing Tor Connection Initialization\u003c/h2\u003e\n    \u003cp\u003eWhen selecting names for Onion instances, either through \u003ccode\u003eplantOnion()\u003c/code\u003e or \u003ccode\u003emakeOnionsBag()\u003c/code\u003e, consistently using the same names can lead to faster connection and configuration times with the Tor network. This efficiency gain is due to the Tor library files already being downloaded. The difference becomes noticeable when rerunning the same script. The initial startup always takes the longest, as Tor needs to download all necessary files, descriptors, etc.\u003c/p\u003e\n  \u003c/div\u003e\n\n  \u003cdiv id=\"method-getOnion\"\u003e\n    \u003ch2\u003eOnionsFarmer.getOnion() Method\u003c/h2\u003e\n    \u003cp\u003eThe \u003ccode\u003egetOnion()\u003c/code\u003e method retrieves an \u003ccode\u003eOnion\u003c/code\u003e object previously created by the OnionsFarmer. This method facilitates access to individual Onion instances for management and interaction:\u003c/p\u003e\n    \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ename\u003c/strong\u003e: The name of the previously created Onion instance. Providing this name as a parameter allows for the retrieval of the specific Onion object. If this parameter is omitted, a \u003ccode\u003edict\u003c/code\u003e object containing all Onion objects managed by OnionsFarmer is returned.\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003cp\u003eOnion objects are typically assigned to variables for easy access. OnionsFarmer internally stores every Onion object created, enabling efficient management and retrieval of these instances as needed.\u003c/p\u003e\n  \u003c/div\u003e\n\n  \u003cdiv id=\"method-stopOnion\"\u003e\n    \u003ch2\u003eOnionsFarmer.stopOnion() Method\u003c/h2\u003e\n    \u003cp\u003eThe \u003ccode\u003estopOnion()\u003c/code\u003e method is designed to halt a specified Onion instance. It serves as a convenient way to terminate Tor processes directly from the OnionsFarmer, complementing the individual stop methods within each Onion object:\u003c/p\u003e\n    \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ename\u003c/strong\u003e: The name of the Onion object to be stopped. When this parameter is provided, OnionsFarmer will attempt to stop the specified Onion instance. If the \u003ccode\u003ename\u003c/code\u003e parameter is omitted, OnionsFarmer will proceed to stop all Onion instances it manages.\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003cp\u003e\u003cstrong\u003eREMEMBER:\u003c/strong\u003e It is crucial to stop all running Onion instances before exiting your script or application. This ensures a proper shutdown of the Tor processes and prevents any potential resource leaks or orphaned processes.\u003c/p\u003e\n  \u003c/div\u003e\n\n  \u003cdiv id=\"method-makeOnionsBag\"\u003e\n    \u003ch2\u003eOnionsFarmer.makeOnionsBag() Method\u003c/h2\u003e\n    \u003cp\u003eThe \u003ccode\u003emakeOnionsBag()\u003c/code\u003e method facilitates the creation of an \u003ccode\u003eOnionsBag\u003c/code\u003e object, which is a collection containing multiple Onion objects. This method is ideal for quickly generating and managing numerous Tor instances:\u003c/p\u003e\n    \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecount\u003c/strong\u003e: Specifies the number of Onion objects to be created. The default value is 1.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ename\u003c/strong\u003e: Optionally provides a base name for the Onion instances. The farmer will append a unique ID to each name, based on the total number of Onions.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003elocal_sock_port_num_start\u003c/strong\u003e: Optionally sets the starting port number. Subsequent Tor SOCKS will be placed on increasing port numbers from this starting point.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eout_proxy_ip\u003c/strong\u003e: Optionally specifies an external proxy IP address that can be connected to from another machine. The script will assign the port.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003etorrc\u003c/strong\u003e: Optionally allows specifying a path to a custom torrc file to be used as a template.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eprint_log\u003c/strong\u003e: Optionally enables the printing of logs to the console for each Onion object. Be cautious as this can lead to extensive output on the console, especially with many instances!\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ehttp_bridge\u003c/strong\u003e: For each Onion, an HTTP Proxy connected to Tor's SOCKS will be created, with the port assigned by the script.\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003cp\u003e\u003cstrong\u003eRemember:\u003c/strong\u003e Each created Onion object has its configuration, which you can inspect. This includes SOCKS addresses, HTTP Bridge addresses and ports, among other settings.\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cbr\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"onionobj\"\u003e\n  \u003ch2 align=\"center\"\u003eOnion Object\u003c/h2\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"img/f3.png\" alt=\"Onion Linux\"\u003e\n  \u003c/div\u003e\n  \u003cdiv id=\"onion-object\"\u003e\n      \u003ch2\u003eThe Onion Object\u003c/h2\u003e\n      \u003cp\u003eThe \u003ccode\u003eOnion\u003c/code\u003e object embodies an individual Tor instance within the OnionsFarmer framework. It encapsulates the configuration and management of a Tor process, offering a variety of properties and methods for interaction:\u003c/p\u003e\n      \u003ch3\u003eProperties\u003c/h3\u003e\n      \u003cul\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.conf\u003c/strong\u003e: Returns a dictionary object containing the Onion's configuration, including SOCKS addresses, HTTP Bridge details, etc.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.isTorConn\u003c/strong\u003e: Returns \u003ccode\u003eTrue\u003c/code\u003e if the Onion has successfully connected to the Tor network.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.IP\u003c/strong\u003e: Retrieves the IP address of the Exit Node. If the address cannot be obtained, it returns \u003ccode\u003eNone\u003c/code\u003e.\u003c/li\u003e\n      \u003c/ul\u003e\n      \u003ch3\u003eMethods\u003c/h3\u003e\n      \u003cul\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.start()\u003c/strong\u003e: Initiates the connection to the Tor network. This method begins the Tor process associated with the Onion instance.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.stop()\u003c/strong\u003e: Terminates the Onion's Tor process. \u003cstrong\u003eImportant:\u003c/strong\u003e Always close each Tor connection with this method before ending your program to prevent errors and orphaned processes.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.sendCMD()\u003c/strong\u003e: Sends a command through the Tor Control Socket and returns the response. This method allows for direct interaction with the Tor process.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.newCircuit()\u003c/strong\u003e: Generates a new circuit for the Onion, potentially altering the exit node and IP address.\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.status()\u003c/strong\u003e: Displays the current status of the Onion object, which can be \"ready to start\", \"working\", or \"terminated\".\u003c/li\u003e\n          \u003cli\u003e\u003cstrong\u003eOnion.infoConf()\u003c/strong\u003e: Prints a readable configuration of the Onion object to the screen, detailing its current setup and parameters.\u003c/li\u003e\n      \u003c/ul\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\n\u003cdiv id=\"onionsBag\"\u003e\n  \u003ch2 align=\"center\"\u003e Onions Bag \u003c/h2\u003e\n\n  \u003cdiv\u003e\n    \u003ch2\u003eThe OnionsBag Object\u003c/h2\u003e\n    \u003cp\u003eThe \u003ccode\u003eOnionsBag\u003c/code\u003e object, or \"Bag of Onions,\" represents a collection of multiple Tor instances (Onion objects). It allows for efficient and quick management of all contained Onions simultaneously.\u003c/p\u003e\n    \u003ch3\u003eProperties\u003c/h3\u003e\n    \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.len\u003c/strong\u003e: Returns the number of Onion objects contained within the bag.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.isTorConn\u003c/strong\u003e: Checks if all Onion objects have successfully established a full connection to the Tor network. Returns \u003ccode\u003eFalse\u003c/code\u003e if at least one Onion is not connected, and \u003ccode\u003eTrue\u003c/code\u003e if all are connected.\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003ch3\u003eMethods\u003c/h3\u003e\n    \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.start()\u003c/strong\u003e: Initiates the Tor connection process for all Onion objects within the bag.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.stop()\u003c/strong\u003e: Terminates the Tor processes for all Onion objects, effectively stopping all connections.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.openBag()\u003c/strong\u003e: Returns a list object that contains all the Onion objects within the bag.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.getIP()\u003c/strong\u003e: Begins the process of obtaining the Exit Node IP addresses for all contained Onion objects.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.newCircuit()\u003c/strong\u003e: Instructs all Onion objects to start the process of creating a new circuit, potentially changing their exit nodes and IP addresses.\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOnionsBag.__str__()\u003c/strong\u003e: Displays a tabular overview of the basic configuration for all Onion objects, including SOCKS addresses, HTTP Bridge statuses, connection statuses, and more. This method provides a quick and readable summary of the entire OnionsBag state.\u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\u003cdiv id=\"examples\"\u003e\n  \u003ch2 align=\"center\"\u003eExamples\u003c/h2\u003e\n  \u003cp\u003eBelow are examples illustrating how to use the OnionsFarmer utility to manage Tor instances.\u003c/p\u003e\n\n  \u003ch3\u003eBasic Usage\u003c/h3\u003e\n  \u003cp\u003eHere's how to initialize OnionsFarmer, create Onion instances, and manage their Tor connections:\u003c/p\u003e\n\n  ```python\n  from time import sleep\n  from onions_farmer import OnionsFarmer\n  \n  # Initialize the OnionsFarmer instance.\n  farmer = OnionsFarmer()\n  \n  # Create and configure a random Onion instance with default settings.\n  my_onion = farmer.plantOnion()\n  \n  # Create and configure a specific Onion instance to listen on local port 4444 and enable console logging.\n  my_onion2 = farmer.plantOnion(local_socks_port=4444, print_log=True)\n  \n  # Start the Onion instance's thread, initiating the Tor process.\n  my_onion2.start()\n  \n  # Loop until the Onion instance establishes a connection with the Tor network.\n  while not my_onion2.isTorConn:\n      sleep(0.5)\n  print(\"TOR Works !!!\")\n  \n  # Retrieve and print the Exit Node IP address for the Onion instance.\n  print(\"Exit Node IP: \", my_onion2.IP)\n  \n  # Wait for user input and then display the Onion instance's configuration.\n  input(\"Press ENTER to display Onion configuration.\")\n  my_onion2.infoConf()\n  \n  # Wait for user input again before stopping the Onion instance's thread.\n  input(\"Press ENTER to stop the Onion.\")\n  my_onion2.stop()\n  \n  # Ensure the Onion instance has time to shut down properly.\n  sleep(2)\n  \n  # Final user prompt before exiting the script.\n  input(\"Press ENTER to EXIT\")\n  ```\n\u003c/div\u003e\n\n\u003cdiv id=\"example2\"\u003e\n  \u003ch2\u003eAdvanced Example: Managing Multiple Onions\u003c/h2\u003e\n  \u003cp\u003eThis example demonstrates creating, starting, and managing multiple Onion instances simultaneously, including renewing their circuits for new identities:\u003c/p\u003e\n\n  ```python\n  from time import sleep\n  from onions_farmer import OnionsFarmer\n  \n  # Initialize the OnionsFarmer.\n  farmer = OnionsFarmer()\n  \n  # Create two Onion instances with specified local SOCKS ports and enable logging.\n  my_onion1 = farmer.plantOnion(local_socks_port=4000, print_log=True)\n  my_onion2 = farmer.plantOnion(local_socks_port=5000, print_log=True)\n  \n  # Start both Onion instances' threads, launching the Tor processes.\n  my_onion1.start()\n  my_onion2.start()\n  \n  # Wait until both Onion instances have established connections to the Tor network.\n  while not my_onion1.isTorConn or not my_onion2.isTorConn:\n      sleep(0.5)\n  \n  print(\"Tor Works !!\")\n  sleep(1)\n  \n  # Display the initial Exit Node IP addresses for both Onion instances.\n  print(\"my_onion1 IP: \", my_onion1.IP)\n  print(\"my_onion2 IP: \", my_onion2.IP)\n  \n  # Wait for user input before requesting new circuits for both Onion instances.\n  input(\"Press ENTER to renew circuits.\")\n  my_onion1.newCircuit()\n  my_onion2.newCircuit()\n  \n  # Wait until both Onion instances have re-established connections with the new circuits.\n  while not my_onion1.isTorConn or not my_onion2.isTorConn:\n      sleep(0.5)\n  \n  # Confirm that new circuits have been established and display the new Exit Node IP addresses.\n  print(\"New Circuit\")\n  print(\"my_onion1 IP: \", my_onion1.IP)\n  print(\"my_onion2 IP: \", my_onion2.IP)\n  \n  # Wait for user input before stopping both Onion instances.\n  input(\"Press ENTER to stop Onions.\")\n  farmer.stopOnion()\n  \n  # Ensure there's enough time for both Onion instances to shut down properly.\n  sleep(2)\n  \n  # Final input to exit the script, ensuring a graceful termination.\n  input(\"Press ENTER to exit.\")\n  ```\n\u003c/div\u003e\n\n\u003cdiv id=\"example3\"\u003e\n  \u003ch2\u003eExample 3: Utilizing OnionsBag for Bulk Management\u003c/h2\u003e\n  \u003cp\u003eThis example demonstrates how to use an \u003ccode\u003eOnionsBag\u003c/code\u003e to efficiently manage multiple Onion instances simultaneously, including creating, starting, renewing circuits, and stopping all instances in bulk:\u003c/p\u003e\n  \n  ```python\n  # OnionsBag example\n  \n  from time import sleep\n  from onions_farmer import OnionsFarmer\n  \n  # Initialize OnionsFarmer\n  Farmer = OnionsFarmer()\n  \n  # Create an OnionsBag with 10 Onion instances.\n  # The first creation might take longer due to initial Tor network connections and configurations.\n  bag = Farmer.makeOnionsBag(10)\n  \n  # Start all Onion instances within the bag.\n  # This initiates the Tor connections for each Onion.\n  bag.start()\n  \n  # Wait for user input to continue. This is a good moment to ensure all Onions have connected to the Tor network.\n  input(\"All Onions are starting. Press Enter after they've connected...\")\n  \n  # Print the current state of all Onion instances in the bag.\n  # This displays basic configurations like SOCKS and HTTP Bridge addresses, and their connection statuses.\n  print(bag)\n  \n  input(\"Press Enter to make a new circuit for all Onions.\")\n  \n  # Request new circuits for all Onion instances in the bag.\n  # This can help refresh the network paths and potentially result in new Exit Node IPs.\n  bag.newCircuit()\n  \n  input(\"Press Enter to check the Exit Node IPs for all Onions.\")\n  \n  # Trigger the process to obtain and print the Exit Node IP addresses for all Onion instances.\n  bag.getIP()\n  \n  input(\"Waiting for all Onions to obtain new IP addresses...\")\n  \n  # Print the updated state of all Onion instances in the bag, including their new Exit Node IP addresses.\n  print(bag)\n  \n  input(\"Press Enter to stop all Onions.\")\n  \n  # Stop all Onion instances within the bag.\n  # This ensures a graceful shutdown of all Tor connections.\n  bag.stop()\n  \n  # Pause to allow time for all Onion instances to shut down properly.\n  sleep(2)\n  \n  # Final input prompt to exit the script.\n  input(\"Press Enter to Exit. All Onions have been stopped.\")\n  ```\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittleatarixe%2Fonionsfarmer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittleatarixe%2Fonionsfarmer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittleatarixe%2Fonionsfarmer/lists"}