HTTP CONNECT Proxy
start-http-proxy
8.12

HTTP CONNECT Proxy🔗ℹ

Bogdan Popa <bogdan@defn.io>

This package provides a simple HTTP CONNECT proxy implementation.

procedure

(start-http-proxy [#:host host    
  #:port port    
  #:ssl-ctx ssl-ctx    
  #:port-ch port-ch    
  handler])  (-> void?)
  host : (or/c #f string?) = "127.0.0.1"
  port : (integer-in 0 65535) = 1080
  ssl-ctx : (or/c #f ssl-server-context?) = #f
  port-ch : (or/c #f (channel/c (integer-in 1 65535))) = #f
  handler : 
(-> string? (integer-in 1 65535)
    string? (integer-in 1 65535)
    (listof bytes?)
    bytes?)
   = (lambda (src-host src-port dst-host dst-port headers) #"200 OK")
Starts an HTTP proxy bound to the interface associated with host and listening on port. Returns a procedure that stops the server when called. The returned stop procedure blocks while there are active connections and breaking while the procedure blocks immediately stops the server and closes all open connections.

When port-ch is a channel, the server sends the port it’s bound to over it once ready.

The handler procedure determines which clients are allowed to connect to which destination servers. A return value of #"200 OK" from the handler signals to the server that the client is allowed to connect to the destination.