### Full AnonSocksClient Example - JavaScript Source: https://docs.anyone.io/sdk/npm/tutorials/ii A complete example demonstrating the setup and usage of AnonSocksClient. It includes starting the Anon client, waiting for network readiness, fetching the IP address, and handling potential errors, followed by stopping the Anon client. ```javascript import { Anon } from "@anyone-protocol/anyone-client"; import { AnonSocksClient } from "@anyone-protocol/anyone-client"; async function main() { const anon = new Anon(); const anonSocksClient = new AnonSocksClient(anon); try { await anon.start(); await new Promise(resolve => setTimeout(resolve, 15000)); const response = await anonSocksClient.get('https://api.ipify.org?format=json'); console.log('Response:', response.data); } catch(error) { console.log(error) } finally { await anon.stop() } } main() ``` -------------------------------- ### Install and Start Anyone Proxy Server on Linux Source: https://docs.anyone.io/connect/beta-scripts/linux This command downloads and executes the Anyone client script, automatically configuring it to run a proxy server. It sets up proxy settings for WiFi traffic and provides instructions for cancellation. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/anyone-protocol/anon-install/main/linux/start_proxy.sh)" ``` -------------------------------- ### Start Anon Client Asynchronously Source: https://docs.anyone.io/sdk/npm/tutorials/i This snippet shows how to initialize and start the Anon client within an asynchronous function. It uses a try-catch block to handle potential errors during the start process. The client is instantiated and then started using `anon.start()`. ```javascript import { Anon } from "@anyone-protocol/anyone-client"; async function main() { const anon = new Anon(); try { await anon.start(); } catch(error) { console.log(error) } } main() ``` -------------------------------- ### Example anonrc Configuration (Shell) Source: https://docs.anyone.io/relay/start/install-anon-on-linux/apt This is an example configuration file for a middle Relay setup. It specifies logging, ports, relay type, nickname, and contact information. Refer to the Anon Manual for all available parameters. ```shell Log notice file /var/log/anon/notices.log ORPort 9001 ControlPort 9051 ExitRelay 0 Nickname MyRelayNickname # Between 1-19 characters, only [a-zA-Z0-9] and no spaces. ContactInfo ``` -------------------------------- ### Wi-Fi Details for Initial Connection Source: https://docs.anyone.io/hardware/setup-guides/router-mode These are the default Wi-Fi network name and password provided by the Anyone Router when it is in setup mode. Clients should connect to this network to access the setup wizard. The network name includes a random identifier. ```yaml Name: relayup_XXXXXX (this will be 6 random digits) Password: anyone.io ``` -------------------------------- ### Import and Start Anon Client (Javascript) Source: https://docs.anyone.io/sdk/npm/tutorials/i Imports the Anon client from the '@anyone-protocol/anyone-client' package and creates a new instance. The .start() function is then called to initiate the Anon binary and negotiate a circuit within the Anyone Network. ```javascript import { Anon } from "@anyone-protocol/anyone-client"; const anon = new Anon(); anon.start(); ``` -------------------------------- ### Initialize NPM Project Source: https://docs.anyone.io/sdk/npm/tutorials/i Initializes a new project directory as an npm module, creating a package.json file and configuring it for module usage. This is a prerequisite for using the Anyone.io SDK with Node.js. ```bash npm init es6 --save ``` -------------------------------- ### Install and Enable Watchdog Service Source: https://docs.anyone.io/security/vps-hardening-and-best-practices Installs the Watchdog service, which monitors system resources and can trigger actions on failures. It also includes commands to enable and start the service. ```bash sudo apt install watchdog -y sudo systemctl enable --now watchdog ``` -------------------------------- ### Install Nyx for Monitoring in Debian Source: https://docs.anyone.io/welcome/faq Steps to install and run Nyx, a monitoring tool, on a Debian system. It also provides guidance on enabling the ControlPort for Nyx to function with the relay setup. ```bash sudo apt-get install nyx --yes # To run Nyx: sudo nyx ``` -------------------------------- ### Initialize and Build SvelteKit Application Source: https://docs.anyone.io/sdk/native-sdk/tutorials/services2 These commands guide through the process of creating a new SvelteKit project, installing dependencies, configuring the Node adapter, and building the project for deployment. It includes setting environment variables for the port and host. ```bash mkdir -p ~/anyone cd ~/anyone npx sv create my-svelte-anon-app cd my-svelte-anon-app npm install npm install -D @sveltejs/adapter-node npm i dotenv ``` ```bash cat < setTimeout(resolve, 12000)); const anonControlClient = new AnonControlClient(); await anonControlClient.authenticate() anonControlClient.end() } catch(error) { console.log(error) } finally { await anon.stop() } } main() ``` -------------------------------- ### Start Anon on macOS Source: https://docs.anyone.io/sdk/native-sdk/releases Instructions for starting the Anon client on macOS. This involves creating an 'anonrc' configuration file in the same directory as the extracted Anon files and then executing the Anon binary with the configuration file specified using './anon -f anonrc' in the terminal. ```bash ./anon -f anonrc ``` -------------------------------- ### Initialize AnonSocksClient and Make HTTP Requests (JavaScript) Source: https://docs.anyone.io/sdk/npm/library/anonsocksclient This snippet demonstrates how to initialize the Anon class, start the Anon network, create an AnonSocksClient instance, and then perform GET and POST requests. It includes error handling and ensures the Anon network is stopped afterwards. Dependencies include the '@anyone-protocol/anyone-client' library. ```javascript import { Anon, AnonSocksClient } from '@anyone-protocol/anyone-client'; const anon = new Anon(); await anon.start(); const client = new AnonSocksClient(anon); try { const response = await client.get('https://api.example.com/data'); console.log(response.data); const postResponse = await client.post('https://api.example.com/users', { name: 'John Doe' }); console.log(postResponse.data); } catch (error) { console.error('Error:', error.message); } finally { await anon.stop(); } ``` -------------------------------- ### Run Javascript Program from Terminal Source: https://docs.anyone.io/sdk/npm/tutorials/i Executes a Javascript file using the Node.js runtime. This command is used to start the Anon client and establish a circuit on the Anyone Network after the code has been written. ```bash node hello.js ``` -------------------------------- ### Start Anyone Proxy Server on macOS Source: https://docs.anyone.io/connect/beta-scripts/macos This bash command downloads and executes a script to start an Anyone proxy server and configure macOS Wi-Fi settings. It requires curl and bash. The output is the proxy server running and enabled. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/anyone-protocol/anon-install/main/macos/start_proxy.sh)" ``` -------------------------------- ### Anon Relay Configuration Wizard - Terms Acceptance Source: https://docs.anyone.io/relay/start/install-anon-on-linux An example of the prompt shown during the Anon Relay installation wizard, requiring the user to read and accept the terms and conditions before proceeding with the configuration. ```text Please read the terms and conditions at https://www.anyone.io/terms Do you accept the terms and conditions? [yes/no] yes ``` -------------------------------- ### Initialize and Use AnonControlClient Source: https://docs.anyone.io/sdk/npm/library/anoncontrolclient Demonstrates how to initialize the AnonControlClient, authenticate, manage circuits, get relay information, and properly close the connection. This example covers common use cases for interacting with the Anon Control Port. ```javascript import { AnonControlClient } from '@anyone-protocol/anyone-client'; const client = new AnonControlClient(); async function example() { try { await client.authenticate('your_password'); const circuits = await client.circuitStatus(); console.log('Current circuits:', circuits); const newCircuitId = await client.extendCircuit(); console.log('New circuit created with ID:', newCircuitId); const relayInfo = await client.getRelayInfo('RELAY_FINGERPRINT'); console.log('Relay info:', relayInfo); await client.closeCircuit(newCircuitId); console.log('Circuit closed'); } catch (error) { console.error('Error:', error.message); } finally { client.end(); } } example(); ``` -------------------------------- ### Setup Mode Wizard Password Source: https://docs.anyone.io/hardware/setup-guides/router-mode This is the password required to access the Anyone Router's setup mode wizard after connecting to the initial Wi-Fi network. It is used to configure the device's settings and choose the desired operating mode. ```text admin ``` -------------------------------- ### Add AnyoneKit Dependency to Podfile Source: https://docs.anyone.io/sdk/ios-sdk-beta/cocoapods Specifies the AnyoneKit library as a dependency within your project's Podfile. This example uses a direct GitHub repository URL for the pod. ```ruby target 'YourApp' do pod 'AnyoneKit', :git => 'https://github.com/anyone-protocol/AnyoneKit.git' end ``` -------------------------------- ### Stop Anon Client After Delay Source: https://docs.anyone.io/sdk/npm/tutorials/i This snippet extends the previous example by adding a 15-second delay before stopping the Anon client. The `anon.stop()` function is placed within a finally block to ensure it executes even if errors occur during the start or delay. This prepares the client for future command execution. ```javascript try { await anon.start(); await new Promise(resolve => setTimeout(resolve, 15000)); } catch(error) { console.log(error) } finally { await anon.stop() } ``` -------------------------------- ### Prepare Directories and Fetch Relay Configuration Files Source: https://docs.anyone.io/relay/start/install-anon-on-linux/docker Creates necessary directories for Docker compose files and Anon configuration, sets permissions, creates a user for the Anon service, and downloads the relay configuration files from a GitHub repository. ```bash sudo mkdir /opt/compose-files/ sudo mkdir -p /opt/anon/etc/anon/ sudo mkdir -p /opt/anon/run/anon/ sudo mkdir -p /root/.nyx/ sudo chmod -R 700 /opt/anon/run/anon/ sudo chown -R 100:101 /opt/anon/run/anon/ sudo touch /opt/anon/etc/anon/notices.log sudo chown 100:101 /opt/anon/etc/anon/notices.log sudo useradd -M anond sudo wget -O /opt/compose-files/relay.yaml https://raw.githubusercontent.com/anyone-protocol/anon-install/refs/heads/main/docker/anon-relay/relay.yaml sudo wget -O /opt/anon/etc/anon/anonrc https://raw.githubusercontent.com/anyone-protocol/anon-install/refs/heads/main/docker/anon-relay/anonrc sudo wget -O /root/.nyx/config https://raw.githubusercontent.com/anyone-protocol/anon-install/refs/heads/main/docker/anon-relay/config ``` -------------------------------- ### Install Dependencies using CocoaPods Source: https://docs.anyone.io/sdk/ios-sdk-beta/cocoapods Installs all the dependencies declared in the Podfile, including AnyoneKit, into your Xcode project. This command should be run after modifying the Podfile. ```shell pod install ``` -------------------------------- ### Install CocoaPods using Ruby Source: https://docs.anyone.io/sdk/ios-sdk-beta/cocoapods Installs CocoaPods, a dependency manager for Swift and Objective-C projects, using Ruby's gem package manager. This is a prerequisite for managing project dependencies. ```shell sudo gem install cocoapods ``` -------------------------------- ### Install UFW on Debian/Ubuntu Source: https://docs.anyone.io/relay/network/firewall Updates the package list and installs the Uncomplicated Firewall (UFW) package. This is a prerequisite for configuring firewall rules. ```bash sudo apt-get update -y sudo apt-get install ufw -y ``` -------------------------------- ### Create Basic index.html for Testing Source: https://docs.anyone.io/sdk/native-sdk/tutorials/services1 Creates a simple index.html file in the default Nginx web root directory. This file will be served when a user accesses the root URL, serving as a basic test. ```bash echo "Welcome to my Anyone Anon Service" | sudo tee /var/www/html/index.html ``` -------------------------------- ### Install Docker Packages and Enable Service on Fedora Source: https://docs.anyone.io/relay/start/install-anon-on-linux/docker Installs Docker CE, CLI, containerd.io, buildx plugin, and compose plugin on Fedora systems. It also enables and starts the Docker service immediately. ```bash sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y sudo systemctl enable --now docker ``` -------------------------------- ### Initialize and Manage Anon Client (JavaScript) Source: https://docs.anyone.io/sdk/npm/library/anon Demonstrates how to create a new instance of the Anon class, start the client, retrieve port information, and stop the client. It requires the '@anyone-protocol/anyone-client' package. ```javascript import { Anon } from '@anyone-protocol/anyone-client'; const anonClient = new Anon({ displayLog: true, socksPort: 9060 }); await anonClient.start(); console.log(`SOCKS Port: ${anonClient.getSOCKSPort()}`); console.log(`Control Port: ${anonClient.getControlPort()}`); console.log(`OR Port: ${anonClient.getORPort()}`); // ... use the Anon client ... if (anonClient.isRunning()) { await anonClient.stop(); } ``` -------------------------------- ### Start and Enable Nginx Service Source: https://docs.anyone.io/sdk/native-sdk/tutorials/services1 Starts the Nginx service immediately and configures it to start automatically on system boot. This ensures the web server is running and persistent. ```bash sudo systemctl start nginx sudo systemctl enable nginx ``` -------------------------------- ### Install Nginx on Ubuntu Source: https://docs.anyone.io/sdk/native-sdk/tutorials/services1 Installs the Nginx web server on an Ubuntu system using apt package manager. This is a prerequisite for running a web server. ```bash sudo apt update --yes sudo apt-get install nginx --yes ``` -------------------------------- ### Create and Start Docker Relay Container Source: https://docs.anyone.io/relay/start/install-anon-on-linux/docker Uses Docker Compose to create and start the Anon relay container in detached mode, based on the configuration file located at /opt/compose-files/relay.yaml. ```bash sudo docker compose -f /opt/compose-files/relay.yaml up -d ``` -------------------------------- ### Start Anyone Client (MacOS) Source: https://docs.anyone.io/connect/macos Starts the Anyone Client with default configurations. This command is executed in the Terminal application. ```bash npx anyone-client ``` -------------------------------- ### Install and Configure Fail2Ban for SSH Protection Source: https://docs.anyone.io/security/vps-hardening-and-best-practices Installs Fail2Ban, a service that scans log files and bans IPs showing malicious signs. It includes steps for basic configuration, enabling SSH protection, and starting the service. ```bash sudo apt install fail2ban -y ``` ```bash sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local sudo nano /etc/fail2ban/jail.local ``` ```ini [DEFAULT] bantime = 10m findtime = 10m maxretry = 5 [sshd] enabled = true port = ssh logpath = %(sshd_log)s backend = %(sshd_backend)s ``` ```ini port = 52231 ``` ```bash sudo systemctl enable fail2ban sudo systemctl start fail2ban ``` ```bash sudo fail2ban-client status sudo fail2ban-client status sshd ``` ```bash sudo fail2ban-client set sshd unbanip ```