# socksjs

> A SOCKS (v5) client library for node.js

Latest version **0.5.0** (published 2014-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install socksjs
pnpm add socksjs
yarn add socksjs
bun add socksjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2014-11-26 |
| First published | 2013-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Jack Allnutt |
| Maintainers | m2ys4u |
| Keywords | SOCKS, SOCKS5, SOCKS client, client |

## Links

- npm: https://www.npmjs.com/package/socksjs
- Repository: https://github.com/M2Ys4U/socksjs
- Issues: https://github.com/M2Ys4U/socksjs/issues
- npm.io page: https://npm.io/package/socksjs

## Dependencies (1)

- [ipaddr.js](https://npm.io/package/ipaddr.js.md) 0.1.3

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2014-11-26
- 0.4.5 — 2014-09-22
- 0.4.4 — 2014-02-12
- 0.4.3 — 2013-10-27
- 0.4.1 — 2013-06-05
- 0.4.0 — 2013-06-05
- 0.3.4 — 2013-05-29
- 0.3.3 — 2013-05-22
- 0.3.2 — 2013-05-09
- 0.3.1 — 2013-04-19
- 0.3.0 — 2013-04-19

## README

socksjs
=======

A SOCKS (v5) client library for node.js

## Installation ##

`` $ npm install socksjs ``

## API ##

`` var SocksConnection = require('socksjs');``

SocksConnection implements node's Duplex Stream. See the Node documentation for [Stream consumers](http://nodejs.org/api/stream.html#stream_api_for_stream_consumers) to see what methods and events are available in addition to those listed below.

### Creating a new SocksConnection ###
`` var sock = new SocksConnection(remote_options, sock_options); ``
`` var sock = SocksConnection.connect(remote_options, sock_options, connect_handler);``

**remote_options**
* ``port`` - The port to connect to (mandatory)
* ``host`` - The hostname or IP to connect to through the SOCKS proxy (optional, default: ``'localhost'``)
* ``ssl`` - Connect using SSL (optional, default ``false``)
* ``rejectUnauthorised`` - If ``true``, the server certificate is verified against the list of supplied CAs. An ``'error'`` event is emitted if verification fails (optional, default: ``false``)
* ``key:`` - A string or Buffer containing the private key of the client in PEM format.
* ``cert`` - A string or Buffer containing the certificate key of the client in PEM format.

**socks_options**
* ``localAddress`` - The local interface to bind to for the outgoing connections (optional, default: ``0.0.0.0``)
* ``allowHalfOpen`` -  If ``true``, the socket won't automatically send a FIN packet when the other end of the socket sends a FIN packet. (optional, default: ``false``)
* ``host`` - The hostname or IP of the SOCKS proxy (optional, default: ``localhost``)
* ``port`` - The SOCKS proxy's port (optional, default: ``1080``)
* ``user`` - The username to use to authenticate to the SOCKS proxy (optional, default: ``null``)
* ``pass`` - The password to use to authenticate to the SOCKS proxy (optional, default: ``null``)

**connection_listener**

Function to attach to the 'connect' event of the SocksConnection

### Additional Methods ###
``getPeerCertificate`` - Returns an object representing the peer's certificate. See the [Node tls documentation](http://nodejs.org/api/tls.html#tls_cleartextstream_getpeercertificate) for more information.

### Events ###
#### ``connect`` ####
SocksConnection will emit a ``connect`` event when it has successfully connected to the target host

#### ``error`` ####
SocksConnection will emit an ``error`` event if it cannot connect to the SOCKS proxy, target host or if there is an error during the connection's lifetime.

## Contributing ##
### Tests ###
socksjs needs tests. Pull requests with testcases are much appreciated.

## License ##
socksjs (C) 2013 Jack Allnutt and is licensed under the [MIT license](http://opensource.org/licenses/MIT), a copy of which can be found in the LICENSE file.

---
_Source: https://npm.io/package/socksjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
