Anyone Docs
  • 🔷The Documentation For Anyone
    • About
    • FAQ
  • 🔷Relay Setup
    • Get Started
    • Installation and Usage
      • Setting Your Environment
        • Virtualization on Windows
        • Virtualization on macOS
        • Install Ubuntu Server 22.04
        • Server management with SSH in Windows and macOS
      • Install Anon on Linux
      • Install Anon using the apt repository
      • Update Anon and accept terms and conditions
      • Install Anon in Docker
      • Configure SOCKS5 Proxy for Anyone
      • Install Anyone Exit Relay
    • Troubleshooting Common Issues
      • Diagnosing CGNAT and Public IPv4
      • Confirm ORPort Reachability
    • Firewall and Network Configurations
      • Router Port Forwarding
      • Install and Configure Firewall
    • Advanced Configuration and Troubleshooting
      • Configure IPv4 and IPv6
      • DoS mitigation parameters
    • Relay Operator Standards
    • Exit Relay Guidelines
  • 🔷Hardware Setup
    • Setup Guide
    • Description and Specifications
    • Relay Control Panel
      • Home
      • Network Settings
      • Relay Settings
      • Relay Family
      • Proxy Settings BETA
      • Change Password
      • Logs
      • Update
    • Update (Using USB)
    • Update to WEB 3.2.0 (Using UI)
    • Troubleshooting and additional configuration
      • Router Port Forwarding
      • Diagnosing CGNAT and Public IPv4
    • Router Setup
  • 🔷Security and Privacy
    • VPS Hardening
  • 🔷Rewards Dashboard
    • Registering to the Rewards Program
    • Accessing the Rewards Dashboard
    • Using the Rewards Dashboard
    • Rewards Status
  • 🔷Anyone SDK
    • NPM SDK
      • Install NPM Package
      • Run as Library
        • Anon
        • AnonSocksClient
        • AnonControlClient
      • Run from CLI
      • Tutorials
        • Hello Anon World I
        • Hello Anon World II
        • Circuit Control I
        • Circuit Control II
    • Native SDK
      • Anyone Client Releases
      • MAN - Anon Manual
      • Tutorials
        • Anyone Services I
        • Anyone Services II
    • iOS SDK [Beta]
      • Manual Install - CocoaPods
  • 🔷Connect to Anyone
    • Connecting to Linux
      • [Beta] One-Click Linux Setup
    • Connecting to macOS
      • macOS with NPM
      • [Beta] One-Click macOS Setup
    • Connecting to Windows
      • [Beta] One-Click Windows Setup
    • Individual Applications with Anyone
    • Connect Through Hardware
  • 🔷Tokenomics
    • Introduction
    • Token Distribution
      • Token Outflow
      • Other Tokens
    • Relay Rewards
      • Lock Requirement
      • Lock Adjustments
      • Reward Multipliers
    • Additional Roles
      • Authorities and Staking
      • Governance Voting
    • Premium Circuits
      • Premium Circuits
      • Premium Circuits: Metrics
    • Summary
      • Value Accrual Summary
      • Rewards Case Study
    • Appendix
      • M Derivation
      • Risk Equation Derivation
  • 🔷Resources
    • Community and Customer Support
    • Links
    • Token
    • Whitepaper
    • Roadmap
    • API
      • REST
      • [Future] GraphQL
Powered by GitBook
On this page
  • Constructor
  • AnonConfig Properties
  • Methods
  • Usage Example

Was this helpful?

  1. Anyone SDK
  2. NPM SDK
  3. Run as Library

Anon

The Anon class allows you to run and manage an Anon client with various configuration options.

Constructor

constructor(options?: Partial<AnonConfig>)

Creates a new instance of the Anon class.

  • options (optional): Partial<AnonConfig> - An object containing partial configuration options for the Anon client.

AnonConfig Properties

  • displayLog: boolean - Whether to display logs. Default: false

  • useExecFile: boolean - Whether to use execFile instead of spawn. Default: false

  • socksPort: number - The SOCKS port to use. Default: 9050

  • orPort: number - The OR (Onion Routing) port to use. Default: 0

  • controlPort: number - The control port to use. Default: 9051

  • binaryPath: string | undefined - The path to the Anon binary. Default: undefined

Methods

getSOCKSPort(): number

Retrieves the SOCKS port number configured for the Anon instance.

Returns: The SOCKS port number.

getControlPort(): number

Retrieves the Control port number configured for the Anon instance.

Returns: The Control port number.

getORPort(): number

Retrieves the OR (Onion Routing) port number configured for the Anon instance.

Returns: The OR port number.

async start(): Promise<void>

Starts the Anon client with the options configured in the constructor.

Throws: An error if the Anon process is already started.

async stop(): Promise<void>

Stops the Anon client.

isRunning(): boolean

Checks if the Anon client is currently running.

Returns: true if Anon is running, false otherwise.

Usage Example

javascriptCopyimport { 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();
}
PreviousRun as LibraryNextAnonSocksClient

Last updated 5 months ago

Was this helpful?

🔷