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
  • Methods
  • Interfaces

Was this helpful?

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

AnonControlClient

The AnonControlClient class provides a way to interact with the Anon Control Port, allowing you to authenticate, send commands, and manage circuits.

Constructor

constructor(host: string = '127.0.0.1', port: number = 9051) Creates a new instance of the AnonControlClient class.

  • host: string - The host of the Anon Control Port. Default: '127.0.0.1'

  • port: number - The port number of the Anon Control Port. Default: 9051

Methods

authenticate(password: string = 'password'): Promise<void>

Authenticates the client with the Anon Control Port.

  • password: string - The password for authentication. Default: 'password' Returns: A promise that resolves when authentication is successful.

sendCommand(command: string): Promise<string>

Sends a command to the Anon Control Port.

  • command: string - The command to send Returns: A promise that resolves with the response from the Anon Control Port.

circuitStatus(): Promise<CircuitStatus[]>

Retrieves the current circuit status. Returns: A promise that resolves with an array of CircuitStatus objects.

extendCircuit(options: ExtendCircuitOptions = {}): Promise<number>

Extends an existing circuit or creates a new one.

  • options: ExtendCircuitOptions - Options for extending the circuit Returns: A promise that resolves with the circuit ID.

closeCircuit(circuitId: number): Promise<void>

Closes a specified circuit.

  • circuitId: number - The ID of the circuit to close Returns: A promise that resolves when the circuit is closed.

getRelayInfo(fingerprint: string): Promise<RelayInfo>

Retrieves information about a relay.

  • fingerprint: string - The fingerprint of the relay Returns: A promise that resolves with a RelayInfo object.

end(): void

Closes the connection to the Anon Control Port.

Interfaces

CircuitStatus

  • circuitId: number

  • state: string

  • relays: Relay[]

  • buildFlags: string[]

  • purpose: string

  • timeCreated: Date

Relay

  • fingerprint: string

  • nickname: string

ExtendCircuitOptions

  • circuitId?: number

  • serverSpecs?: string[]

  • purpose?: 'general' | 'controller'

RelayInfo

  • fingerprint: string

  • nickname: string

  • ip: string

  • orPort: number

  • flags: string[]

  • bandwidth: number

Usage Example

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();
PreviousAnonSocksClientNextRun from CLI

Last updated 5 months ago

Was this helpful?

🔷