proxy

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_PREFIX          = "header_"
	RESPONSE_HEADER_PREFIX = "resheader_"
	SUB_PREFIX             = "sub_"
	SUBR_PREFIX            = "subr_"
	SUBB_PREFIX            = "subb_"
	CORS_STRING            = "cors"
	NOCACHE_STRING         = "nocache"
	NORF_STRING            = "norf"
	PROXY_STRING           = "proxy"
	IMPERSONATE_STRING     = "impersonate"
	TRIMRESHEADER_STRING   = "trimresheader"
	FORCESUB_STRING        = "forcesub"
	NOCSP_STRING           = "nocsp"
	TIMEOUT_STRING         = "timeout"
	INSECURE_STRING        = "insecure"
	COOKIE_STRING          = "cookie"
	USER_STRING            = "user"
	AUTH_STRING            = "auth" // entrypoint url http authorization, username:password
	FDHEADERS_STRING       = "fdheaders"
	BODY_STRING            = "body"
	RESBODY_STRING         = "resbody"
	RESBODYTYPE_STRING     = "resbodytype"
	TYPE_STRING            = "type"
	RESTYPE_STRING         = "restype"
	METHOD_STRING          = "method"
	REFERER_STRING         = "referer"
	ORIGIN_STRING          = "origin"
	SCOPE_STRING           = "scope"
	SIGN_STRING            = "sign"
	KEYTYPE_STRING         = "keytype"
	VALIDBEFORE_STRING     = "validbefore"
	VALIDAFTER_STRING      = "validafter"
	RESPASS_STRING         = "respass" // response body encryption password
	EID_STRING             = "eid"     // encrypt url id
	STATUS_STRING          = "status"
	ENCMODE_STRING         = "encmode"
	AUTHMODE_STRING        = "authmode"
	TPLMODE_STRING         = "tplmode"
	RESBODYTPL_STRING      = "resbodytpl" // use response body as template. path suffix, e.g. ".sgp.txt"
	DEBUG_STRING           = "debug"
	EPATH_STRING           = "epath" // allow subpath in encrypted url
	SALT_STRING            = "salt"
	ARG_SRING              = "arg"
	ARGS_SRING             = "args"
)
View Source
const NOBODY = "NOBODY"

Variables

These params do not participate in url signing, sign, keytype, salt.

Functions

func FetchUrl

func FetchUrl(urlObj *url.URL, srcReq *http.Request, queryParams url.Values, prefix, signkey string, keytypeBlacklist,
	openScopes []string, openNormal bool, rcloneBinary, rcloneConfig, encryltedUrlPath string, authenticator *auth.Auth,
	doLog bool) (*http.Response, error)

func Generate

func Generate(targetUrl, eid, key, publicurl, prefix string,
	cipher cipher.AEAD) (canonicalurl string, sign, encryptedurl, entryurl, encryptedEntryurl string)

func NewReadCloserReplacer added in v0.12.0

func NewReadCloserReplacer(src io.Reader, subs [][2]string, subrs [][2]string,
	subbs [][2][]byte) (io.ReadCloser, error)

Return a ReadCloser stream that do find-and-replacements to src on the fly. The Close func of returned value is no-op if src ifself is not a Closer.

func Parse added in v0.12.0

func Parse(prefix, fromurl, publicurl string) (plainurl, encryptedEntryurl, entryurl, eid string, err error)

func ProxyFunc

func ProxyFunc(w http.ResponseWriter, r *http.Request, prefix, key string, keytypeBlacklist, openScopes []string,
	openNormal, supressError, doLog bool, enableUnix, enableFile, enableRclone, enableCurl, enableExec bool,
	rcloneBinary, rcloneConfig, curlBinary string, cipher cipher.AEAD, authenticator *auth.Auth)

func Realkey

func Realkey(key, keytype string) string

key and keytype are guaranteed to do not contain \n. Put keytype (plaintext) first, to increase security against length extension attack. See https://en.wikipedia.org/wiki/Length_extension_attack . We use HMAC to derive signing key from Realkey() output, so it's only a double security.

Types

type ReadCloserReplacer added in v0.12.0

type ReadCloserReplacer struct {
	io.Reader
	// contains filtered or unexported fields
}

func (*ReadCloserReplacer) Close added in v0.12.0

func (r *ReadCloserReplacer) Close() error

type Response added in v0.12.0

type Response struct {
	Err     error
	Status  int
	Header  http.Header
	Body    string
	Data    any
	RawBody io.ReadCloser
}

type Template added in v0.11.0

type Template interface {
	Execute(wr io.Writer, data any) error
}

Jump to

Keyboard shortcuts

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