engin

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ONE_GB float64 = 1024 * 1024 * 1024
	ONE_MB float64 = 1024 * 1024
	ONE_KB float64 = 1024
)

Variables

This section is empty.

Functions

func Address

func Address(u *url.URL) string

func AuthCache

func AuthCache(r *http.Request) bool

func AuthFailHandler

func AuthFailHandler(w http.ResponseWriter, r *http.Request)

func AuthLogin

func AuthLogin(r *http.Request)

func Connect

func Connect(acc *HttpAccess, in net.Conn, out net.Conn)

func DebugReqeust

func DebugReqeust(r *http.Request)

func GetUUID

func GetUUID() string

func HttpError

func HttpError(w http.ResponseWriter, err string, code int)

func IsConnect

func IsConnect(address string, timeout int) bool

func SetVersion

func SetVersion(v string)

func StatUpdate

func StatUpdate(session int64, size int64)

func TlsConfigClient

func TlsConfigClient(servername string, certfile, keyfile string) (*tls.Config, error)

func TlsConfigServer

func TlsConfigServer(certfile, keyfile string) (*tls.Config, error)

func WriteFull

func WriteFull(w io.Writer, body []byte) error

Types

type Access

type Access interface {
	Shutdown() error
	AuthHandlerSet(func(*AuthInfo) bool)
	ForwardHandlerSet(func(address string, r *http.Request) Forward)
	ForwardUpdateHandlerSet(func(address string, forward Forward))
}

func NewHttpsAccess

func NewHttpsAccess(addr string, timeout int, tlsEnable bool, certfile, keyfile string) (Access, error)

type AuthCtrl

type AuthCtrl struct {
	sync.RWMutex
	Cache map[string]AuthItem
}

type AuthInfo

type AuthInfo struct {
	User  string
	Token string
}

func AuthInfoParse

func AuthInfoParse(r *http.Request) *AuthInfo

type AuthItem

type AuthItem struct {
	Address string
	Login   time.Time
}

type Forward

type Forward interface {
	Close() error
	Http(r *http.Request) (*http.Response, error)
	Https(address string, r *http.Request) (net.Conn, error)
}

func NewHttpProxyForward

func NewHttpProxyForward(address string, timeout int, auth *AuthInfo, tlsEnable bool, certfile, keyfile string) (Forward, error)

func NewLocalForward

func NewLocalForward(timeout int) Forward

type HttpAccess

type HttpAccess struct {
	Timeout int
	Address string

	sync.WaitGroup
	// contains filtered or unexported fields
}

func (*HttpAccess) AuthHandlerSet

func (acc *HttpAccess) AuthHandlerSet(handler func(auth *AuthInfo) bool)

func (*HttpAccess) AuthHttp

func (acc *HttpAccess) AuthHttp(r *http.Request) bool

func (*HttpAccess) ForwardHandlerSet

func (acc *HttpAccess) ForwardHandlerSet(handler func(address string, r *http.Request) Forward)

func (*HttpAccess) ForwardUpdate

func (acc *HttpAccess) ForwardUpdate(address string, forward Forward)

func (*HttpAccess) ForwardUpdateHandlerSet

func (acc *HttpAccess) ForwardUpdateHandlerSet(handler func(address string, forward Forward))

func (*HttpAccess) HttpForward

func (acc *HttpAccess) HttpForward(address string, r *http.Request) (*http.Response, error)

func (*HttpAccess) HttpRoundTripper

func (acc *HttpAccess) HttpRoundTripper(r *http.Request) (*http.Response, error)

func (*HttpAccess) HttpsForward

func (acc *HttpAccess) HttpsForward(address string, r *http.Request) (net.Conn, error)

func (*HttpAccess) HttpsRoundTripper

func (acc *HttpAccess) HttpsRoundTripper(w http.ResponseWriter, r *http.Request)

func (*HttpAccess) NoProxyHandler

func (acc *HttpAccess) NoProxyHandler(w http.ResponseWriter, r *http.Request)

func (*HttpAccess) ServeHTTP

func (acc *HttpAccess) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HttpAccess) Shutdown

func (acc *HttpAccess) Shutdown() error

type HttpProxyForward

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

func (*HttpProxyForward) Close

func (d *HttpProxyForward) Close() error

func (*HttpProxyForward) Http

func (h *HttpProxyForward) Http(r *http.Request) (*http.Response, error)

func (*HttpProxyForward) Https

func (h *HttpProxyForward) Https(address string, r *http.Request) (net.Conn, error)

func (*HttpProxyForward) ProxyFunc

func (h *HttpProxyForward) ProxyFunc(r *http.Request) (*url.URL, error)

type LocalForward

type LocalForward struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func (*LocalForward) Close

func (d *LocalForward) Close() error

func (*LocalForward) Http

func (d *LocalForward) Http(r *http.Request) (*http.Response, error)

func (*LocalForward) Https

func (d *LocalForward) Https(address string, r *http.Request) (net.Conn, error)

Jump to

Keyboard shortcuts

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