tbmp

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 12 Imported by: 0

README

tbmp

TBMP (Tunnel Boring Machine Protocol, aka 同步门协议)

Documentation

Index

Constants

View Source
const (
	NameProtocol = "TBMP/1.0"
	NameClient   = "TBMP.client/1.0"
	NameServer   = "TBMP.server/1.0"
)

定义协议的名称(和版本)

View Source
const (
	HeaderContentType = "Content-Type"
	HeaderProtocol    = "Protocol"

	HeaderMethod = "Method"
	HeaderURL    = "URL"
	HeaderClient = "Client"

	HeaderServer = "Server"
	HeaderStatus = "Status"
)

定义一些常用的头部字段名称

Variables

This section is empty.

Functions

func NewClientModule added in v0.0.2

func NewClientModule() *application.ModuleBuilder

NewClientModule make module (client)

func NewMainModule

func NewMainModule() *application.ModuleBuilder

NewMainModule make module (main)

func NewServerModule added in v0.0.2

func NewServerModule() *application.ModuleBuilder

NewServerModule make module (server)

func NewTestModule added in v0.0.2

func NewTestModule() *application.ModuleBuilder

NewTestModule make module (test)

Types

type Client

type Client interface {
	Connector

	Name() string

	SetName(name string)
}

Client ...

func NewClient

func NewClient() Client

NewClient ...

type ClientSideConnection

type ClientSideConnection interface {
	Connection

	Downstream() (RxStream, error)

	Upstream(input ...*Headers) (TxStream, error)
}

ClientSideConnection ...

type Configuration

type Configuration struct {
	Method   string
	Protocol string
	Host     string
	Port     int
	Username string
	Password string
	Secure   bool
	Headers  Headers
}

Configuration ...

type Connection

type Connection interface {
	io.Closer
}

Connection 表示一个 TBMP 连接

type Connector

type Connector interface {
	Connect(url string, options ...Option) (ClientSideConnection, error)
}

Connector 表示一个 TBMP 连接器

type Downstream added in v0.0.2

type Downstream struct {
	Protocol    string
	ContentType string
	Headers     Headers

	Status int
}

Downstream ...

type HandlerSelector added in v0.0.2

type HandlerSelector string

HandlerSelector 是一个字符串,用于选择 handler

type HandlerSelectorBuilder added in v0.0.2

type HandlerSelectorBuilder struct {
	Method string
	Path   string
}

HandlerSelectorBuilder ...

func (*HandlerSelectorBuilder) Create added in v0.0.2

func (inst *HandlerSelectorBuilder) Create() HandlerSelector

Create ...

type Headers

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

Headers ...

func (*Headers) ForEach

func (inst *Headers) ForEach(fn func(name, value string))

ForEach ...

func (*Headers) Get

func (inst *Headers) Get(name string) string

Get ...

func (*Headers) Set

func (inst *Headers) Set(name, value string)

Set ...

type Listener

type Listener interface {
	io.Closer

	Accept() (ServerSideConnection, error)
}

Listener ...

type Location added in v0.0.2

type Location struct {
	Scheme   string
	User     string
	Host     string
	Port     int
	Path     string
	Query    map[string]string
	Fragment string
}

Location ...

func NewLocation added in v0.0.2

func NewLocation(u *url.URL) *Location

NewLocation ...

type Option added in v0.0.2

type Option func(cfg *Configuration)

Option 定义选项函数的签名

func OptionHeader added in v0.0.2

func OptionHeader(name, value string) Option

OptionHeader 用于设置 header

func OptionMethod added in v0.0.2

func OptionMethod(method string) Option

OptionMethod 用于设置 method

type RxStream

type RxStream interface {
	io.Reader

	Headers() *Headers
}

RxStream ...

type Server

type Server interface {
	Name() string

	SetName(name string)

	Listen(cfg *Configuration) (Listener, error)
}

Server ...

func NewServer

func NewServer() Server

NewServer ...

type ServerSideConnection

type ServerSideConnection interface {
	Connection

	Upstream() (RxStream, error)

	Downstream(input ...*Headers) (TxStream, error)
}

ServerSideConnection ...

type TxStream

type TxStream interface {
	io.Writer

	Headers() *Headers
}

TxStream ...

type Upstream added in v0.0.2

type Upstream struct {
	Protocol    string
	ContentType string
	Headers     Headers

	Method   string
	URL      string
	Location Location
}

Upstream ...

Jump to

Keyboard shortcuts

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