engin

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 24 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 added in v1.4.0

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

func DebugReqeust

func DebugReqeust(r *http.Request)

func GetFileTimestamp added in v1.6.0

func GetFileTimestamp(file string) time.Time

func GetUUID added in v1.4.0

func GetUUID() string

func HttpError added in v1.4.0

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

func IsConnect

func IsConnect(address string, timeout int) bool

func SetVersion added in v1.5.0

func SetVersion(v string)

func StatUpdate added in v1.5.0

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 added in v1.5.0

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

func NewLocalForward added in v1.5.0

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 added in v1.4.1

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

func (*HttpAccess) ForwardUpdateHandlerSet added in v1.4.1

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 added in v1.2.7

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 added in v1.5.0

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

func (*HttpProxyForward) Close added in v1.5.0

func (d *HttpProxyForward) Close() error

func (*HttpProxyForward) Http added in v1.5.0

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

func (*HttpProxyForward) Https added in v1.5.0

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

func (*HttpProxyForward) ProxyFunc added in v1.5.0

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

type LocalForward added in v1.5.0

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

func (*LocalForward) Close added in v1.5.0

func (d *LocalForward) Close() error

func (*LocalForward) Http added in v1.5.0

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

func (*LocalForward) Https added in v1.5.0

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