authproxy

package
v0.11.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2020 License: MIT Imports: 35 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
)
View Source
var TokenExpiration = 5 * time.Minute

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 AuthProxy

type AuthProxy struct {
	Config *configv2.Config
	// contains filtered or unexported fields
}

func NewAuthProxy

func NewAuthProxy(conf *configv2.Config, ct *connector.Server, c *rpcclient.Client) *AuthProxy

func (*AuthProxy) Accept

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

func (*AuthProxy) ServeHTTP

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

type Client

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

func NewSocketProxyClient

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

func (*Client) Dial

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

func (*Client) Pipe

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

type ErrorTokenAuthorization

type ErrorTokenAuthorization struct {
	Endpoint string
}

func (*ErrorTokenAuthorization) Error

func (e *ErrorTokenAuthorization) Error() string

type HttpProxy

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

func NewHttpProxy

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

func (*HttpProxy) ServeGithubWebHook

func (p *HttpProxy) ServeGithubWebHook(ctx 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().

func (*HttpProxy) ServeSlackWebHook

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

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 *configv2.Config
	// contains filtered or unexported fields
}

func NewSocketProxy

func NewSocketProxy(conf *configv2.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 *configv2.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