• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”Œ A simple tool that wraps HTTPS proxies into a SOCKS5 proxy.

h2s

GoDoc Release CircleCI Go Report Card License

h2s is a tiny CLI tool that wraps one or multiple HTTPS proxies into a SOCKS5 proxy. It does something like polipo and privoxy do, but in a reversed way.

There are already some SOCKS to HTTPS tools out there, but I can hardly find a reversed one (HTTPS to SOCKS), so I decided to make one on my own.

Install

You can view the release page for handy prebuilt binaries.

Build from Source

h2s relies on stadard libs only.

$ go get -u ekyu.moe/h2s/cmd/h2s

Configure

An example config file:

{
  // bind is the address h2s will listen to.
  // Note that since HTTPS proxy support only TCP, the h2s wrapped SOCKS5
  // proxy consequently support only TCP as well.
  "bind": "127.0.0.1:1080",

  // upstreams are HTTPS proxy upstreams.
  // h2s will do a simple round-robin load balance.
  "upstreams": [{
    // If no port is specified, 80 is assumed by default.
    "address": "proxy1.example.com",
  }, {
    "address": "proxy2.example.com:3128",

    // username and password are optional for proxy authentication.
    "username": "Alice",
    "password": "secret here"
  }, {
    // An HTTPS proxy over TLS upstream.
    // You have to specify port explicitly (usually 443), and set the tls field.
    "address": "secure.proxy.example.com:443",
    "username": "Secure",
    "password": "Yeah!",

    // h2s only provides some basic TLS settings. If you are an advanced user and
    // looking for other settings, you may use stunnel(1) to handle TLS instead,
    // and simply leave a naive TCP interface to h2s.
    "tlsConfig": {
      // If empty, serverName is set to the hostname from address.
      // Most users could just leave it empty.
      "serverName": "secure.proxy.example.com",

      // If you prefer to set a fingerprint instead of providing certs, you can
      // set this to true.
      // Do not set to true unless you know what you are doing.
      "insecureSkipVerify": false,
      // Server's SHA256 fingerprint, used to verify as an alternative to providing
      // the whole server certs, should be used with insecureSkipVerify to true.
      // If both rootCA and sha256Fingerprint are provided, they will both be
      // verified.
      //
      // An example to get fingerprint of a given cert:
      //     openssl x509 -fingerprint -sha256 -noout -in cert.cer | cut -f2 -d'=' | sed s/://g
      // or of a server with TLS enabled:
      //      openssl s_client -showcerts -connect example.com:443 < /dev/null | \
      //        openssl x509 -fingerprint -sha256 -noout | cut -f2 -d'=' | sed s/://g
      "sha256fingerprint": "22B975A1409850EF7F4522183E9C5A8955758FC899D70FE257112DA2FC430CCC",

      // rootCA is useful for self-signed certs. Be careful with it.
      // If the server has a trusted cert, you don't have to set it.
      "rootCA": "/path/to/the/ca/cert",

      // certFile and keyFile are advanced options for client authentication.
      // Most users could just leave it empty.
      "certFile": "/path/to/the/client/cert",
      "keyFile": "/path/to/the/client/key"
    }
  }],

  // accounts is an optional array of accounts for SOCKS5 authentication
  // with no accounts, authentication is disabled
  "accounts": [{
    "username": "test server",
    "password": "test"
  }],

  // timeout optionally sets timeout value when dialing to a upstream
  // default "20s"
  "timeout": "20s",
  // retries optionally specifies the max retries count of dialing to upstreams
  // default 3.
  "retries": 3
}

Usage

$ h2s [-config h2s.json]

License

MIT

More Repositories

1

mjai-reviewer

๐Ÿ”๐Ÿ€„๏ธ Review mahjong game log with mjai-compatible mahjong AI.
Rust
887
star
2

Mortal

๐Ÿš€๐Ÿ€„๏ธ A fast and strong AI for riichi mahjong, powered by Rust and deep reinforcement learning.
Rust
736
star
3

cryptonight

โžฟ Pure Go/ASM implementation of CryptoNight hash function with its variants, without any CGO binding.
Go
77
star
4

vanity-monero

๐Ÿ’ณ Generate vanity address for CryptoNote currency (Monero etc.).
Go
64
star
5

base256

๐ŸŒ€ binary-to-emoji encoding.
Go
30
star
6

tensoul

Convert MahjongSoul log into tenhou.net/6 format
JavaScript
24
star
7

koa-virtual-host

โšก A name-based virtual host middleware for Koa2.
JavaScript
16
star
8

base91

๐Ÿ”ก basE91 codec in pure JavaScript implementation.
JavaScript
13
star
9

base91-go

๐Ÿ”ก basE91 codec in pure Golang implementation.
Go
9
star
10

leb128

Go implementation of Little Endian Base 128 codec.
Go
8
star
11

sha3sum

A sha3sum CLI utility based on golang.org/x/crypto/sha3
Go
6
star
12

broken-pantsu

๐Ÿ’˜ Love, rather than sorry.
Go
6
star
13

csu-ems-api

๐Ÿ” A kit of third-party APIs for the EMS of CSU, based on Node.js.
JavaScript
5
star
14

soda-old

1 of 3 - Get Away from Eve.
Go
2
star
15

tenhou-convlog

Convert tenhou log to format ้›ป่„ณ้บปๅฐ† can understand
JavaScript
2
star
16

My-OJ-Solutions

โœ… My solutions in LeetCode OJ, Codewars, Vijos, AOJ, CSUOJ, etc..
C#
1
star
17

util

A kit of helpful utilities for Golang.
Go
1
star
18

eae

2 of 3: Alice Across over Time
Go
1
star
19

thompson-hack-go

PoC of a Thompson hack upon Go.
Go
1
star
20

Equim-chan

1
star
21

str-cat

Rust
1
star
22

libb256

C implementation of base256 (a binary-to-emoji encoding).
C
1
star
23

equim-chan.github.io

HTML
1
star