frontproxy

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenHeaderName  = "X-Auth-Token"
	UserIdHeaderName = "X-Auth-Id"
)
View Source
const (
	TypeOpen uint8 = 1 + iota
	TypeOpenSuccess
	TypePacket
	TypeMessage
	TypePing
	TypePong
)
View Source
const (
	SocketErrorCodeInvalidProtocol = 1 + iota
	SocketErrorCodeRequestAuth
	SocketErrorCodeNotAccessible
	SocketErrorCodeCloseConnection
	SocketErrorCodeServerUnavailable
)
View Source
const (
	SocketProxyNextProto = "lpsc1"
)

Variables

View Source
var (
	SocketErrorInvalidProtocol   = NewMessageError(SocketErrorCodeInvalidProtocol, "invalid protocol")
	SocketErrorRequestAuth       = NewMessageError(SocketErrorCodeRequestAuth, "need authenticate")
	SocketErrorNotAccessible     = NewMessageError(SocketErrorCodeNotAccessible, "You don't have privilege")
	SocketErrorCloseConnection   = NewMessageError(SocketErrorCodeCloseConnection, "Sorry, the server has close connection")
	SocketErrorServerUnavailable = NewMessageError(SocketErrorCodeServerUnavailable, "Temporary the server unavailable")
)
View Source
var (
	HeartbeatInterval = 30 * time.Second
)

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	Host      string `json:"host"`
	Protocol  string `json:"protocol"`
	Method    string `json:"method"`
	Path      string `json:"path"`
	Status    int    `json:"status"`
	UserAgent string `json:"user_agent"`
	ClientIp  string `json:"client_ip"`
	AppTime   int    `json:"app_time_ms"`
	RequestId string `json:"request_id"`
	UserId    string `json:"user_id"`
}

func (AccessLog) Fields

func (a AccessLog) Fields() []zap.Field

type Client added in v0.3.2

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

func NewSocketProxyClient added in v0.3.2

func NewSocketProxyClient(in io.Reader, out io.Writer) *Client

func (*Client) Dial added in v0.3.2

func (c *Client) Dial(host, port, token string) error

func (*Client) Pipe added in v0.3.2

func (c *Client) Pipe(ctx context.Context) error

type ErrorTokenAuthorization added in v0.3.2

type ErrorTokenAuthorization struct {
	Endpoint string
}

func (*ErrorTokenAuthorization) Error added in v0.3.2

func (e *ErrorTokenAuthorization) Error() string

type FrontendProxy

type FrontendProxy struct {
	Config *config.Config
	// contains filtered or unexported fields
}

func NewFrontendProxy

func NewFrontendProxy(conf *config.Config, ct *connector.Server, c *rpcclient.Client) *FrontendProxy

func (*FrontendProxy) Accept

func (p *FrontendProxy) Accept(server *http.Server, conn *tls.Conn, handler http.Handler)

func (*FrontendProxy) ServeHTTP

func (p *FrontendProxy) ServeHTTP(w http.ResponseWriter, req *http.Request)

type HttpProxy

type HttpProxy struct {
	Config *config.Config
	// contains filtered or unexported fields
}

func NewHttpProxy

func NewHttpProxy(conf *config.Config, ct *connector.Server, rpcClient *rpcclient.Client) *HttpProxy

func (*HttpProxy) ServeGithubWebHook

func (p *HttpProxy) ServeGithubWebHook(_ context.Context, w http.ResponseWriter, req *http.Request)

func (*HttpProxy) ServeHTTP

func (p *HttpProxy) ServeHTTP(ctx context.Context, w http.ResponseWriter, req *http.Request)

ServeHTTP has responsibility to serving content to client. ctx should be used instead of req.Context().

type MessageError

type MessageError interface {
	error
	Code() int
	Message() string
	Params() url.Values
	Clone() MessageError
}

func NewMessageError

func NewMessageError(code int, message string) MessageError

func ParseMessageError

func ParseMessageError(v url.Values) (MessageError, error)

type SocketProxy

type SocketProxy struct {
	Config *config.Config
	// contains filtered or unexported fields
}

func NewSocketProxy

func NewSocketProxy(conf *config.Config, ct *connector.Server) *SocketProxy

func (*SocketProxy) Accept

func (s *SocketProxy) Accept(_ *http.Server, conn tlsConn, _ http.Handler)

Accept handles incoming connection. conn is an established connection that is finished handshake.

func (*SocketProxy) Shutdown

func (s *SocketProxy) Shutdown()

type Stream

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

func NewStream

func NewStream(parent *SocketProxy, conn tlsConn, host string) *Stream

type Transport

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

func NewTransport

func NewTransport(conf *config.Config, ct *connector.Server) *Transport

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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