http3

package module
v1.2.84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Http3 server for FNS

Install

go get github.com/aacfactory/fns-contrib/transports/http3

Usage

Make sure tls is used.

import (
    "github.com/aacfactory/fns-contrib/transports/http3"
)

tr := http3.New()

Setup config, see quic for more quic config detail.

transport:
  name: "http3"
  tls:
    kind: "SSC"
    options:
      ca: "{path of ca}"
      caKey: "{path of ca key}"
  options:
    enableDatagrams: true
    maxRequestHeaderSize: "4K"
    quic:
      handshakeIdleTimeout: "2s"
      maxIdleTimeout: "60s"
      keepAlivePeriod: "60s"
    client:
      maxConnsPerHost: 64
      maxResponseHeaderSize: "4K"
      timeout: "2s"

Enable announce that this server supports HTTP/3.


tr := http3.NewWithAlternative(fast.New())

transport:
  name: "http3"
  tls:
    kind: "SSC"
    options:
      ca: "{path of ca}"
      caKey: "{path of ca key}"
  options:
    enableDatagrams: true
    maxHeaderBytes: "4K"
    quic:
      handshakeIdleTimeout: "2s"
      maxIdleTimeout: "60s"
      keepAlivePeriod: "60s"
    client:
      maxConnsPerHost: 64
      maxResponseHeaderBytes: "4K"
      timeout: "2s"
    alternative: # alternative http server config
      name: "fasthttp" 
      options:
        foo: "bar"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() transports.Transport

func NewWithAlternative

func NewWithAlternative(alternative transports.Transport) transports.Transport

Types

type AlternativeConfig

type AlternativeConfig struct {
	Name    string          `json:"name"`
	Options json.RawMessage `json:"options"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(address string, roundTripper *http3.RoundTripper, timeout time.Duration) (client *Client)

func (*Client) Close

func (c *Client) Close()

func (*Client) Do

func (c *Client) Do(ctx context.Context, method []byte, path []byte, header transports.Header, body []byte) (status int, responseHeader transports.Header, responseBody []byte, err error)

func (*Client) Key

func (c *Client) Key() (key string)

type ClientConfig

type ClientConfig struct {
	MaxConnsPerHost       int          `json:"maxConnsPerHost"`
	MaxResponseHeaderSize string       `json:"maxResponseHeaderSize"`
	Timeout               string       `json:"timeout"`
	Dialer                DialerConfig `json:"dialer"`
}

func (*ClientConfig) MaxConnectionsPerHost

func (config *ClientConfig) MaxConnectionsPerHost() (n int)

func (*ClientConfig) MaxResponseHeaderByteSize

func (config *ClientConfig) MaxResponseHeaderByteSize() (n uint64, err error)

func (*ClientConfig) TimeoutDuration

func (config *ClientConfig) TimeoutDuration() (n time.Duration, err error)

type Config

type Config struct {
	EnableDatagrams      bool              `json:"enableDatagrams"`
	MaxRequestHeaderSize string            `json:"maxRequestHeaderSize"`
	MaxRequestBodySize   string            `json:"maxRequestBodySize"`
	AdditionalSettings   map[uint64]uint64 `json:"additionalSettings"`
	Quic                 *QuicConfig       `json:"quic"`
	Client               ClientConfig      `json:"client"`
	Alternative          AlternativeConfig `json:"alternative"`
}

func (*Config) ClientConfig

func (config *Config) ClientConfig() (clientConfig ClientConfig)

func (*Config) QuicConfig

func (config *Config) QuicConfig() (quicConfig *quic.Config, err error)

type ConnectionIDGenerator

type ConnectionIDGenerator struct {
}

func (*ConnectionIDGenerator) ConnectionIDLen

func (generator *ConnectionIDGenerator) ConnectionIDLen() int

func (*ConnectionIDGenerator) GenerateConnectionID

func (generator *ConnectionIDGenerator) GenerateConnectionID() (id quic.ConnectionID, err error)

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

func NewDialer

func NewDialer(cliTLS *tls.Config, clientConfig ClientConfig, enableDatagrams bool, quicConfig *quic.Config, additionalSettings map[uint64]uint64) (dialer *Dialer, err error)

func (*Dialer) Close

func (dialer *Dialer) Close()

func (*Dialer) Dial

func (dialer *Dialer) Dial(addressBytes []byte) (client transports.Client, err error)

type DialerConfig added in v1.2.41

type DialerConfig struct {
	CacheSize     int `json:"cacheSize"`
	ExpireSeconds int `json:"expireSeconds"`
}

type Printf

type Printf struct {
	Core logs.Logger
}

func (*Printf) Printf

func (p *Printf) Printf(layout string, v ...interface{})

func (*Printf) Write

func (p *Printf) Write(b []byte) (n int, err error)

type QuicConfig

type QuicConfig struct {
	Versions                       []string `json:"versions"`
	HandshakeIdleTimeout           string   `json:"handshakeIdleTimeout"`
	MaxIdleTimeout                 string   `json:"maxIdleTimeout"`
	InitialStreamReceiveWindow     string   `json:"initialStreamReceiveWindow"`
	MaxStreamReceiveWindow         string   `json:"maxStreamReceiveWindow"`
	InitialConnectionReceiveWindow string   `json:"initialConnectionReceiveWindow"`
	MaxConnectionReceiveWindow     string   `json:"maxConnectionReceiveWindow"`
	MaxIncomingStreams             int64    `json:"maxIncomingStreams"`
	MaxIncomingUniStreams          int64    `json:"maxIncomingUniStreams"`
	KeepAlivePeriod                string   `json:"keepAlivePeriod"`
	DisablePathMTUDiscovery        bool     `json:"disablePathMtuDiscovery"`
	Allow0RTT                      bool     `json:"allow0RTT"`
}

func (*QuicConfig) Convert

func (config *QuicConfig) Convert(enableDatagrams bool) (quicConfig *quic.Config, err error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) Shutdown

func (srv *Server) Shutdown(_ context.Context) (err error)

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func (*Transport) Construct

func (tr *Transport) Construct(options transports.Options) (err error)

func (*Transport) Dial

func (tr *Transport) Dial(address []byte) (client transports.Client, err error)

func (*Transport) ListenAndServe

func (tr *Transport) ListenAndServe() (err error)

func (*Transport) Name

func (tr *Transport) Name() (name string)

func (*Transport) Port

func (tr *Transport) Port() (port int)

func (*Transport) Shutdown

func (tr *Transport) Shutdown(ctx context.Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL