Giter Site home page Giter Site logo

httransform's Introduction

httransform

Build Status codecov Go Reference

httransform is the library/framework to build your own HTTP proxies. It relies on high-performant and memory-efficient fasthttp library as HTTP base layer and can give you the ability to build a proxy where you can control every aspect.

Main features of this framework:

  1. Support of HTTP (plain HTTP) proxy protocol.
  2. Support of HTTPS (with CONNECT method) protocol. This library does MITM and provides the possibility to generate TLS certificates for the hosts on-the-fly.
  3. Keeps and maintains the order of headers and their case (no normalization).
  4. Supports the concept of layers or middlewares which process HTTP requests and responses.
  5. Supports custom executors: a function which converts HTTP requests to HTTP responses. Allowing your proxy to fetch the data from other services, which are not necessarily HTTP. The executor simply converts HTTP request structure to HTTP response.
  6. Can support connection upgrades (this includes websockets) with an ability to look into them.

Please check the full documentation for more details.

Example

Just a small example to give you the feeling of how it all looks like:

package main

import (
	"context"
	"net"
	"os"
	"os/signal"
	"syscall"
	"time"

	"github.com/9seconds/httransform/v2"
	"github.com/9seconds/httransform/v2/auth"
	"github.com/9seconds/httransform/v2/layers"
)

// These are generates examples of self-signed certificates
// to simplify the example.
var caCert = []byte(`-----BEGIN CERTIFICATE-----
MIICWzCCAcSgAwIBAgIJAJ34yk7oiKv5MA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTgxMjAyMTQyNTAyWhcNMjgxMTI5MTQyNTAyWjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
gQDL7Hzfmx7xfFWTRm26t/lLsCZwOri6VIzp2dYM5Hp0dV4XUZ+q60nEbHwN3Usr
GKAK/Rsr9Caam3A18Upn2ly69Tyr29kVK+PlsOgSSCUnAYcqT166/j205n3CGNLL
OPtQKfAT/i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22+49Z0pi2mk3jVMUhpmWprNoQJBANdAT0v2XFpXfQ38bTQMYT82j9Myytdg
npjRm++Rs1AdvoIbZb52OqIoqoaVoxJnVchLD6t5LYXnecesAcok1e8CQEKB7ycJ
6yVwnBE3Ua9CHcGmrre6HmEWdPy1Zyb5DQC6duX46zEBzti9oWx0DJIQRZifeCvw
4J45NsSQjuuAAWs=
-----END PRIVATE KEY-----`)

func main() {
	// Root context is crucial here. When root context is closed, a
	// proxy is shutdown.
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	// For demo purpose we are going to close by SIGINT and SIGTERM
	// signals.
	signals := make(chan os.Signal, 1)

	signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)

	go func() {
		for range signals {
			cancel()
		}
	}()

	// Filter layer is required if you want to drop request
	// which are made to you internal networks.
	filterLayer, err := layers.NewFilterSubnetsLayer([]net.IPNet{
		{IP: net.ParseIP("127.0.0.0"), Mask: net.CIDRMask(8, 32)},
		{IP: net.ParseIP("172.16.0.0"), Mask: net.CIDRMask(12, 32)},
		{IP: net.ParseIP("10.0.0.0"), Mask: net.CIDRMask(8, 32)},
		{IP: net.ParseIP("192.168.0.0"), Mask: net.CIDRMask(16, 32)},
	})
	if err != nil {
		panic(err)
	}

	opts := httransform.ServerOpts{
		TLSCertCA:     caCert,
		TLSPrivateKey: caPrivateKey,
		// We are going to use basic proxy authorization with username
		// 'user' and password 'password'.
		Authenticator: auth.NewBasicAuth(map[string]string{
			"user": "password",
		}),
		Layers: []layers.Layer{
			filterLayer,
			// This guy will remove Proxy headers from the request.
			layers.ProxyHeadersLayer{},
			// This guy is going to limit request processing time to 3
			// minutes.
			layers.TimeoutLayer{
				Timeout: 3 * time.Minute,
			},
		},
	}

	proxy, err := httransform.NewServer(ctx, opts)
	if err != nil {
		panic(err)
	}

	// We bind our proxy to the port 3128 and all interfaces.
	listener, err := net.Listen("tcp", ":3128")
	if err != nil {
		panic(err)
	}

	if err := proxy.Serve(listener); err != nil {
		panic(err)
	}
}

This will create an HTTP proxy on 127.0.0.1:3128. It will also require authentication (user and password) and will remove the Proxy-Authorization header before sending the request further.

v1 version

Version 1 is not supported anymore. Please use version 2. Version 2 has a lot of breaking changes but which really help to maintain a package.

Unfortunately, I cannot enumerate all of them and I understand that it is going to make your life painful in some moments. Sorry for that. v2 was a complete rewrite and I assume that given a size of this library, it won't take a lot of time for you to migrate. But if you have any questions, feel free to open an issue. I'm happy to help.

httransform's People

Contributors

9seconds avatar azlotnikov avatar dependabot[bot] avatar geronsv avatar ldaneliukas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

httransform's Issues

Only one Set-Cookie header in response

in headerset.go func (hs *HeaderSet) SetBytes(key []byte, value []byte)

        if position, ok := hs.index[lowerKey]; ok {
		hs.values[position].Value = value
	} else {
		newHeader := getHeader()
		newHeader.ID = lowerKey
		newHeader.Key = append(newHeader.Key, key...)
		newHeader.Value = append(newHeader.Value, value...)
		hs.values = append(hs.values, newHeader)
		hs.index[lowerKey] = len(hs.values) - 1
	}

When lowerKey=set-cookie only the last one cookie will remain.

Can be easily checked with curl

curl -I -X GET -x http://127.0.0.1:64890 https://mail.ru -k

1 cookie in response

curl -I -X GET https://mail.ru -k

2 cookies in response

Proxy example doesn't work with https://golang.org

Hi,

MacOS 11 intel-mac, golang 1.15.12, example from here - https://github.com/9seconds/httransform#example ,

MacBook-Pro:golang1.15.12 mixadior$ curl -Gvk --proxy http://user:[email protected]:3128 https://golang.org/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3128 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to golang.org:443
* Proxy auth using Basic with user 'user'
> CONNECT golang.org:443 HTTP/1.1
> Host: golang.org:443
> Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==
> User-Agent: curl/7.64.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Content-Length: 0
* Ignoring Content-Length in CONNECT 200 response
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* CONNECT phase completed!
* CONNECT phase completed!
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=golang.org
*  start date: May 31 14:15:10 2021 GMT
*  expire date: Sep  1 14:15:10 2021 GMT
*  issuer: C=AU; ST=Some-State; O=Internet Widgits Pty Ltd
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET / HTTP/1.1
> Host: golang.org
> User-Agent: curl/7.64.1
> Accept: */*
>
* TLSv1.2 (IN), TLS alert, close notify (256):
* Connection #0 to host 127.0.0.1 left intact
* Closing connection 0
MacBook-Pro:golang1.15.12 mixadior$

At the same time https://httpbin.org/ip works:

MacBook-Pro:golang1.15.12 mixadior$ curl -Gvk --proxy http://user:[email protected]:3128 https://httpbin.org/ip
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3128 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to httpbin.org:443
* Proxy auth using Basic with user 'user'
> CONNECT httpbin.org:443 HTTP/1.1
> Host: httpbin.org:443
> Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==
> User-Agent: curl/7.64.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Content-Length: 0
* Ignoring Content-Length in CONNECT 200 response
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* CONNECT phase completed!
* CONNECT phase completed!
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=httpbin.org
*  start date: May 31 14:16:02 2021 GMT
*  expire date: Sep  1 14:16:02 2021 GMT
*  issuer: C=AU; ST=Some-State; O=Internet Widgits Pty Ltd
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET /ip HTTP/1.1
> Host: httpbin.org
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: gunicorn/19.9.0
< Date: Tue, 01 Jun 2021 14:20:09 GMT
< Content-Type: application/json
< Content-Length: 33
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Connection: close
<
{
  "origin": "178.150.141.27"
}
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, close notify (256):
MacBook-Pro:golang1.15.12 mixadior$

Seems Content-Length > 0 works, but streaming - doesn't:

MacBook-Pro:golang1.15.12 mixadior$ curl -Gvk --proxy http://user:[email protected]:3128 https://httpbin.org/stream/25
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3128 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to httpbin.org:443
* Proxy auth using Basic with user 'user'
> CONNECT httpbin.org:443 HTTP/1.1
> Host: httpbin.org:443
> Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==
> User-Agent: curl/7.64.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Content-Length: 0
* Ignoring Content-Length in CONNECT 200 response
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* CONNECT phase completed!
* CONNECT phase completed!
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=httpbin.org
*  start date: May 31 14:16:02 2021 GMT
*  expire date: Sep  1 14:16:02 2021 GMT
*  issuer: C=AU; ST=Some-State; O=Internet Widgits Pty Ltd
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET /stream/25 HTTP/1.1
> Host: httpbin.org
> User-Agent: curl/7.64.1
> Accept: */*
>
* TLSv1.2 (IN), TLS alert, close notify (256):
* Connection #0 to host 127.0.0.1 left intact
* Closing connection 0
MacBook-Pro:golang1.15.12 mixadior$

It's a bug or i this is limitation of default executor and i should implement own executor with support of streaming?

Too small buffer size for response headers

Some sites (instagram for example) send large headers.
So the buffer size const bufioReaderSize = 1024 * 4 is not enough

screen

Maybe we can have this option moved into config?

For instagram it was enough to set const bufioReaderSize = 1024 * 5

Cloudflare somehow detects and blocks httransform

Hi,

Small intro: i use proxy server build on top of httransform lib in combination with google chrome (passing cli flag --proxy-server=127.0.0.1:3128).

proxy code:

package main

import (
    "context"
    "net"
    "os"
    "os/signal"
    "syscall"
    "time"

    "github.com/9seconds/httransform/v2"
    "github.com/9seconds/httransform/v2/layers"
)

// These are generates examples of self-signed certificates
// to simplify the example.
var caCert = []byte(`-----BEGIN CERTIFICATE-----
MIICWzCCAcSgAwIBAgIJAJ34yk7oiKv5MA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTgxMjAyMTQyNTAyWhcNMjgxMTI5MTQyNTAyWjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
gQDL7Hzfmx7xfFWTRm26t/lLsCZwOri6VIzp2dYM5Hp0dV4XUZ+q60nEbHwN3Usr
GKAK/Rsr9Caam3A18Upn2ly69Tyr29kVK+PlsOgSSCUnAYcqT166/j205n3CGNLL
OPtQKfAT/iH3dPBObd8N4FR9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jVMUhpmWprNoQJBANdAT0v2XFpXfQ38bTQMYT82j9Myytdg
npjRm++Rs1AdvoIbZb52OqIoqoaVoxJnVchLD6t5LYXnecesAcok1e8CQEKB7ycJ
6yVwnBE3Ua9CHcGmrre6HmEWdPy1Zyb5DQC6duX46zEBzti9oWx0DJIQRZifeCvw
4J45NsSQjuuAAWs=
-----END PRIVATE KEY-----`)

func main() {
    // Root context is crucial here. When root context is closed, a
    // proxy is shutdown.
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()

    // For demo purpose we are going to close by SIGINT and SIGTERM
    // signals.
    signals := make(chan os.Signal, 1)

    signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)

    go func() {
        for range signals {
            cancel()
        }
    }()

    // Filter layer is required if you want to drop request
    // which are made to you internal networks.
    filterLayer, err := layers.NewFilterSubnetsLayer([]net.IPNet{
        {IP: net.ParseIP("127.0.0.0"), Mask: net.CIDRMask(8, 32)},
        {IP: net.ParseIP("172.16.0.0"), Mask: net.CIDRMask(12, 32)},
        {IP: net.ParseIP("10.0.0.0"), Mask: net.CIDRMask(8, 32)},
        {IP: net.ParseIP("192.168.0.0"), Mask: net.CIDRMask(16, 32)},
    })
    if err != nil {
        panic(err)
    }

    opts := httransform.ServerOpts{
        TLSCertCA:     caCert,
        TLSPrivateKey: caPrivateKey,
        // We are going to use basic proxy authorization with username
        // 'user' and password 'password'.
        //Authenticator: auth.NewBasicAuth(map[string]string{
        //    "user": "password",
        //}),
        Layers: []layers.Layer{
            filterLayer,
            // This guy will remove Proxy headers from the request.
            layers.ProxyHeadersLayer{},
            // This guy is going to limit request processing time to 3
            // minutes.
            layers.TimeoutLayer{
                Timeout: 3 * time.Minute,
            },
        },
        TLSSkipVerify: false,
    }

    proxy, err := httransform.NewServer(ctx, opts)
    if err != nil {
        panic(err)
    }

    // We bind our proxy to the port 3128 and all interfaces.
    listener, err := net.Listen("tcp", ":3128")
    if err != nil {
        panic(err)
    }

    if err := proxy.Serve(listener); err != nil {
        panic(err)
    }
}

i open site https://www.meretdemeures.com/ and with proxy i receive Error 1020 and without proxy page is ok.
i understand, that this is kinda offtopic, if it is - just close issue. But seems cloudflare detects that SSL connection is hijacked and blocks such requests. Is it possible to turn off hijacking and use httransform as chaining proxy?

Thx for help.

"tls: handshake failure" error for some hosts

Found this error while trying to connect to angel.co

Cannot fetch from upstream: cannot send a request: remote error: tls: handshake failure

Error occuries with proxy chain executor and without it

ln, _ := net.Listen("tcp", ":3128")
srv, _ := httransform.NewServer(httransform.ServerOpts{
        CertCA:   caCert,
	CertKey:  caPrivateKey,
})
srv.Serve(ln)
curl -k --proxy localhost:3128 https://angel.co

Send on closed channel panic

runtime.fatalpanic at panic.go:690
runtime.gopanic at panic.go:565
runtime.chansend at chan.go:252
runtime.chansend1 at chan.go:127
github.com/9seconds/httransform/ca.(*CA).Get at ca.go:72
github.com/9seconds/httransform.(*Server).makeHijackHandler.func1 at server.go:96
github.com/valyala/fasthttp.hijackConnHandler at server.go:2150
runtime.goexit at asm_amd64.s:1337
 - Async stack trace
github.com/valyala/fasthttp.(*Server).serveConn at server.go:2110

After srv.Shutdown() some requests still being processed, but certs channels already closed, i tried to create code, that reproduce problem, but failed.

  1. Create chaining proxy
  2. Set it in browser
  3. Actively open https sites
  4. Shutdown in separate goroutine server, continuing opening sites in browser
  5. Panic

It reproduces well, when you actively use headless browsers and do big requests amount.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.