# 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

```javascript
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();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.anyone.io/sdk/npm/library/anon.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
