internal

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: BSD-2-Clause Imports: 27 Imported by: 0

README

Internal is the core of Hemi.

THE BIG PICTURE

TODO

THE WEB PICTURE

  --http[1-3]Stream-->                        ----H[1-3]Stream--->
  ----hwebExchan----->                        ------HExchan------>
                  ^                                           ^
  [REVISERS]      |    -------pass/post----->                 |
                  |                                           |
  webIn_          | webStream                 webOut_         | webStream
  ^ - stream -----+                           ^ - stream -----+
  |                                           |
  | - shell ------+                           | - shell ------+
  |               | webIn                     |               | webOut
  +-serverRequest_|                           +-clientRequest_|
    ^             |                             ^             |
    |             v                             |             v
    +-http[1-3]Request                          +-H[1-3]Request
    +-hwebRequest                               +-HRequest
                            \           /
                  \          \         /
        1/2/3      \          \       /             1/2/3
     [webServer]   [Handlet]/[webProxy]          [webClient]
        1/2/3      /          /       \             1/2/3
                  /          /         \
                            /           \
  <--http[1-3]Stream--                        <---H[1-3]Stream----
  <----hwebExchan-----                        <-----HExchan-------
                   ^                                           ^
  [REVISERS]       |   <------pass/post------                  |
                   |                                           |
  webOut_          | webStream                webIn_           | webStream
  ^ - stream ------+                          ^ - stream ------+
  |                                           |
  | - shell -------+                          | - shell -------+
  |                | webOut                   |                | webIn
  +-serverResponse_|                          +-clientResponse_|
    ^              |                            ^              |
    |              v                            |              v
    +-http[1-3]Response                         +-H[1-3]Response
    +-hwebResponse                              +-HResponse

NOTES

  • messages are composed of control, headers, [content, [trailers]].
  • control & headers is called head, and it must be small (<=16K).
  • contents, if exist (perhaps of zero size), may be large (>64K1) or small (<=64K1), sized or unsized.
  • trailers must be small (<=16K), and only exist when contents exist and are unsized.
  • incoming messages need parsing.
  • outgoing messages need building.
  • adding headers to incoming messages: apply + check.
  • adding headers to outgoing messages: insert + append.
  • deleting headers from outgoing messages: remove + delete.
  • proxies can be forward or reverse.

WEB SERVER -> WEB PROXY -> WEB CLIENT

  • we support HTTP/1.x in server side, but we don't support HTTP/1.0 in client side.
  • we support revisers in server side, but we don't support revisers in client side.
  • HTTP/1.1 pipelining is recognized in server side, but not optimized.
  • HTTP/1.1 pipelining is not used in client side.
  • in HTTP/2 server side, streams are started passively (by receiving a HEADERS frame).
  • in HTTP/2 client side, streams are started actively.

Documentation

Index

Constants

View Source
const (
	K = 1 << 10
	M = 1 << 20
	G = 1 << 30
	T = 1 << 40
)
View Source
const (
	CodeBug = 20
	CodeUse = 21
	CodeEnv = 22
)
View Source
const (
	Version1_0 = 0 // must be 0
	Version1_1 = 1
	Version2   = 2
	Version3   = 3
)
View Source
const (
	SchemeHTTP  = 0 // must be 0
	SchemeHTTPS = 1
)
View Source
const (
	MethodGET     = 0x00000001
	MethodHEAD    = 0x00000002
	MethodPOST    = 0x00000004
	MethodPUT     = 0x00000008
	MethodDELETE  = 0x00000010
	MethodCONNECT = 0x00000020
	MethodOPTIONS = 0x00000040
	MethodTRACE   = 0x00000080
)
View Source
const (
	// 1XX
	StatusContinue           = 100
	StatusSwitchingProtocols = 101
	StatusProcessing         = 102
	StatusEarlyHints         = 103
	// 2XX
	StatusOK                         = 200
	StatusCreated                    = 201
	StatusAccepted                   = 202
	StatusNonAuthoritativeInfomation = 203
	StatusNoContent                  = 204
	StatusResetContent               = 205
	StatusPartialContent             = 206
	StatusMultiStatus                = 207
	StatusAlreadyReported            = 208
	StatusIMUsed                     = 226
	// 3XX
	StatusMultipleChoices   = 300
	StatusMovedPermanently  = 301
	StatusFound             = 302
	StatusSeeOther          = 303
	StatusNotModified       = 304
	StatusUseProxy          = 305
	StatusTemporaryRedirect = 307
	StatusPermanentRedirect = 308
	// 4XX
	StatusBadRequest                  = 400
	StatusUnauthorized                = 401
	StatusPaymentRequired             = 402
	StatusForbidden                   = 403
	StatusNotFound                    = 404
	StatusMethodNotAllowed            = 405
	StatusNotAcceptable               = 406
	StatusProxyAuthenticationRequired = 407
	StatusRequestTimeout              = 408
	StatusConflict                    = 409
	StatusGone                        = 410
	StatusLengthRequired              = 411
	StatusPreconditionFailed          = 412
	StatusContentTooLarge             = 413
	StatusURITooLong                  = 414
	StatusUnsupportedMediaType        = 415
	StatusRangeNotSatisfiable         = 416
	StatusExpectationFailed           = 417
	StatusMisdirectedRequest          = 421
	StatusUnprocessableEntity         = 422
	StatusLocked                      = 423
	StatusFailedDependency            = 424
	StatusTooEarly                    = 425
	StatusUpgradeRequired             = 426
	StatusPreconditionRequired        = 428
	StatusTooManyRequests             = 429
	StatusRequestHeaderFieldsTooLarge = 431
	StatusUnavailableForLegalReasons  = 451
	// 5XX
	StatusInternalServerError           = 500
	StatusNotImplemented                = 501
	StatusBadGateway                    = 502
	StatusServiceUnavailable            = 503
	StatusGatewayTimeout                = 504
	StatusHTTPVersionNotSupported       = 505
	StatusVariantAlsoNegotiates         = 506
	StatusInsufficientStorage           = 507
	StatusLoopDetected                  = 508
	StatusNotExtended                   = 510
	StatusNetworkAuthenticationRequired = 511
)
View Source
const Version = "0.1.7"

Variables

This section is empty.

Functions

func BaseDir

func BaseDir() string

func BugExitf

func BugExitf(format string, args ...any)

func BugExitln

func BugExitln(args ...any)

func Debug

func Debug() int32

func EnvExitf

func EnvExitf(format string, args ...any)

func EnvExitln

func EnvExitln(args ...any)

func Error added in v0.1.5

func Error(args ...any)

func Errorf added in v0.1.5

func Errorf(format string, args ...any)

func Errorln added in v0.1.5

func Errorln(args ...any)

func Get16K

func Get16K() []byte

func Get4K

func Get4K() []byte

func Get64K1

func Get64K1() []byte

func GetNK

func GetNK(n int64) []byte

func LogsDir

func LogsDir() string

func Print added in v0.1.5

func Print(args ...any)

func Printf added in v0.1.5

func Printf(format string, args ...any)

func Println added in v0.1.5

func Println(args ...any)

func PutNK

func PutNK(p []byte)

func RegisterAppInit

func RegisterAppInit(name string, init func(app *App) error)

func RegisterBackend

func RegisterBackend(sign string, create func(name string, stage *Stage) Backend)

func RegisterCronjob

func RegisterCronjob(sign string, create func(name string, stage *Stage) Cronjob)

func RegisterHandlet

func RegisterHandlet(sign string, create func(name string, stage *Stage, app *App) Handlet)

func RegisterQUICFilter added in v0.1.0

func RegisterQUICFilter(sign string, create func(name string, stage *Stage, mesher *QUICMesher) QUICFilter)

func RegisterReviser

func RegisterReviser(sign string, create func(name string, stage *Stage, app *App) Reviser)

func RegisterRunner added in v0.1.2

func RegisterRunner(sign string, create func(name string, stage *Stage) Runner)

func RegisterServer

func RegisterServer(sign string, create func(name string, stage *Stage) Server)

func RegisterSocklet

func RegisterSocklet(sign string, create func(name string, stage *Stage, app *App) Socklet)

func RegisterStater

func RegisterStater(sign string, create func(name string, stage *Stage) Stater)

func RegisterStorer added in v0.1.6

func RegisterStorer(sign string, create func(name string, stage *Stage) Storer)

func RegisterSvcInit

func RegisterSvcInit(name string, init func(svc *Svc) error)

func RegisterTCPSFilter added in v0.1.0

func RegisterTCPSFilter(sign string, create func(name string, stage *Stage, mesher *TCPSMesher) TCPSFilter)

func RegisterUDPSFilter added in v0.1.0

func RegisterUDPSFilter(sign string, create func(name string, stage *Stage, mesher *UDPSMesher) UDPSFilter)

func SetBaseDir

func SetBaseDir(dir string)

func SetDebug

func SetDebug(level int32)

func SetLogsDir

func SetLogsDir(dir string)

func SetTempDir

func SetTempDir(dir string)

func SetVarsDir

func SetVarsDir(dir string)

func TempDir

func TempDir() string

func UseExitf

func UseExitf(format string, args ...any)

func UseExitln

func UseExitln(args ...any)

func VarsDir

func VarsDir() string

Types

type App

type App struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

App is the Web application.

func (*App) AddSetting

func (a *App) AddSetting(name string, value string)

func (*App) Handlet

func (a *App) Handlet(name string) Handlet

func (*App) IncSub

func (w *App) IncSub(n int)

func (*App) Log

func (a *App) Log(str string)

func (*App) Logf

func (a *App) Logf(format string, args ...any)

func (*App) Logln

func (a *App) Logln(str string)

func (*App) Loop

func (s *App) Loop(interval time.Duration, callback func(now time.Time))

func (*App) OnConfigure

func (a *App) OnConfigure()

func (*App) OnPrepare

func (a *App) OnPrepare()

func (*App) OnShutdown

func (a *App) OnShutdown()

func (*App) Reviser

func (a *App) Reviser(name string) Reviser

func (*App) Rule

func (a *App) Rule(name string) *Rule

func (*App) SaveContentFilesDir

func (s *App) SaveContentFilesDir() string

func (*App) Setting

func (a *App) Setting(name string) (value string, ok bool)

func (*App) Socklet

func (a *App) Socklet(name string) Socklet

func (*App) SubDone

func (w *App) SubDone()

func (*App) WaitSubs

func (w *App) WaitSubs()

type Backend

type Backend interface {
	// Imports
	Component

	// Methods
	Maintain() // goroutine
	// contains filtered or unexported methods
}

Backend is a group of nodes.

type Backend_

type Backend_[N Node] struct {
	// contains filtered or unexported fields
}

Backend_ is the mixin for backends.

func (*Backend_) AliveTimeout

func (c *Backend_) AliveTimeout() time.Duration

func (*Backend_[N]) Maintain

func (b *Backend_[N]) Maintain()

func (*Backend_) OnShutdown

func (c *Backend_) OnShutdown()

func (*Backend_) ReadTimeout

func (c *Backend_) ReadTimeout() time.Duration

func (*Backend_) Stage

func (c *Backend_) Stage() *Stage

func (*Backend_) TLSMode

func (c *Backend_) TLSMode() bool

func (*Backend_) WriteTimeout

func (c *Backend_) WriteTimeout() time.Duration

type Bundlet added in v0.1.6

type Bundlet interface {
}

Bundlet is a bundle of procedures in Svc.

type Chain

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

Chain is a linked-list of pieces.

func (*Chain) NumPieces

func (c *Chain) NumPieces() int

func (*Chain) PushHead

func (c *Chain) PushHead(piece *Piece)

func (*Chain) PushTail

func (c *Chain) PushTail(piece *Piece)

func (*Chain) Size

func (c *Chain) Size() (int64, bool)

type Component

type Component interface {
	MakeComp(name string)
	OnShutdown()
	SubDone() // sub components call this

	Name() string

	OnConfigure()
	Find(name string) (value Value, ok bool)
	Prop(name string) (value Value, ok bool)
	ConfigureBool(name string, prop *bool, defaultValue bool)
	ConfigureInt64(name string, prop *int64, check func(value int64) error, defaultValue int64)
	ConfigureInt32(name string, prop *int32, check func(value int32) error, defaultValue int32)
	ConfigureInt16(name string, prop *int16, check func(value int16) error, defaultValue int16)
	ConfigureInt8(name string, prop *int8, check func(value int8) error, defaultValue int8)
	ConfigureInt(name string, prop *int, check func(value int) error, defaultValue int)
	ConfigureString(name string, prop *string, check func(value string) error, defaultValue string)
	ConfigureBytes(name string, prop *[]byte, check func(value []byte) error, defaultValue []byte)
	ConfigureDuration(name string, prop *time.Duration, check func(value time.Duration) error, defaultValue time.Duration)
	ConfigureStringList(name string, prop *[]string, check func(value []string) error, defaultValue []string)
	ConfigureBytesList(name string, prop *[][]byte, check func(value [][]byte) error, defaultValue [][]byte)
	ConfigureStringDict(name string, prop *map[string]string, check func(value map[string]string) error, defaultValue map[string]string)

	OnPrepare()
	// contains filtered or unexported methods
}

Component is the interface for all components.

type Component_

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

Component_ is the mixin for all components.

func (*Component_) ConfigureBool

func (c *Component_) ConfigureBool(name string, prop *bool, defaultValue bool)

func (*Component_) ConfigureBytes

func (c *Component_) ConfigureBytes(name string, prop *[]byte, check func(value []byte) error, defaultValue []byte)

func (*Component_) ConfigureBytesList

func (c *Component_) ConfigureBytesList(name string, prop *[][]byte, check func(value [][]byte) error, defaultValue [][]byte)

func (*Component_) ConfigureDuration

func (c *Component_) ConfigureDuration(name string, prop *time.Duration, check func(value time.Duration) error, defaultValue time.Duration)

func (*Component_) ConfigureInt

func (c *Component_) ConfigureInt(name string, prop *int, check func(value int) error, defaultValue int)

func (*Component_) ConfigureInt16

func (c *Component_) ConfigureInt16(name string, prop *int16, check func(value int16) error, defaultValue int16)

func (*Component_) ConfigureInt32

func (c *Component_) ConfigureInt32(name string, prop *int32, check func(value int32) error, defaultValue int32)

func (*Component_) ConfigureInt64

func (c *Component_) ConfigureInt64(name string, prop *int64, check func(value int64) error, defaultValue int64)

func (*Component_) ConfigureInt8

func (c *Component_) ConfigureInt8(name string, prop *int8, check func(value int8) error, defaultValue int8)

func (*Component_) ConfigureString

func (c *Component_) ConfigureString(name string, prop *string, check func(value string) error, defaultValue string)

func (*Component_) ConfigureStringDict

func (c *Component_) ConfigureStringDict(name string, prop *map[string]string, check func(value map[string]string) error, defaultValue map[string]string)

func (*Component_) ConfigureStringList

func (c *Component_) ConfigureStringList(name string, prop *[]string, check func(value []string) error, defaultValue []string)

func (*Component_) Find

func (c *Component_) Find(name string) (value Value, ok bool)

func (*Component_) IncSub

func (w *Component_) IncSub(n int)

func (*Component_) Loop

func (s *Component_) Loop(interval time.Duration, callback func(now time.Time))

func (*Component_) MakeComp

func (c *Component_) MakeComp(name string)

func (*Component_) Name

func (c *Component_) Name() string

func (*Component_) Prop

func (c *Component_) Prop(name string) (value Value, ok bool)

func (*Component_) SubDone

func (w *Component_) SubDone()

func (*Component_) WaitSubs

func (w *Component_) WaitSubs()

type Conn added in v0.1.6

type Conn interface {
	// contains filtered or unexported methods
}

Conn is the client conns.

type Conn_ added in v0.1.6

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

Conn_ is the mixin for client conns.

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

Cookie is a "set-cookie" sent to client.

func (*Cookie) Set

func (c *Cookie) Set(name string, value string) bool

func (*Cookie) SetDomain

func (c *Cookie) SetDomain(domain string) bool

func (*Cookie) SetExpires

func (c *Cookie) SetExpires(expires time.Time) bool

func (*Cookie) SetHttpOnly

func (c *Cookie) SetHttpOnly()

func (*Cookie) SetMaxAge

func (c *Cookie) SetMaxAge(maxAge int64)

func (*Cookie) SetPath

func (c *Cookie) SetPath(path string) bool

func (*Cookie) SetSameSite

func (c *Cookie) SetSameSite(mode string)

func (*Cookie) SetSameSiteLax

func (c *Cookie) SetSameSiteLax()

func (*Cookie) SetSameSiteNone

func (c *Cookie) SetSameSiteNone()

func (*Cookie) SetSameSiteStrict

func (c *Cookie) SetSameSiteStrict()

func (*Cookie) SetSecure

func (c *Cookie) SetSecure()

type Cronjob

type Cronjob interface {
	// Imports
	Component
	// Methods
	Schedule() // goroutine
}

Cronjob component

type Cronjob_

type Cronjob_ struct {
	// Mixins
	Component_
}

Cronjob_ is the mixin for all cronjobs.

func (*Cronjob_) IncSub

func (w *Cronjob_) IncSub(n int)

func (*Cronjob_) Loop

func (s *Cronjob_) Loop(interval time.Duration, callback func(now time.Time))

func (*Cronjob_) SubDone

func (w *Cronjob_) SubDone()

func (*Cronjob_) WaitSubs

func (w *Cronjob_) WaitSubs()

type GRPCBridge added in v0.1.2

type GRPCBridge interface {

	// Methods
	GRPCServer() any // may be a *grpc.Server
	// contains filtered or unexported methods
}

GRPCBridge is the interface for all gRPC server bridges. Users can implement their own gRPC server in exts, which may embeds *grpc.Server and must implements the GRPCBridge interface.

type Gate

type Gate interface {
	// Methods
	ID() int32
	IsShut() bool
	// contains filtered or unexported methods
}

Gate is the interface for all gates.

type Gate_

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

Gate_ is a mixin for mesher gates and server gates.

func (*Gate_) Address

func (g *Gate_) Address() string

func (*Gate_) DecConns

func (g *Gate_) DecConns() int32

func (*Gate_) ID

func (g *Gate_) ID() int32

func (*Gate_) IncSub

func (w *Gate_) IncSub(n int)

func (*Gate_) Init

func (g *Gate_) Init(stage *Stage, id int32, address string, maxConns int32)

func (*Gate_) IsShut

func (g *Gate_) IsShut() bool

func (*Gate_) MarkShut

func (g *Gate_) MarkShut()

func (*Gate_) ReachLimit

func (g *Gate_) ReachLimit() bool

func (*Gate_) Stage

func (g *Gate_) Stage() *Stage

func (*Gate_) SubDone

func (w *Gate_) SubDone()

func (*Gate_) WaitSubs

func (w *Gate_) WaitSubs()

type H1Conn

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

H1Conn is the client-side HTTP/1 connection.

func (*H1Conn) Close

func (c *H1Conn) Close() error

func (*H1Conn) EndStream

func (c *H1Conn) EndStream(stream *H1Stream)

func (*H1Conn) UseStream

func (c *H1Conn) UseStream() *H1Stream

type H1Request

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

H1Request is the client-side HTTP/1 request.

func (*H1Request) AddCookie

func (r *H1Request) AddCookie(name string, value string) bool

func (*H1Request) Response

func (r *H1Request) Response() clientResponse

func (*H1Request) SetIfModifiedSince

func (r *H1Request) SetIfModifiedSince(since int64) bool

func (*H1Request) SetIfUnmodifiedSince

func (r *H1Request) SetIfUnmodifiedSince(since int64) bool

func (*H1Request) SetMethodURI

func (r *H1Request) SetMethodURI(method string, uri string, hasContent bool) bool

type H1Response

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

H1Response is the client-side HTTP/1 response.

func (*H1Response) C

func (r *H1Response) C(name string) string

func (*H1Response) Content

func (r *H1Response) Content() string

func (*H1Response) Cookie

func (r *H1Response) Cookie(name string) (value string, ok bool)

func (*H1Response) HasContent

func (r *H1Response) HasContent() bool

func (*H1Response) HasCookie

func (r *H1Response) HasCookie(name string) bool

func (*H1Response) HasCookies

func (r *H1Response) HasCookies() bool

func (*H1Response) Status

func (r *H1Response) Status() int16

func (*H1Response) UnsafeContent

func (r *H1Response) UnsafeContent() []byte

func (*H1Response) UnsafeCookie

func (r *H1Response) UnsafeCookie(name []byte) (value []byte, ok bool)

type H1Socket

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

H1Socket is the client-side HTTP/1 websocket.

type H1Stream

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

H1Stream is the client-side HTTP/1 stream.

func (*H1Stream) ExecuteExchan added in v0.1.3

func (s *H1Stream) ExecuteExchan() error

func (*H1Stream) ExecuteSocket

func (s *H1Stream) ExecuteSocket() *H1Socket

func (*H1Stream) ExecuteTCPTun

func (s *H1Stream) ExecuteTCPTun()

func (*H1Stream) ExecuteUDPTun

func (s *H1Stream) ExecuteUDPTun()

func (*H1Stream) ForwardProxy

func (s *H1Stream) ForwardProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool) error

func (*H1Stream) Request

func (s *H1Stream) Request() *H1Request

func (*H1Stream) Response

func (s *H1Stream) Response() *H1Response

func (*H1Stream) ReverseProxy

func (s *H1Stream) ReverseProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool) error

type H2Conn

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

H2Conn

func (*H2Conn) Close

func (c *H2Conn) Close() error

func (*H2Conn) FetchStream

func (c *H2Conn) FetchStream() *H2Stream

func (*H2Conn) StoreStream

func (c *H2Conn) StoreStream(stream *H2Stream)

type H2Request

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

H2Request is the client-side HTTP/2 request.

func (*H2Request) AddCookie

func (r *H2Request) AddCookie(name string, value string) bool

func (*H2Request) Response

func (r *H2Request) Response() clientResponse

func (*H2Request) SetIfModifiedSince

func (r *H2Request) SetIfModifiedSince(since int64) bool

func (*H2Request) SetIfUnmodifiedSince

func (r *H2Request) SetIfUnmodifiedSince(since int64) bool

func (*H2Request) SetMethodURI

func (r *H2Request) SetMethodURI(method string, uri string, hasContent bool) bool

type H2Response

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

H2Response is the client-side HTTP/2 response.

func (*H2Response) C

func (r *H2Response) C(name string) string

func (*H2Response) Content

func (r *H2Response) Content() string

func (*H2Response) Cookie

func (r *H2Response) Cookie(name string) (value string, ok bool)

func (*H2Response) HasContent

func (r *H2Response) HasContent() bool

func (*H2Response) HasCookie

func (r *H2Response) HasCookie(name string) bool

func (*H2Response) HasCookies

func (r *H2Response) HasCookies() bool

func (*H2Response) Status

func (r *H2Response) Status() int16

func (*H2Response) UnsafeContent

func (r *H2Response) UnsafeContent() []byte

func (*H2Response) UnsafeCookie

func (r *H2Response) UnsafeCookie(name []byte) (value []byte, ok bool)

type H2Socket

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

H2Socket is the client-side HTTP/2 websocket.

type H2Stream

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

H2Stream

func (*H2Stream) ExecuteExchan added in v0.1.3

func (s *H2Stream) ExecuteExchan() error

func (*H2Stream) ExecuteSocket

func (s *H2Stream) ExecuteSocket() *H2Socket

func (*H2Stream) ExecuteTCPTun

func (s *H2Stream) ExecuteTCPTun()

func (*H2Stream) ExecuteUDPTun

func (s *H2Stream) ExecuteUDPTun()

func (*H2Stream) ForwardProxy

func (s *H2Stream) ForwardProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool)

func (*H2Stream) Request

func (s *H2Stream) Request() *H2Request

func (*H2Stream) Response

func (s *H2Stream) Response() *H2Response

func (*H2Stream) ReverseProxy

func (s *H2Stream) ReverseProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool)

type H3Conn

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

H3Conn

func (*H3Conn) Close

func (c *H3Conn) Close() error

func (*H3Conn) FetchStream

func (c *H3Conn) FetchStream() *H3Stream

func (*H3Conn) StoreStream

func (c *H3Conn) StoreStream(stream *H3Stream)

type H3Request

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

H3Request is the client-side HTTP/3 request.

func (*H3Request) AddCookie

func (r *H3Request) AddCookie(name string, value string) bool

func (*H3Request) Response

func (r *H3Request) Response() clientResponse

func (*H3Request) SetIfModifiedSince

func (r *H3Request) SetIfModifiedSince(since int64) bool

func (*H3Request) SetIfUnmodifiedSince

func (r *H3Request) SetIfUnmodifiedSince(since int64) bool

func (*H3Request) SetMethodURI

func (r *H3Request) SetMethodURI(method string, uri string, hasContent bool) bool

type H3Response

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

H3Response is the client-side HTTP/3 response.

func (*H3Response) C

func (r *H3Response) C(name string) string

func (*H3Response) Content

func (r *H3Response) Content() string

func (*H3Response) Cookie

func (r *H3Response) Cookie(name string) (value string, ok bool)

func (*H3Response) HasContent

func (r *H3Response) HasContent() bool

func (*H3Response) HasCookie

func (r *H3Response) HasCookie(name string) bool

func (*H3Response) HasCookies

func (r *H3Response) HasCookies() bool

func (*H3Response) Status

func (r *H3Response) Status() int16

func (*H3Response) UnsafeContent

func (r *H3Response) UnsafeContent() []byte

func (*H3Response) UnsafeCookie

func (r *H3Response) UnsafeCookie(name []byte) (value []byte, ok bool)

type H3Socket

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

H3Socket is the client-side HTTP/3 websocket.

type H3Stream

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

H3Stream

func (*H3Stream) ExecuteExchan added in v0.1.3

func (s *H3Stream) ExecuteExchan() error

func (*H3Stream) ExecuteSocket

func (s *H3Stream) ExecuteSocket() *H3Socket

func (*H3Stream) ExecuteTCPTun

func (s *H3Stream) ExecuteTCPTun()

func (*H3Stream) ExecuteUDPTun

func (s *H3Stream) ExecuteUDPTun()

func (*H3Stream) ForwardProxy

func (s *H3Stream) ForwardProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool)

func (*H3Stream) Request

func (s *H3Stream) Request() *H3Request

func (*H3Stream) Response

func (s *H3Stream) Response() *H3Response

func (*H3Stream) ReverseProxy

func (s *H3Stream) ReverseProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool)

type HCall added in v0.1.5

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

HCall is the client-side HRPC call.

type HExchan added in v0.1.3

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

HExchan is the client-side HWEB exchan.

func (*HExchan) ExecuteExchan added in v0.1.3

func (x *HExchan) ExecuteExchan() error

func (*HExchan) ForwardProxy added in v0.1.3

func (x *HExchan) ForwardProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool)

func (*HExchan) Request added in v0.1.3

func (x *HExchan) Request() *HRequest

func (*HExchan) Response added in v0.1.3

func (x *HExchan) Response() *HResponse

func (*HExchan) ReverseProxy added in v0.1.3

func (x *HExchan) ReverseProxy(req Request, resp Response, bufferClientContent bool, bufferServerContent bool)

type HRPCBackend added in v0.1.5

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

HRPCBackend

func (*HRPCBackend) OnConfigure added in v0.1.6

func (b *HRPCBackend) OnConfigure()

func (*HRPCBackend) OnPrepare added in v0.1.6

func (b *HRPCBackend) OnPrepare()

type HRPCOutgate added in v0.1.5

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

HRPCOutgate

func (*HRPCOutgate) OnConfigure added in v0.1.5

func (f *HRPCOutgate) OnConfigure()

func (*HRPCOutgate) OnPrepare added in v0.1.5

func (f *HRPCOutgate) OnPrepare()

type HReq added in v0.1.5

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

HReq is the client-side HRPC request.

type HRequest added in v0.1.3

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

HRequest is the client-side HWEB request.

func (*HRequest) AddCookie added in v0.1.3

func (r *HRequest) AddCookie(name string, value string) bool

func (*HRequest) Response added in v0.1.3

func (r *HRequest) Response() clientResponse

func (*HRequest) SetIfModifiedSince added in v0.1.3

func (r *HRequest) SetIfModifiedSince(since int64) bool

func (*HRequest) SetIfUnmodifiedSince added in v0.1.3

func (r *HRequest) SetIfUnmodifiedSince(since int64) bool

func (*HRequest) SetMethodURI added in v0.1.3

func (r *HRequest) SetMethodURI(method string, uri string, hasContent bool) bool

type HResp added in v0.1.5

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

HResp is the client-side HRPC response.

type HResponse added in v0.1.3

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

HResponse is the client-side HWEB response.

func (*HResponse) C added in v0.1.3

func (r *HResponse) C(name string) string

func (*HResponse) Content added in v0.1.3

func (r *HResponse) Content() string

func (*HResponse) Cookie added in v0.1.3

func (r *HResponse) Cookie(name string) (value string, ok bool)

func (*HResponse) HasContent added in v0.1.3

func (r *HResponse) HasContent() bool

func (*HResponse) HasCookie added in v0.1.3

func (r *HResponse) HasCookie(name string) bool

func (*HResponse) HasCookies added in v0.1.3

func (r *HResponse) HasCookies() bool

func (*HResponse) Status added in v0.1.3

func (r *HResponse) Status() int16

func (*HResponse) UnsafeContent added in v0.1.3

func (r *HResponse) UnsafeContent() []byte

func (*HResponse) UnsafeCookie added in v0.1.3

func (r *HResponse) UnsafeCookie(name []byte) (value []byte, ok bool)

type HTTP1Backend

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

HTTP1Backend

func (*HTTP1Backend) FetchConn

func (b *HTTP1Backend) FetchConn() (*H1Conn, error)

func (*HTTP1Backend) OnConfigure

func (b *HTTP1Backend) OnConfigure()

func (*HTTP1Backend) OnPrepare

func (b *HTTP1Backend) OnPrepare()

func (*HTTP1Backend) StoreConn

func (b *HTTP1Backend) StoreConn(conn *H1Conn)

type HTTP1Outgate

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

HTTP1Outgate

func (*HTTP1Outgate) Dial

func (f *HTTP1Outgate) Dial(address string, tlsMode bool) (*H1Conn, error)

func (*HTTP1Outgate) OnConfigure

func (f *HTTP1Outgate) OnConfigure()

func (*HTTP1Outgate) OnPrepare

func (f *HTTP1Outgate) OnPrepare()

type HTTP2Backend

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

HTTP2Backend

func (*HTTP2Backend) FetchConn

func (b *HTTP2Backend) FetchConn() (*H2Conn, error)

func (*HTTP2Backend) OnConfigure

func (b *HTTP2Backend) OnConfigure()

func (*HTTP2Backend) OnPrepare

func (b *HTTP2Backend) OnPrepare()

func (*HTTP2Backend) StoreConn

func (b *HTTP2Backend) StoreConn(conn *H2Conn)

type HTTP2Outgate

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

HTTP2Outgate

func (*HTTP2Outgate) FetchConn

func (f *HTTP2Outgate) FetchConn(address string, tlsMode bool) (*H2Conn, error)

func (*HTTP2Outgate) OnConfigure

func (f *HTTP2Outgate) OnConfigure()

func (*HTTP2Outgate) OnPrepare

func (f *HTTP2Outgate) OnPrepare()

func (*HTTP2Outgate) StoreConn

func (f *HTTP2Outgate) StoreConn(conn *H2Conn)

type HTTP3Backend

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

HTTP3Backend

func (*HTTP3Backend) FetchConn

func (b *HTTP3Backend) FetchConn() (*H3Conn, error)

func (*HTTP3Backend) OnConfigure

func (b *HTTP3Backend) OnConfigure()

func (*HTTP3Backend) OnPrepare

func (b *HTTP3Backend) OnPrepare()

func (*HTTP3Backend) StoreConn

func (b *HTTP3Backend) StoreConn(conn *H3Conn)

type HTTP3Outgate

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

HTTP3Outgate

func (*HTTP3Outgate) FetchConn

func (f *HTTP3Outgate) FetchConn(address string, tlsMode bool) (*H3Conn, error)

func (*HTTP3Outgate) OnConfigure

func (f *HTTP3Outgate) OnConfigure()

func (*HTTP3Outgate) OnPrepare

func (f *HTTP3Outgate) OnPrepare()

func (*HTTP3Outgate) StoreConn

func (f *HTTP3Outgate) StoreConn(conn *H3Conn)

type HWEBBackend added in v0.1.3

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

HWEBBackend

func (*HWEBBackend) OnConfigure added in v0.1.3

func (b *HWEBBackend) OnConfigure()

func (*HWEBBackend) OnPrepare added in v0.1.3

func (b *HWEBBackend) OnPrepare()

type HWEBOutgate added in v0.1.3

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

HWEBOutgate

func (*HWEBOutgate) OnConfigure added in v0.1.3

func (f *HWEBOutgate) OnConfigure()

func (*HWEBOutgate) OnPrepare added in v0.1.3

func (f *HWEBOutgate) OnPrepare()

type Handle

type Handle func(req Request, resp Response)

Handle is a function which can handle http request and gives http response.

type Handlet

type Handlet interface {
	// Imports
	Component
	// Methods
	IsProxy() bool // proxies and origins are different, we must differentiate them
	IsCache() bool // caches and proxies are different, we must differentiate them
	Handle(req Request, resp Response) (next bool)
}

Handlet component handles the incoming request and gives an outgoing response if the request is handled.

type Handlet_

type Handlet_ struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

Handlet_ is the mixin for all handlets.

func (*Handlet_) Dispatch

func (h *Handlet_) Dispatch(req Request, resp Response, notFound Handle)

func (*Handlet_) IncSub

func (w *Handlet_) IncSub(n int)

func (*Handlet_) IsCache

func (h *Handlet_) IsCache() bool

func (*Handlet_) IsProxy

func (h *Handlet_) IsProxy() bool

func (*Handlet_) Loop

func (s *Handlet_) Loop(interval time.Duration, callback func(now time.Time))

func (*Handlet_) SubDone

func (w *Handlet_) SubDone()

func (*Handlet_) UseRouter added in v0.0.10

func (h *Handlet_) UseRouter(handlet Handlet, router Router)

func (*Handlet_) WaitSubs

func (w *Handlet_) WaitSubs()

type Hobject

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

Hobject is an HTTP object in storer

type Node

type Node interface {
	Maintain() // goroutine
	// contains filtered or unexported methods
}

Node is a member of backend.

type Node_

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

Node_ is a mixin for backend nodes.

func (*Node_) IncSub

func (w *Node_) IncSub(n int)

func (*Node_) Loop

func (s *Node_) Loop(interval time.Duration, callback func(now time.Time))

func (*Node_) SubDone

func (w *Node_) SubDone()

func (*Node_) WaitSubs

func (w *Node_) WaitSubs()

type Piece

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

Piece is a member of content chain.

func GetPiece

func GetPiece() *Piece

func (*Piece) File

func (p *Piece) File() *os.File

func (*Piece) IsFile

func (p *Piece) IsFile() bool

func (*Piece) IsText

func (p *Piece) IsText() bool

func (*Piece) Next

func (p *Piece) Next() *Piece

func (*Piece) SetFile

func (p *Piece) SetFile(file *os.File, info os.FileInfo, shut bool)

func (*Piece) SetText

func (p *Piece) SetText(text []byte)

func (*Piece) Text

func (p *Piece) Text() []byte

type QConnection added in v0.1.6

type QConnection struct {
	// Mixins
	Conn_
	// contains filtered or unexported fields
}

QConnection is a client-side connection to quicNode.

func (*QConnection) FetchOneway added in v0.1.6

func (c *QConnection) FetchOneway() *QOneway

func (*QConnection) FetchStream added in v0.1.6

func (c *QConnection) FetchStream() *QStream

func (*QConnection) StoreOneway added in v0.1.6

func (c *QConnection) StoreOneway(oneway *QOneway)

func (*QConnection) StoreStream added in v0.1.6

func (c *QConnection) StoreStream(stream *QStream)

type QOneway

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

QOneway is a unidirectional stream of QConnection.

func (*QOneway) Read

func (s *QOneway) Read(p []byte) (n int, err error)

func (*QOneway) Write

func (s *QOneway) Write(p []byte) (n int, err error)

type QStream

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

QStream is a bidirectional stream of QConnection.

func (*QStream) Read

func (s *QStream) Read(p []byte) (n int, err error)

func (*QStream) Write

func (s *QStream) Write(p []byte) (n int, err error)

type QUDSBackend added in v0.1.5

type QUDSBackend struct {
	// Mixins
	Backend_[*qudsNode]
	// contains filtered or unexported fields
}

QUDSBackend component.

func (*QUDSBackend) AliveTimeout added in v0.1.5

func (c *QUDSBackend) AliveTimeout() time.Duration

func (*QUDSBackend) Dial added in v0.1.5

func (b *QUDSBackend) Dial() (*XConnection, error)

func (*QUDSBackend) FetchConnection added in v0.1.6

func (b *QUDSBackend) FetchConnection() (*XConnection, error)

func (*QUDSBackend) MaxStreamsPerConn added in v0.1.5

func (s *QUDSBackend) MaxStreamsPerConn() int32

func (*QUDSBackend) OnConfigure added in v0.1.5

func (b *QUDSBackend) OnConfigure()

func (*QUDSBackend) OnPrepare added in v0.1.5

func (b *QUDSBackend) OnPrepare()

func (*QUDSBackend) OnShutdown added in v0.1.5

func (c *QUDSBackend) OnShutdown()

func (*QUDSBackend) ReadTimeout added in v0.1.5

func (c *QUDSBackend) ReadTimeout() time.Duration

func (*QUDSBackend) Stage added in v0.1.5

func (c *QUDSBackend) Stage() *Stage

func (*QUDSBackend) StoreConnection added in v0.1.6

func (b *QUDSBackend) StoreConnection(xConnection *XConnection)

func (*QUDSBackend) TLSMode added in v0.1.5

func (c *QUDSBackend) TLSMode() bool

func (*QUDSBackend) WriteTimeout added in v0.1.5

func (c *QUDSBackend) WriteTimeout() time.Duration

type QUDSOutgate added in v0.1.5

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

QUDSOutgate component.

func (*QUDSOutgate) Dial added in v0.1.5

func (f *QUDSOutgate) Dial(address string) (*XConnection, error)

func (*QUDSOutgate) FetchConnection added in v0.1.6

func (f *QUDSOutgate) FetchConnection(address string)

func (*QUDSOutgate) MaxStreamsPerConn added in v0.1.5

func (s *QUDSOutgate) MaxStreamsPerConn() int32

func (*QUDSOutgate) OnConfigure added in v0.1.5

func (f *QUDSOutgate) OnConfigure()

func (*QUDSOutgate) OnPrepare added in v0.1.5

func (f *QUDSOutgate) OnPrepare()

func (*QUDSOutgate) StoreConnection added in v0.1.6

func (f *QUDSOutgate) StoreConnection(xConnection *XConnection)

type QUICBackend

type QUICBackend struct {
	// Mixins
	Backend_[*quicNode]
	// contains filtered or unexported fields
}

QUICBackend component.

func (*QUICBackend) AliveTimeout

func (c *QUICBackend) AliveTimeout() time.Duration

func (*QUICBackend) Dial

func (b *QUICBackend) Dial() (*QConnection, error)

func (*QUICBackend) FetchConnection added in v0.1.6

func (b *QUICBackend) FetchConnection() (*QConnection, error)

func (*QUICBackend) MaxStreamsPerConn

func (s *QUICBackend) MaxStreamsPerConn() int32

func (*QUICBackend) OnConfigure

func (b *QUICBackend) OnConfigure()

func (*QUICBackend) OnPrepare

func (b *QUICBackend) OnPrepare()

func (*QUICBackend) OnShutdown

func (c *QUICBackend) OnShutdown()

func (*QUICBackend) ReadTimeout

func (c *QUICBackend) ReadTimeout() time.Duration

func (*QUICBackend) Stage

func (c *QUICBackend) Stage() *Stage

func (*QUICBackend) StoreConnection added in v0.1.6

func (b *QUICBackend) StoreConnection(qConnection *QConnection)

func (*QUICBackend) TLSMode

func (c *QUICBackend) TLSMode() bool

func (*QUICBackend) WriteTimeout

func (c *QUICBackend) WriteTimeout() time.Duration

type QUICConnection added in v0.1.6

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

QUICConnection is the QUIC connection coming from QUICMesher.

func (*QUICConnection) Close added in v0.1.6

func (c *QUICConnection) Close() error

type QUICFilter added in v0.1.0

type QUICFilter interface {
	// Imports
	Component
	// Methods
	Deal(connection *QUICConnection, stream *QUICStream) (next bool)
}

QUICFilter

type QUICFilter_ added in v0.1.0

type QUICFilter_ struct {
	// Mixins
	Component_
}

QUICFilter_

func (*QUICFilter_) IncSub added in v0.1.7

func (w *QUICFilter_) IncSub(n int)

func (*QUICFilter_) Loop added in v0.1.7

func (s *QUICFilter_) Loop(interval time.Duration, callback func(now time.Time))

func (*QUICFilter_) SubDone added in v0.1.7

func (w *QUICFilter_) SubDone()

func (*QUICFilter_) WaitSubs added in v0.1.7

func (w *QUICFilter_) WaitSubs()

type QUICMesher

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

QUICMesher

func (*QUICMesher) Log added in v0.0.10

func (m *QUICMesher) Log(str string)

func (*QUICMesher) Logf added in v0.0.10

func (m *QUICMesher) Logf(format string, args ...any)

func (*QUICMesher) Logln added in v0.0.10

func (m *QUICMesher) Logln(str string)

func (*QUICMesher) OnConfigure

func (m *QUICMesher) OnConfigure()

func (*QUICMesher) OnPrepare

func (m *QUICMesher) OnPrepare()

func (*QUICMesher) OnShutdown

func (m *QUICMesher) OnShutdown()

type QUICOutgate

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

QUICOutgate component.

func (*QUICOutgate) Dial

func (f *QUICOutgate) Dial(address string) (*QConnection, error)

func (*QUICOutgate) FetchConnection added in v0.1.6

func (f *QUICOutgate) FetchConnection(address string)

func (*QUICOutgate) MaxStreamsPerConn

func (s *QUICOutgate) MaxStreamsPerConn() int32

func (*QUICOutgate) OnConfigure

func (f *QUICOutgate) OnConfigure()

func (*QUICOutgate) OnPrepare

func (f *QUICOutgate) OnPrepare()

func (*QUICOutgate) StoreConnection added in v0.1.6

func (f *QUICOutgate) StoreConnection(qConnection *QConnection)

type QUICStream

type QUICStream struct {
}

QUICStream

func (*QUICStream) Read

func (s *QUICStream) Read(p []byte) (n int, err error)

func (*QUICStream) Write

func (s *QUICStream) Write(p []byte) (n int, err error)

type Region

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

Region

func (*Region) Free

func (r *Region) Free()

func (*Region) Init

func (r *Region) Init()

func (*Region) Make

func (r *Region) Make(size int) []byte

type Req added in v0.1.5

type Req interface {
	Svc() *Svc
}

Req is the server-side RPC request.

type Request

type Request interface {
	PeerAddr() net.Addr
	App() *App

	VersionCode() uint8
	IsHTTP1_0() bool
	IsHTTP1_1() bool
	IsHTTP1() bool
	IsHTTP2() bool
	IsHTTP3() bool
	Version() string // HTTP/1.0, HTTP/1.1, HTTP/2, HTTP/3

	SchemeCode() uint8 // SchemeHTTP, SchemeHTTPS
	IsHTTP() bool
	IsHTTPS() bool
	Scheme() string // http, https

	MethodCode() uint32
	Method() string // GET, POST, ...
	IsGET() bool
	IsPOST() bool
	IsPUT() bool
	IsDELETE() bool

	IsAbsoluteForm() bool    // TODO: what about HTTP/2 and HTTP/3?
	IsAsteriskOptions() bool // OPTIONS *

	Authority() string // hostname[:port]
	Hostname() string  // hostname
	ColonPort() string // :port

	URI() string         // /encodedPath?queryString
	Path() string        // /path
	EncodedPath() string // /encodedPath
	QueryString() string // including '?' if query string exists, otherwise empty

	AddQuery(name string, value string) bool
	HasQueries() bool
	AllQueries() (queries [][2]string)
	Q(name string) string
	Qstr(name string, defaultValue string) string
	Qint(name string, defaultValue int) int
	Query(name string) (value string, ok bool)
	Queries(name string) (values []string, ok bool)
	HasQuery(name string) bool
	DelQuery(name string) (deleted bool)

	AddHeader(name string, value string) bool
	HasHeaders() bool
	AllHeaders() (headers [][2]string)
	H(name string) string
	Hstr(name string, defaultValue string) string
	Hint(name string, defaultValue int) int
	Header(name string) (value string, ok bool)
	Headers(name string) (values []string, ok bool)
	HasHeader(name string) bool
	DelHeader(name string) (deleted bool)

	UserAgent() string
	ContentType() string
	ContentSize() int64
	AcceptTrailers() bool

	TestConditions(modTime int64, etag []byte, asOrigin bool) (status int16, pass bool) // to test preconditons intentionally
	TestIfRanges(modTime int64, etag []byte, asOrigin bool) (pass bool)                 // to test preconditons intentionally

	AddCookie(name string, value string) bool
	HasCookies() bool
	AllCookies() (cookies [][2]string)
	C(name string) string
	Cstr(name string, defaultValue string) string
	Cint(name string, defaultValue int) int
	Cookie(name string) (value string, ok bool)
	Cookies(name string) (values []string, ok bool)
	HasCookie(name string) bool
	DelCookie(name string) (deleted bool)

	SetRecvTimeout(timeout time.Duration) // to defend against slowloris attack

	HasContent() bool // true if content exists
	IsUnsized() bool  // true if content exists and is not sized
	Content() string

	AddForm(name string, value string) bool
	HasForms() bool
	AllForms() (forms [][2]string)
	F(name string) string
	Fstr(name string, defaultValue string) string
	Fint(name string, defaultValue int) int
	Form(name string) (value string, ok bool)
	Forms(name string) (values []string, ok bool)
	HasForm(name string) bool

	HasUploads() bool
	AllUploads() (uploads []*Upload)
	U(name string) *Upload
	Upload(name string) (upload *Upload, ok bool)
	Uploads(name string) (uploads []*Upload, ok bool)
	HasUpload(name string) bool

	AddTrailer(name string, value string) bool
	HasTrailers() bool
	AllTrailers() (trailers [][2]string)
	T(name string) string
	Tstr(name string, defaultValue string) string
	Tint(name string, defaultValue int) int
	Trailer(name string) (value string, ok bool)
	Trailers(name string) (values []string, ok bool)
	HasTrailer(name string) bool
	DelTrailer(name string) (deleted bool)

	// Unsafe
	UnsafeMake(size int) []byte
	UnsafeVersion() []byte
	UnsafeScheme() []byte
	UnsafeMethod() []byte
	UnsafeAuthority() []byte // hostname[:port]
	UnsafeHostname() []byte  // hostname
	UnsafeColonPort() []byte // :port
	UnsafeURI() []byte
	UnsafePath() []byte
	UnsafeEncodedPath() []byte
	UnsafeQueryString() []byte // including '?' if query string exists, otherwise empty
	UnsafeQuery(name string) (value []byte, ok bool)
	UnsafeHeader(name string) (value []byte, ok bool)
	UnsafeCookie(name string) (value []byte, ok bool)
	UnsafeUserAgent() []byte
	UnsafeContentLength() []byte
	UnsafeContentType() []byte
	UnsafeContent() []byte
	UnsafeForm(name string) (value []byte, ok bool)
	UnsafeTrailer(name string) (value []byte, ok bool)
	// contains filtered or unexported methods
}

Request is the interface for *http[1-3]Request and *hwebRequest.

type Resp added in v0.1.5

type Resp interface {
	Req() Req
}

Resp is the server-side RPC response.

type Response

type Response interface {
	Request() Request

	SetStatus(status int16) error
	Status() int16

	MakeETagFrom(modTime int64, fileSize int64) ([]byte, bool) // with `""`
	SetExpires(expires int64) bool
	SetLastModified(lastModified int64) bool
	AddContentType(contentType string) bool
	AddHTTPSRedirection(authority string) bool
	AddHostnameRedirection(hostname string) bool
	AddDirectoryRedirection() bool

	SetCookie(cookie *Cookie) bool

	AddHeader(name string, value string) bool
	AddHeaderBytes(name []byte, value []byte) bool
	Header(name string) (value string, ok bool)
	HasHeader(name string) bool
	DelHeader(name string) bool
	DelHeaderBytes(name []byte) bool

	IsSent() bool
	SetSendTimeout(timeout time.Duration) // to defend against slowloris attack

	Send(content string) error
	SendBytes(content []byte) error
	SendJSON(content any) error
	SendFile(contentPath string) error
	SendBadRequest(content []byte) error                     // 400
	SendForbidden(content []byte) error                      // 403
	SendNotFound(content []byte) error                       // 404
	SendMethodNotAllowed(allow string, content []byte) error // 405
	SendInternalServerError(content []byte) error            // 500
	SendNotImplemented(content []byte) error                 // 501
	SendBadGateway(content []byte) error                     // 502
	SendGatewayTimeout(content []byte) error                 // 504

	Echo(chunk string) error
	EchoBytes(chunk []byte) error
	EchoFile(chunkPath string) error

	AddTrailer(name string, value string) bool
	AddTrailerBytes(name []byte, value []byte) bool
	// contains filtered or unexported methods
}

Response is the interface for *http[1-3]Response and *hwebResponse.

type Reviser

type Reviser interface {
	// Imports
	Component

	// Methods
	Rank() int8                            // 0-31 (with 0-15 as tunable, 16-31 as fixed)
	BeforeRecv(req Request, resp Response) // for sized content
	OnRecv(req Request, resp Response, chain Chain) (Chain, bool)
	BeforeDraw(req Request, resp Response) // for unsized content
	OnDraw(req Request, resp Response, chain Chain) (Chain, bool)
	FinishDraw(req Request, resp Response) // for unsized content
	BeforeSend(req Request, resp Response) // for sized content
	OnSend(req Request, resp Response, content *Chain)
	BeforeEcho(req Request, resp Response) // for unsized content
	OnEcho(req Request, resp Response, chunks *Chain)
	FinishEcho(req Request, resp Response) // for unsized content
	// contains filtered or unexported methods
}

Reviser component revises incoming requests and outgoing responses.

type Reviser_

type Reviser_ struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

Reviser_ is the mixin for all revisers.

func (*Reviser_) ID

func (i *Reviser_) ID() uint8

func (*Reviser_) IncSub

func (w *Reviser_) IncSub(n int)

func (*Reviser_) Loop

func (s *Reviser_) Loop(interval time.Duration, callback func(now time.Time))

func (*Reviser_) SubDone

func (w *Reviser_) SubDone()

func (*Reviser_) WaitSubs

func (w *Reviser_) WaitSubs()

type Router

type Router interface {
	FindHandle(req Request) Handle // firstly
	HandleName(req Request) string // secondly
}

Router performs request mapping in handlets.

type Rule

type Rule struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

Rule component

func (*Rule) IncSub

func (w *Rule) IncSub(n int)

func (*Rule) Loop

func (s *Rule) Loop(interval time.Duration, callback func(now time.Time))

func (*Rule) OnConfigure

func (r *Rule) OnConfigure()

func (*Rule) OnPrepare

func (r *Rule) OnPrepare()

func (*Rule) OnShutdown

func (r *Rule) OnShutdown()

func (*Rule) SubDone

func (w *Rule) SubDone()

func (*Rule) WaitSubs

func (w *Rule) WaitSubs()

type Runner added in v0.1.2

type Runner interface {
	// Imports
	Component
	// Methods
	Run() // goroutine
}

Runner component.

Runners are plugins or addons for Hemi. Users can create their own runners.

type Server

type Server interface {
	// Imports
	Component
	// Methods
	Serve() // goroutine
	Stage() *Stage
	TLSMode() bool
	ColonPort() string
	ColonPortBytes() []byte
	ReadTimeout() time.Duration
	WriteTimeout() time.Duration
}

Server component.

type Server_

type Server_ struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

Server_ is the mixin for all servers.

func (*Server_) Address

func (s *Server_) Address() string

func (*Server_) ColonPort

func (s *Server_) ColonPort() string

func (*Server_) ColonPortBytes

func (s *Server_) ColonPortBytes() []byte

func (*Server_) IncSub

func (w *Server_) IncSub(n int)

func (*Server_) Loop

func (s *Server_) Loop(interval time.Duration, callback func(now time.Time))

func (*Server_) MaxConnsPerGate

func (s *Server_) MaxConnsPerGate() int32

func (*Server_) NumGates

func (s *Server_) NumGates() int32

func (*Server_) OnConfigure

func (s *Server_) OnConfigure()

func (*Server_) OnCreate

func (s *Server_) OnCreate(name string, stage *Stage)

func (*Server_) OnPrepare

func (s *Server_) OnPrepare()

func (*Server_) ReadTimeout

func (s *Server_) ReadTimeout() time.Duration

func (*Server_) Stage

func (s *Server_) Stage() *Stage

func (*Server_) SubDone

func (w *Server_) SubDone()

func (*Server_) TLSMode

func (s *Server_) TLSMode() bool

func (*Server_) WaitSubs

func (w *Server_) WaitSubs()

func (*Server_) WriteTimeout

func (s *Server_) WriteTimeout() time.Duration

type Session

type Session struct {
	// TODO
	ID     [40]byte // session id
	Secret [40]byte // secret
	Role   int8     // 0: default, >0: app defined values
	Device int8     // terminal device type
	// contains filtered or unexported fields
}

Session is an HTTP session in stater

func (*Session) Del

func (s *Session) Del(name string)

func (*Session) Get

func (s *Session) Get(name string) string

func (*Session) Set

func (s *Session) Set(name string, value string)

type Socket

type Socket interface {
	Read(p []byte) (int, error)
	Write(p []byte) (int, error)
	Close() error
}

Socket is the interface for *http[1-3]Socket.

type Socklet

type Socklet interface {
	// Imports
	Component
	// Methods
	IsProxy() bool // proxys and origins are different, we must differentiate them
	Serve(req Request, sock Socket)
}

Socklet component handles the websocket.

type Socklet_

type Socklet_ struct {
	// Mixins
	Component_
}

Socklet_ is the mixin for all socklets.

func (*Socklet_) IncSub

func (w *Socklet_) IncSub(n int)

func (*Socklet_) IsProxy

func (s *Socklet_) IsProxy() bool

func (*Socklet_) Loop

func (s *Socklet_) Loop(interval time.Duration, callback func(now time.Time))

func (*Socklet_) SubDone

func (w *Socklet_) SubDone()

func (*Socklet_) WaitSubs

func (w *Socklet_) WaitSubs()

type Stage

type Stage struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

Stage represents a running stage in worker process.

A worker process may have many stages in its lifetime, especially when new configuration is applied, a new stage is created, or the old one is told to quit.

func FromFile added in v0.1.5

func FromFile(base string, file string) (*Stage, error)

func FromText added in v0.1.5

func FromText(text string) (*Stage, error)

func (*Stage) App

func (s *Stage) App(name string) *App

func (*Stage) Backend

func (s *Stage) Backend(name string) Backend

func (*Stage) Clock

func (s *Stage) Clock() *clockFixture

func (*Stage) Cronjob

func (s *Stage) Cronjob(name string) Cronjob

func (*Stage) Fcache

func (s *Stage) Fcache() *fcacheFixture

func (*Stage) HRPCOutgate added in v0.1.5

func (s *Stage) HRPCOutgate() *HRPCOutgate

func (*Stage) HTTP1Outgate

func (s *Stage) HTTP1Outgate() *HTTP1Outgate

func (*Stage) HTTP2Outgate

func (s *Stage) HTTP2Outgate() *HTTP2Outgate

func (*Stage) HTTP3Outgate

func (s *Stage) HTTP3Outgate() *HTTP3Outgate

func (*Stage) HWEBOutgate added in v0.1.3

func (s *Stage) HWEBOutgate() *HWEBOutgate

func (*Stage) ID

func (s *Stage) ID() int32

func (*Stage) IncSub

func (w *Stage) IncSub(n int)

func (*Stage) Loop

func (s *Stage) Loop(interval time.Duration, callback func(now time.Time))

func (*Stage) NumCPU

func (s *Stage) NumCPU() int32

func (*Stage) OnConfigure

func (s *Stage) OnConfigure()

func (*Stage) OnPrepare

func (s *Stage) OnPrepare()

func (*Stage) OnShutdown

func (s *Stage) OnShutdown()

func (*Stage) ProfBlock

func (s *Stage) ProfBlock()

func (*Stage) ProfCPU

func (s *Stage) ProfCPU()

func (*Stage) ProfGoroutine

func (s *Stage) ProfGoroutine()

func (*Stage) ProfHeap

func (s *Stage) ProfHeap()

func (*Stage) ProfThread

func (s *Stage) ProfThread()

func (*Stage) QUDSOutgate added in v0.1.5

func (s *Stage) QUDSOutgate() *QUDSOutgate

func (*Stage) QUICMesher

func (s *Stage) QUICMesher(name string) *QUICMesher

func (*Stage) QUICOutgate

func (s *Stage) QUICOutgate() *QUICOutgate

func (*Stage) Quit

func (s *Stage) Quit()

func (*Stage) Resolv added in v0.1.5

func (s *Stage) Resolv() *resolvFixture

func (*Stage) Runner added in v0.1.2

func (s *Stage) Runner(name string) Runner

func (*Stage) Server

func (s *Stage) Server(name string) Server

func (*Stage) Start

func (s *Stage) Start(id int32)

func (*Stage) Stater

func (s *Stage) Stater(name string) Stater

func (*Stage) Storer added in v0.1.6

func (s *Stage) Storer(name string) Storer

func (*Stage) SubDone

func (w *Stage) SubDone()

func (*Stage) Svc

func (s *Stage) Svc(name string) *Svc

func (*Stage) TCPSMesher

func (s *Stage) TCPSMesher(name string) *TCPSMesher

func (*Stage) TCPSOutgate

func (s *Stage) TCPSOutgate() *TCPSOutgate

func (*Stage) TUDSOutgate added in v0.1.5

func (s *Stage) TUDSOutgate() *TUDSOutgate

func (*Stage) UDPSMesher

func (s *Stage) UDPSMesher(name string) *UDPSMesher

func (*Stage) UDPSOutgate

func (s *Stage) UDPSOutgate() *UDPSOutgate

func (*Stage) UUDSOutgate added in v0.1.5

func (s *Stage) UUDSOutgate() *UUDSOutgate

func (*Stage) WaitSubs

func (w *Stage) WaitSubs()

type Stater

type Stater interface {
	// Imports
	Component
	// Methods
	Maintain() // goroutine
	Set(sid []byte, session *Session)
	Get(sid []byte) (session *Session)
	Del(sid []byte) bool
}

Stater component is the interface to storages of HTTP states. See RFC 6265.

type Stater_

type Stater_ struct {
	// Mixins
	Component_
}

Stater_

func (*Stater_) IncSub

func (w *Stater_) IncSub(n int)

func (*Stater_) Loop

func (s *Stater_) Loop(interval time.Duration, callback func(now time.Time))

func (*Stater_) SubDone

func (w *Stater_) SubDone()

func (*Stater_) WaitSubs

func (w *Stater_) WaitSubs()

type Storer added in v0.1.6

type Storer interface {
	// Imports
	Component
	// Methods
	Maintain() // goroutine
	Set(key []byte, hobject *Hobject)
	Get(key []byte) (hobject *Hobject)
	Del(key []byte) bool
}

Storer component is the interface to storages of HTTP caching. See RFC 9111.

type Storer_ added in v0.1.6

type Storer_ struct {
	// Mixins
	Component_
}

Storer_

func (*Storer_) IncSub added in v0.1.6

func (w *Storer_) IncSub(n int)

func (*Storer_) Loop added in v0.1.6

func (s *Storer_) Loop(interval time.Duration, callback func(now time.Time))

func (*Storer_) SubDone added in v0.1.6

func (w *Storer_) SubDone()

func (*Storer_) WaitSubs added in v0.1.6

func (w *Storer_) WaitSubs()

type Svc

type Svc struct {
	// Mixins
	Component_
	// contains filtered or unexported fields
}

Svc is the RPC service.

func (*Svc) BindServer added in v0.1.5

func (s *Svc) BindServer(server rpcServer)

func (*Svc) IncSub

func (w *Svc) IncSub(n int)

func (*Svc) Log added in v0.1.2

func (s *Svc) Log(str string)

func (*Svc) Logf added in v0.1.2

func (s *Svc) Logf(format string, args ...any)

func (*Svc) Logln added in v0.1.2

func (s *Svc) Logln(str string)

func (*Svc) Loop

func (s *Svc) Loop(interval time.Duration, callback func(now time.Time))

func (*Svc) OnConfigure

func (s *Svc) OnConfigure()

func (*Svc) OnPrepare

func (s *Svc) OnPrepare()

func (*Svc) OnShutdown

func (s *Svc) OnShutdown()

func (*Svc) Servers added in v0.1.2

func (s *Svc) Servers() []rpcServer

func (*Svc) SubDone

func (w *Svc) SubDone()

func (*Svc) WaitSubs

func (w *Svc) WaitSubs()

type TCPSBackend

type TCPSBackend struct {
	// Mixins
	Backend_[*tcpsNode]
	// contains filtered or unexported fields
}

TCPSBackend component.

func (*TCPSBackend) AliveTimeout

func (c *TCPSBackend) AliveTimeout() time.Duration

func (*TCPSBackend) Dial

func (b *TCPSBackend) Dial() (wireConn, error)

func (*TCPSBackend) DialTCPS added in v0.1.6

func (b *TCPSBackend) DialTCPS() (*TConn, error)

func (*TCPSBackend) FetchConn

func (b *TCPSBackend) FetchConn() (wireConn, error)

func (*TCPSBackend) FetchTConn added in v0.1.6

func (b *TCPSBackend) FetchTConn() (*TConn, error)

func (*TCPSBackend) MaxStreamsPerConn

func (s *TCPSBackend) MaxStreamsPerConn() int32

func (*TCPSBackend) OnConfigure

func (b *TCPSBackend) OnConfigure()

func (*TCPSBackend) OnPrepare

func (b *TCPSBackend) OnPrepare()

func (*TCPSBackend) OnShutdown

func (c *TCPSBackend) OnShutdown()

func (*TCPSBackend) ReadTimeout

func (c *TCPSBackend) ReadTimeout() time.Duration

func (*TCPSBackend) Stage

func (c *TCPSBackend) Stage() *Stage

func (*TCPSBackend) StoreConn

func (b *TCPSBackend) StoreConn(conn wireConn)

func (*TCPSBackend) StoreTConn added in v0.1.6

func (b *TCPSBackend) StoreTConn(tConn *TConn)

func (*TCPSBackend) TLSMode

func (c *TCPSBackend) TLSMode() bool

func (*TCPSBackend) WriteTimeout

func (c *TCPSBackend) WriteTimeout() time.Duration

type TCPSConn

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

TCPSConn is the TCP/TLS connection coming from TCPSMesher.

func (*TCPSConn) Recv

func (c *TCPSConn) Recv() (p []byte, err error)

func (*TCPSConn) Send

func (c *TCPSConn) Send(p []byte) (err error)

type TCPSFilter added in v0.1.0

type TCPSFilter interface {
	// Imports
	Component
	// Methods
	Deal(conn *TCPSConn) (next bool)
}

TCPSFilter

type TCPSFilter_ added in v0.1.0

type TCPSFilter_ struct {
	// Mixins
	Component_
}

TCPSFilter_

func (*TCPSFilter_) IncSub added in v0.1.7

func (w *TCPSFilter_) IncSub(n int)

func (*TCPSFilter_) Loop added in v0.1.7

func (s *TCPSFilter_) Loop(interval time.Duration, callback func(now time.Time))

func (*TCPSFilter_) SubDone added in v0.1.7

func (w *TCPSFilter_) SubDone()

func (*TCPSFilter_) WaitSubs added in v0.1.7

func (w *TCPSFilter_) WaitSubs()

type TCPSMesher

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

TCPSMesher

func (*TCPSMesher) Log added in v0.0.10

func (m *TCPSMesher) Log(str string)

func (*TCPSMesher) Logf added in v0.0.10

func (m *TCPSMesher) Logf(format string, args ...any)

func (*TCPSMesher) Logln added in v0.0.10

func (m *TCPSMesher) Logln(str string)

func (*TCPSMesher) OnConfigure

func (m *TCPSMesher) OnConfigure()

func (*TCPSMesher) OnPrepare

func (m *TCPSMesher) OnPrepare()

func (*TCPSMesher) OnShutdown

func (m *TCPSMesher) OnShutdown()

type TCPSOutgate

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

TCPSOutgate component.

func (*TCPSOutgate) Dial

func (f *TCPSOutgate) Dial(address string, tlsMode bool) (*TConn, error)

func (*TCPSOutgate) MaxStreamsPerConn

func (s *TCPSOutgate) MaxStreamsPerConn() int32

func (*TCPSOutgate) OnConfigure

func (f *TCPSOutgate) OnConfigure()

func (*TCPSOutgate) OnPrepare

func (f *TCPSOutgate) OnPrepare()

type TConn

type TConn struct {
	// Mixins
	Conn_
	// contains filtered or unexported fields
}

TConn is a client-side connection to tcpsNode.

func (*TConn) Close

func (c *TConn) Close() error

func (*TConn) CloseWrite

func (c *TConn) CloseWrite() error

func (*TConn) IsBroken

func (c *TConn) IsBroken() bool

func (*TConn) MakeTempName

func (c *TConn) MakeTempName(p []byte, unixTime int64) (from int, edge int)

func (*TConn) MarkBroken

func (c *TConn) MarkBroken()

func (*TConn) Read

func (c *TConn) Read(p []byte) (n int, err error)

func (*TConn) ReadAtLeast

func (c *TConn) ReadAtLeast(p []byte, min int) (n int, err error)

func (*TConn) ReadFull

func (c *TConn) ReadFull(p []byte) (n int, err error)

func (*TConn) SetReadDeadline

func (c *TConn) SetReadDeadline(deadline time.Time) error

func (*TConn) SetWriteDeadline

func (c *TConn) SetWriteDeadline(deadline time.Time) error

func (*TConn) TCPConn

func (c *TConn) TCPConn() *net.TCPConn

func (*TConn) TLSConn

func (c *TConn) TLSConn() *tls.Conn

func (*TConn) Write

func (c *TConn) Write(p []byte) (n int, err error)

func (*TConn) Writev

func (c *TConn) Writev(vector *net.Buffers) (int64, error)

type TUDSBackend added in v0.1.5

type TUDSBackend struct {
	// Mixins
	Backend_[*tudsNode]
	// contains filtered or unexported fields
}

TUDSBackend component.

func (*TUDSBackend) AliveTimeout added in v0.1.5

func (c *TUDSBackend) AliveTimeout() time.Duration

func (*TUDSBackend) Dial added in v0.1.5

func (b *TUDSBackend) Dial() (wireConn, error)

func (*TUDSBackend) DialTUDS added in v0.1.6

func (b *TUDSBackend) DialTUDS() (*XConn, error)

func (*TUDSBackend) FetchConn added in v0.1.5

func (b *TUDSBackend) FetchConn() (wireConn, error)

func (*TUDSBackend) FetchXConn added in v0.1.6

func (b *TUDSBackend) FetchXConn() (*XConn, error)

func (*TUDSBackend) MaxStreamsPerConn added in v0.1.5

func (s *TUDSBackend) MaxStreamsPerConn() int32

func (*TUDSBackend) OnConfigure added in v0.1.5

func (b *TUDSBackend) OnConfigure()

func (*TUDSBackend) OnPrepare added in v0.1.5

func (b *TUDSBackend) OnPrepare()

func (*TUDSBackend) OnShutdown added in v0.1.5

func (c *TUDSBackend) OnShutdown()

func (*TUDSBackend) ReadTimeout added in v0.1.5

func (c *TUDSBackend) ReadTimeout() time.Duration

func (*TUDSBackend) Stage added in v0.1.5

func (c *TUDSBackend) Stage() *Stage

func (*TUDSBackend) StoreConn added in v0.1.5

func (b *TUDSBackend) StoreConn(conn wireConn)

func (*TUDSBackend) StoreXConn added in v0.1.6

func (b *TUDSBackend) StoreXConn(xConn *XConn)

func (*TUDSBackend) TLSMode added in v0.1.5

func (c *TUDSBackend) TLSMode() bool

func (*TUDSBackend) WriteTimeout added in v0.1.5

func (c *TUDSBackend) WriteTimeout() time.Duration

type TUDSOutgate added in v0.1.5

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

TUDSOutgate component.

func (*TUDSOutgate) Dial added in v0.1.5

func (f *TUDSOutgate) Dial(address string) (*XConn, error)

func (*TUDSOutgate) MaxStreamsPerConn added in v0.1.5

func (s *TUDSOutgate) MaxStreamsPerConn() int32

func (*TUDSOutgate) OnConfigure added in v0.1.5

func (f *TUDSOutgate) OnConfigure()

func (*TUDSOutgate) OnPrepare added in v0.1.5

func (f *TUDSOutgate) OnPrepare()

type ThriftBridge added in v0.1.2

type ThriftBridge interface {

	// Methods
	ThriftServer() any // may be a thrift.TServer?
	// contains filtered or unexported methods
}

ThriftBridge is the interface for all Thrift server bridges. Users can implement their own Thrift server in exts, which may embeds thrift.TServer and must implements the ThriftBridge interface.

type UDPSBackend

type UDPSBackend struct {
	// Mixins
	Backend_[*udpsNode]
	// contains filtered or unexported fields
}

UDPSBackend component.

func (*UDPSBackend) AliveTimeout

func (c *UDPSBackend) AliveTimeout() time.Duration
func (b *UDPSBackend) FetchLink() (*ULink, error)
func (b *UDPSBackend) Link() (*ULink, error)

func (*UDPSBackend) OnConfigure

func (b *UDPSBackend) OnConfigure()

func (*UDPSBackend) OnPrepare

func (b *UDPSBackend) OnPrepare()

func (*UDPSBackend) OnShutdown

func (c *UDPSBackend) OnShutdown()

func (*UDPSBackend) ReadTimeout

func (c *UDPSBackend) ReadTimeout() time.Duration

func (*UDPSBackend) Stage

func (c *UDPSBackend) Stage() *Stage
func (b *UDPSBackend) StoreLink(uLink *ULink)

func (*UDPSBackend) TLSMode

func (c *UDPSBackend) TLSMode() bool

func (*UDPSBackend) WriteTimeout

func (c *UDPSBackend) WriteTimeout() time.Duration

type UDPSFilter added in v0.1.0

type UDPSFilter interface {
	// Imports
	Component
	// Methods
	Deal(link *UDPSLink) (next bool)
}

UDPSFilter

type UDPSFilter_ added in v0.1.0

type UDPSFilter_ struct {
	// Mixins
	Component_
}

UDPSFilter_

func (*UDPSFilter_) IncSub added in v0.1.7

func (w *UDPSFilter_) IncSub(n int)

func (*UDPSFilter_) Loop added in v0.1.7

func (s *UDPSFilter_) Loop(interval time.Duration, callback func(now time.Time))

func (*UDPSFilter_) SubDone added in v0.1.7

func (w *UDPSFilter_) SubDone()

func (*UDPSFilter_) WaitSubs added in v0.1.7

func (w *UDPSFilter_) WaitSubs()
type UDPSLink struct {
	// contains filtered or unexported fields
}

UDPSLink needs redesign, maybe datagram?

func (*UDPSLink) Close added in v0.1.3

func (l *UDPSLink) Close() error

type UDPSMesher

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

UDPSMesher

func (*UDPSMesher) Log added in v0.0.10

func (m *UDPSMesher) Log(str string)

func (*UDPSMesher) Logf added in v0.0.10

func (m *UDPSMesher) Logf(format string, args ...any)

func (*UDPSMesher) Logln added in v0.0.10

func (m *UDPSMesher) Logln(str string)

func (*UDPSMesher) OnConfigure

func (m *UDPSMesher) OnConfigure()

func (*UDPSMesher) OnPrepare

func (m *UDPSMesher) OnPrepare()

func (*UDPSMesher) OnShutdown

func (m *UDPSMesher) OnShutdown()

type UDPSOutgate

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

UDPSOutgate component.

func (*UDPSOutgate) Dial

func (f *UDPSOutgate) Dial(address string, tlsMode bool) (*ULink, error)
func (f *UDPSOutgate) FetchLink(address string, tlsMode bool) (*ULink, error)

func (*UDPSOutgate) OnConfigure

func (f *UDPSOutgate) OnConfigure()

func (*UDPSOutgate) OnPrepare

func (f *UDPSOutgate) OnPrepare()
func (f *UDPSOutgate) StoreLink(uLink *ULink)
type ULink struct {
	// Mixins
	Conn_
	// contains filtered or unexported fields
}

ULink needs redesign, maybe datagram?

func (*ULink) Close added in v0.1.3

func (l *ULink) Close() error

func (*ULink) Read added in v0.1.3

func (l *ULink) Read(p []byte) (n int, err error)

func (*ULink) SetReadDeadline added in v0.1.3

func (l *ULink) SetReadDeadline(deadline time.Time) error

func (*ULink) SetWriteDeadline added in v0.1.3

func (l *ULink) SetWriteDeadline(deadline time.Time) error

func (*ULink) Write added in v0.1.3

func (l *ULink) Write(p []byte) (n int, err error)

type UUDSBackend added in v0.1.5

type UUDSBackend struct {
	// Mixins
	Backend_[*uudsNode]
	// contains filtered or unexported fields
}

UUDSBackend component.

func (*UUDSBackend) AliveTimeout added in v0.1.5

func (c *UUDSBackend) AliveTimeout() time.Duration
func (b *UUDSBackend) FetchLink() (*XLink, error)
func (b *UUDSBackend) Link() (*XLink, error)

func (*UUDSBackend) OnConfigure added in v0.1.5

func (b *UUDSBackend) OnConfigure()

func (*UUDSBackend) OnPrepare added in v0.1.5

func (b *UUDSBackend) OnPrepare()

func (*UUDSBackend) OnShutdown added in v0.1.5

func (c *UUDSBackend) OnShutdown()

func (*UUDSBackend) ReadTimeout added in v0.1.5

func (c *UUDSBackend) ReadTimeout() time.Duration

func (*UUDSBackend) Stage added in v0.1.5

func (c *UUDSBackend) Stage() *Stage
func (b *UUDSBackend) StoreLink(xLink *XLink)

func (*UUDSBackend) TLSMode added in v0.1.5

func (c *UUDSBackend) TLSMode() bool

func (*UUDSBackend) WriteTimeout added in v0.1.5

func (c *UUDSBackend) WriteTimeout() time.Duration

type UUDSOutgate added in v0.1.5

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

UUDSOutgate component.

func (*UUDSOutgate) Dial added in v0.1.5

func (f *UUDSOutgate) Dial(address string, tlsMode bool) (*XLink, error)
func (f *UUDSOutgate) FetchLink(address string, tlsMode bool) (*XLink, error)

func (*UUDSOutgate) OnConfigure added in v0.1.5

func (f *UUDSOutgate) OnConfigure()

func (*UUDSOutgate) OnPrepare added in v0.1.5

func (f *UUDSOutgate) OnPrepare()
func (f *UUDSOutgate) StoreLink(xLink *XLink)

type Upload

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

Upload is a file uploaded by client.

func (*Upload) Base

func (u *Upload) Base() string

func (*Upload) Error

func (u *Upload) Error() error

func (*Upload) IsOK

func (u *Upload) IsOK() bool

func (*Upload) MoveTo

func (u *Upload) MoveTo(path string) error

func (*Upload) Name

func (u *Upload) Name() string

func (*Upload) Path

func (u *Upload) Path() string

func (*Upload) Size

func (u *Upload) Size() int64

func (*Upload) Type

func (u *Upload) Type() string

type Value

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

Value is a value in config file.

func (*Value) Bool

func (v *Value) Bool() (b bool, ok bool)

func (*Value) Bytes

func (v *Value) Bytes() (p []byte, ok bool)

func (*Value) BytesList

func (v *Value) BytesList() (list [][]byte, ok bool)

func (*Value) Dict

func (v *Value) Dict() (dict map[string]Value, ok bool)

func (*Value) Duration

func (v *Value) Duration() (d time.Duration, ok bool)

func (*Value) Int

func (v *Value) Int() (i int, ok bool)

func (*Value) Int16

func (v *Value) Int16() (i16 int16, ok bool)

func (*Value) Int32

func (v *Value) Int32() (i32 int32, ok bool)

func (*Value) Int64

func (v *Value) Int64() (i64 int64, ok bool)

func (*Value) Int8

func (v *Value) Int8() (i8 int8, ok bool)

func (*Value) IsBool

func (v *Value) IsBool() bool

func (*Value) IsDict

func (v *Value) IsDict() bool

func (*Value) IsDuration

func (v *Value) IsDuration() bool

func (*Value) IsInteger

func (v *Value) IsInteger() bool

func (*Value) IsList

func (v *Value) IsList() bool

func (*Value) IsString

func (v *Value) IsString() bool

func (*Value) List

func (v *Value) List() (list []Value, ok bool)

func (*Value) ListN

func (v *Value) ListN(n int) (list []Value, ok bool)

func (*Value) String

func (v *Value) String() (s string, ok bool)

func (*Value) StringDict

func (v *Value) StringDict() (dict map[string]string, ok bool)

func (*Value) StringList

func (v *Value) StringList() (list []string, ok bool)

func (*Value) StringListN

func (v *Value) StringListN(n int) (list []string, ok bool)

func (*Value) Uint32

func (v *Value) Uint32() (u32 uint32, ok bool)

type XConn added in v0.1.0

type XConn struct {
	// Mixins
	Conn_
	// contains filtered or unexported fields
}

XConn is a client-side connection to tudsNode.

func (*XConn) Close added in v0.1.0

func (c *XConn) Close() error

func (*XConn) CloseWrite added in v0.1.0

func (c *XConn) CloseWrite() error

func (*XConn) IsBroken added in v0.1.5

func (c *XConn) IsBroken() bool

func (*XConn) MakeTempName added in v0.1.5

func (c *XConn) MakeTempName(p []byte, unixTime int64) (from int, edge int)

func (*XConn) MarkBroken added in v0.1.5

func (c *XConn) MarkBroken()

func (*XConn) Read added in v0.1.0

func (c *XConn) Read(p []byte) (n int, err error)

func (*XConn) ReadAtLeast added in v0.1.5

func (c *XConn) ReadAtLeast(p []byte, min int) (n int, err error)

func (*XConn) ReadFull added in v0.1.0

func (c *XConn) ReadFull(p []byte) (n int, err error)

func (*XConn) SetReadDeadline added in v0.1.0

func (c *XConn) SetReadDeadline(deadline time.Time) error

func (*XConn) SetWriteDeadline added in v0.1.0

func (c *XConn) SetWriteDeadline(deadline time.Time) error

func (*XConn) UnixConn added in v0.1.5

func (c *XConn) UnixConn() *net.UnixConn

func (*XConn) Write added in v0.1.0

func (c *XConn) Write(p []byte) (n int, err error)

func (*XConn) Writev added in v0.1.0

func (c *XConn) Writev(vector *net.Buffers) (int64, error)

type XConnection added in v0.1.6

type XConnection struct {
	// Mixins
	Conn_
	// contains filtered or unexported fields
}

XConnection is a client-side connection to qudsNode.

func (*XConnection) FetchOneway added in v0.1.6

func (c *XConnection) FetchOneway() *XOneway

func (*XConnection) FetchStream added in v0.1.6

func (c *XConnection) FetchStream() *XStream

func (*XConnection) StoreOneway added in v0.1.6

func (c *XConnection) StoreOneway(oneway *XOneway)

func (*XConnection) StoreStream added in v0.1.6

func (c *XConnection) StoreStream(stream *XStream)
type XLink struct {
	// Mixins
	Conn_
	// contains filtered or unexported fields
}

XLink needs redesign, maybe datagram?

func (*XLink) Close added in v0.1.5

func (l *XLink) Close() error

func (*XLink) Read added in v0.1.5

func (l *XLink) Read(p []byte) (n int, err error)

func (*XLink) SetReadDeadline added in v0.1.5

func (l *XLink) SetReadDeadline(deadline time.Time) error

func (*XLink) SetWriteDeadline added in v0.1.5

func (l *XLink) SetWriteDeadline(deadline time.Time) error

func (*XLink) Write added in v0.1.5

func (l *XLink) Write(p []byte) (n int, err error)

type XOneway added in v0.1.6

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

XOneway is a unidirectional stream of XConnection.

func (*XOneway) Read added in v0.1.6

func (s *XOneway) Read(p []byte) (n int, err error)

func (*XOneway) Write added in v0.1.6

func (s *XOneway) Write(p []byte) (n int, err error)

type XStream added in v0.1.6

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

XStream is a bidirectional stream of XConnection.

func (*XStream) Read added in v0.1.6

func (s *XStream) Read(p []byte) (n int, err error)

func (*XStream) Write added in v0.1.6

func (s *XStream) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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