httpp

package module
v0.0.0-...-ea05940 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package httpp provides a convenient way to implement an http proxy server with flexible backends.

Index

Constants

View Source
const (
	CONNECT = "CONNECT"
)

proxy type

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Type() string
	Cred(string) bool
}

Authenticator interface

type BasicAuth

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

BasicAuth ...

func (*BasicAuth) Add

func (ba *BasicAuth) Add(c string)

Add adds a credential. cred = string(USERNAME) + ":" + string(PASSWORD)

func (*BasicAuth) Cred

func (ba *BasicAuth) Cred(c string) (b bool)

Cred validates a credential.

func (*BasicAuth) Del

func (ba *BasicAuth) Del(c string)

Del deletes a credential. cred = string(USERNAME) + ":" + string(PASSWORD)

func (*BasicAuth) Type

func (ba *BasicAuth) Type() string

Type returns Proxy-Authorization type.

type Request

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

Request illustrates a request.

func (*Request) ClientAddr

func (req *Request) ClientAddr() net.Addr

ClientAddr returns client's address.

func (*Request) Fail

func (req *Request) Fail(e error)

Fail denies the Request with a given error.

func (*Request) Host

func (req *Request) Host() string

Host returns request's target host.

func (*Request) Success

func (req *Request) Success(conn net.Conn)

Success approves the Request with an interface which can be converted to net.Conn.

func (*Request) Type

func (req *Request) Type() string

Type returns request's type.

type Server

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

Server illustrates a server.

func NewServer

func NewServer(addr string, forceAuth bool, timeout time.Duration) *Server

NewServer news a Server.

func (*Server) Accept

func (s *Server) Accept() (req *Request)

Accept returns a valid request. If the server is stopped, it will return nil.

func (*Server) DelAuth

func (s *Server) DelAuth(typ string)

DelAuth deletes the authenticator with given type.

func (*Server) GetAuth

func (s *Server) GetAuth(typ string) (a Authenticator)

GetAuth gets the authenticator with given type. It will return a nil authenticator when not exist.

func (*Server) Listen

func (s *Server) Listen() (e error)

Listen listens the address and serves.

func (*Server) SetAuth

func (s *Server) SetAuth(a Authenticator)

SetAuth sets an authenticator, it will overwrite the authenticator with same type if exists.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server. Stop a server before Listen() will cause panic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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