Documentation ¶
Index ¶
- Variables
- func HandshakeTimeout(tlsConn *tls.Conn, d time.Duration, plainConn net.Conn) error
- func ListenAndServeTCP(addr string, f func(conn net.Conn)) (net.Listener, error)
- func ParseTLS(acc *BufferReader) (string, error)
- func ServeListener(l net.Listener, f func(conn net.Conn)) error
- type BufferReader
- type ClientHelloMsg
- type CloseWriter
- type Endpoint
- type HBone
- func (hb *HBone) HandleAcceptedH2C(conn net.Conn)
- func (hb *HBone) HandleSNIConn(conn net.Conn)
- func (hb *HBone) HandleTCPProxy(w io.Writer, r io.Reader, hostPort string) error
- func (hb *HBone) NewClient() *HBoneClient
- func (hb *HBone) NewEndpoint(urlOrHost string) *Endpoint
- func (hb *HBone) Proxy(svc string, hbURL string, stdin io.ReadCloser, stdout io.WriteCloser) error
- type HBoneAcceptedConn
- type HBoneClient
- type HTTPConn
- func (hc *HTTPConn) Close() error
- func (hc *HTTPConn) LocalAddr() net.Addr
- func (hc *HTTPConn) Read(b []byte) (n int, err error)
- func (hc *HTTPConn) RemoteAddr() net.Addr
- func (hc *HTTPConn) SetDeadline(t time.Time) error
- func (hc *HTTPConn) SetReadDeadline(t time.Time) error
- func (hc *HTTPConn) SetWriteDeadline(t time.Time) error
- func (hc *HTTPConn) Write(b []byte) (n int, err error)
- type Stream
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Functions ¶
func HandshakeTimeout ¶
HandshakeTimeout wraps tlsConn.Handshake with a timeout, to prevent hanging connection.
func ListenAndServeTCP ¶
func ParseTLS ¶
func ParseTLS(acc *BufferReader) (string, error)
TODO: if a session ID is provided, use it as a cookie and attempt to find the corresponding host. On server side generate session IDs !
TODO: in mesh, use one cypher suite (TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) maybe 2 ( since keys are ECDSA )
Types ¶
type BufferReader ¶
BufferReader wraps a buffer and a Reader. The Fill method will populate the buffer. Read will first return data from the buffer, and if buffer is empty will read directly from the source reader.
func NewBufferReader ¶
func NewBufferReader(in io.Reader) *BufferReader
func (*BufferReader) Close ¶
func (s *BufferReader) Close() error
type ClientHelloMsg ¶
type ClientHelloMsg struct { //CipherSuites []uint16 //compressionMethods []uint8 ServerName string // contains filtered or unexported fields }
type CloseWriter ¶
type CloseWriter interface {
CloseWrite() error
}
CloseWriter is one of possible interfaces implemented by Out to send a FIN, without closing the input. Some writers only do this when Close is called.
type Endpoint ¶
type Endpoint struct { // URL used to reach the H2 endpoint providing the proxy. URL string // SNI name to use - defaults to service name SNI string // SNIGate is the endpoint address of a SNI gate. It can be a normal Istio SNI, a SNI to HBone or other protocols, // or a H2R gate. // If empty, the endpoint will use the URL and HBone protocol directly. // If set, the endpoint will use the nomal in-cluster Istio protocol. SNIGate string // H2Gate is the endpoint of a HTTP/2 gateway. Will be used to dial. // It is expected to have a spiffee identity, and request client certs - // similar with an egress gateway. H2Gate string // contains filtered or unexported fields }
Endpoint is a client for a specific destination.
type HBone ¶
type HBone struct { Cert *tls.Certificate // Non-local endpoints. Key is the 'pod id' of a H2R client Endpoints map[string]*Endpoint // H2R holds H2 client (reverse) connections to the local server. // Will be used to route requests directly. Key is the SNI expected in forwarding requests. H2R map[string]http.RoundTripper SNIAddr string HTTPClientSystem *http.Client HTTPClientMesh *http.Client // Ports is the equivalent of container ports in k8s. // Name follows the same conventions as Istio and should match the port name in the Service. // Port "*" means 'any' port - if set, allows connections to any port by number. // Currently this is loaded from env variables named PORT_name=value, with the default PORT_http=8080 // TODO: refine the 'wildcard' to indicate http1/2 protocol // TODO: this can be populated from a WorkloadGroup object, loaded from XDS or mesh env. Ports map[string]string TokenCallback func(ctx context.Context, host string) (string, error) Mux http.ServeMux // Timeout used for TLS handshakes. If not set, 3 seconds is used. HandsahakeTimeout time.Duration EndpointResolver func(sni string) *Endpoint H2RConn map[*http2.ClientConn]string H2RCallback func(string, *http2.ClientConn) // contains filtered or unexported fields }
HBone represents a node using a HTTP/2 or HTTP/3 based overlay network environment.
Each HBone node has a Istio (spiffee) certificate.
HBone can be used as a client, server or gateway.
func New ¶
func New() *HBone
New creates a new HBone node. It requires a workload identity, including mTLS certificates.
func (*HBone) HandleAcceptedH2C ¶
func (*HBone) HandleSNIConn ¶
func (*HBone) HandleTCPProxy ¶
HandleTCPProxy connects and forwards r/w to the hostPort
func (*HBone) NewClient ¶
func (hb *HBone) NewClient() *HBoneClient
func (*HBone) NewEndpoint ¶
NewEndpoint creates a client for connecting to a specific service:port
The service is mapped to an endpoint URL, protocol, etc. using a config callback, to isolate XDS or discovery dependency.
func (*HBone) Proxy ¶
func (hb *HBone) Proxy(svc string, hbURL string, stdin io.ReadCloser, stdout io.WriteCloser) error
Proxy will proxy in/out (plain text) to a remote service, using mTLS tunnel over H2 POST. used for testing.
type HBoneAcceptedConn ¶
type HBoneAcceptedConn struct {
// contains filtered or unexported fields
}
func (*HBoneAcceptedConn) ServeHTTP ¶
func (hac *HBoneAcceptedConn) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HBoneClient ¶
type HBoneClient struct {
// contains filtered or unexported fields
}
Client for mTLS-over-HTTP/2. Primarily for testing and for the CLI debug helper.
func (HBoneClient) NewEndpoint ¶
func (c HBoneClient) NewEndpoint(url string) *Endpoint
type HTTPConn ¶
type HTTPConn struct {
// contains filtered or unexported fields
}
HTTPConn wraps a http server request/response in a net.Conn
func (*HTTPConn) RemoteAddr ¶
type Stream ¶
func (Stream) CopyBuffered ¶
CopyBuffered will copy src to dst, using a pooled intermediary buffer.
Blocking, returns when src returned an error or EOF/graceful close. May also return with error if src or dst return errors.
CopyBuffered may be called in a go routine, for one of the streams in the connection - the stats and error are returned on a channel.