HTTP Proxy to SOCKS Converter (CLI)

1.1.4 · abandoned · verified Wed Apr 22

http-proxy-to-socks (hpts) is a command-line interface (CLI) tool for Node.js designed to convert a SOCKS proxy into an HTTP proxy. This utility is particularly useful in environments where applications or clients only support HTTP proxy configurations, but the available upstream proxy is SOCKS-based. It operates by launching a local HTTP proxy server that intercepts HTTP requests and transparently forwards them through a user-specified SOCKS proxy. The package is currently at version 1.1.4, with its last update approximately six years ago, indicating it is likely in an abandoned or unmaintained state. While it fulfills a specific niche, users should be aware of its age and lack of recent updates. Key differentiators include its simplicity and direct command-line utility for this specific proxy conversion task, contrasting with more comprehensive proxy agents or libraries that might offer programmatic integration.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically execute the `hpts` command-line tool using Node.js's `child_process` module to set up an HTTP proxy on port 8080, forwarding traffic through a SOCKS proxy running on 127.0.0.1:1080. It simulates typical CLI usage for integration or testing.

import { exec } from 'child_process';

const socksHost = '127.0.0.1'; // Replace with your SOCKS proxy host
const socksPort = 1080;      // Replace with your SOCKS proxy port
const httpProxyPort = 8080;  // Port for the HTTP proxy hpts will create

const command = `hpts -s ${socksHost}:${socksPort} -p ${httpProxyPort}`;

console.log(`Starting http-proxy-to-socks: ${command}`);

const hptsProcess = exec(command, (error, stdout, stderr) => {
  if (error) {
    console.error(`exec error: ${error}`);
    return;
  }
  if (stdout) console.log(`stdout: ${stdout}`);
  if (stderr) console.error(`stderr: ${stderr}`);
});

hptsProcess.stdout.on('data', (data) => {
  console.log(`hpts output: ${data.toString().trim()}`);
});

hptsProcess.stderr.on('data', (data) => {
  console.error(`hpts error: ${data.toString().trim()}`);
});

// Keep the process alive for a few seconds to demonstrate. In a real app,
// you'd manage its lifecycle more robustly or run it as a daemon.
setTimeout(() => {
  console.log('Stopping hpts process...');
  hptsProcess.kill();
}, 10000); // Stop after 10 seconds for demonstration

view raw JSON →