serve

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2014 License: MIT Imports: 32 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AuthType_NO            = 0
	AuthType_Basic         = 1
	AuthType_Basic_WithAny = 2
	AuthType_Basic_Try     = 3

	ResponseSave_All      = 0
	ResponseSave_HasBroad = 1 //has show

	SessionView_ALL        = 0
	SessionView_IP_OR_USER = 1
)
View Source
const (
	REDO_FLAG       = "Proxy-pproxy_redo"
	REDO_REMOTEADDR = "Proxy-pproxy_remoteaddr"
	REDO_USER_NAME  = "Proxy-pproxy_user"
)
View Source
const (
	Content_Encoding = "Content-Encoding"
)

Variables

View Source
var CookieName = "pproxy"
View Source
var (
	// DefaultUpgrader specifies the parameters for upgrading an HTTP
	// connection to a WebSocket connection.
	DefaultUpgrader = &websocket.Upgrader{
		ReadBufferSize:  1024,
		WriteBufferSize: 1024,
	}
)
View Source
var PproxyVersion string = ""

Functions

func GetDemoConf

func GetDemoConf() string

func GetFormValuesWithPrefix

func GetFormValuesWithPrefix(values url.Values, prefix string) map[string][]string

func GetVersion

func GetVersion() string

func Int64ToBytes

func Int64ToBytes(i int64) []byte

func IsLocalIp

func IsLocalIp(host string) bool

func NewRequestCtx

func NewRequestCtx(ser *ProxyServe, req *http.Request) *requestCtx

func NewRequestModifier

func NewRequestModifier(ser *ProxyServe) *requestModifier

Types

type Config

type Config struct {
	Port         int
	Title        string
	Notice       string
	AuthType     int
	DataDir      string
	ResponseSave int
	SessionView  int
	DataStoreDay int
	ParentProxy  *url.URL
}

func LoadConfig

func LoadConfig(confPath string) (*Config, error)

type HttpProxy

type HttpProxy struct {
	GoProxy *goproxy.ProxyHttpServer
	// contains filtered or unexported fields
}

func NewHttpProxy

func NewHttpProxy(ser *ProxyServe) *HttpProxy

func (*HttpProxy) ServeHTTP

func (proxy *HttpProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type KvTable

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

func (*KvTable) Count

func (tb *KvTable) Count() int

func (*KvTable) Delete

func (tb *KvTable) Delete(id int) error

func (*KvTable) ForEachDoc

func (tb *KvTable) ForEachDoc(fn func(int, []byte) bool)

func (*KvTable) Gc

func (tb *KvTable) Gc(max_time_unix int64) int

func (*KvTable) GetByKey

func (tb *KvTable) GetByKey(id int) (data KvType, err error)

func (*KvTable) Scrub

func (tb *KvTable) Scrub()

func (*KvTable) Set

func (tb *KvTable) Set(id int, data KvType) error

type KvType

type KvType map[string]interface{}

type ProxyServe

type ProxyServe struct {
	MaxResSaveLength int64

	Debug bool

	Users        map[string]*User
	ProxyClients map[string]*clientSession
	// contains filtered or unexported fields
}

func NewProxyServe

func NewProxyServe(confPath string, port int) (*ProxyServe, error)

func (*ProxyServe) Broadcast_Req

func (ser *ProxyServe) Broadcast_Req(req *http.Request, reqCtx *requestCtx) bool

func (*ProxyServe) GetHostsFilePath

func (ser *ProxyServe) GetHostsFilePath() string

func (*ProxyServe) GetNewDocid

func (ser *ProxyServe) GetNewDocid() int

func (*ProxyServe) GetRequestByDocid

func (ser *ProxyServe) GetRequestByDocid(docid int) (req_data KvType)

func (*ProxyServe) GetResponseByDocid

func (ser *ProxyServe) GetResponseByDocid(docid int) (res_data KvType)

func (*ProxyServe) GetRewriteJsPath

func (ser *ProxyServe) GetRewriteJsPath() string

func (*ProxyServe) ServeHTTP

func (ser *ProxyServe) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*ProxyServe) Start

func (ser *ProxyServe) Start()

type TieDb

type TieDb struct {
	RequestTable  *KvTable
	ResponseTable *KvTable
	// contains filtered or unexported fields
}

func NewTieDb

func NewTieDb(dir string, maxDay int) *TieDb

func (*TieDb) Clean

func (t *TieDb) Clean(max_time_unix int64)

func (*TieDb) Flush

func (t *TieDb) Flush()

func (*TieDb) StartGcTimer

func (t *TieDb) StartGcTimer(sec int64, max_life int64)

type User

type User struct {
	Name         string
	Psw          string
	PswMd5       string
	IsAdmin      bool
	SkipCheckPsw bool
}

func (*User) ConfigString

func (u *User) ConfigString() string

func (*User) String

func (u *User) String() string

type WebsocketProxy

type WebsocketProxy struct {
	// Upgrader specifies the parameters for upgrading a incoming HTTP
	// connection to a WebSocket connection. If nil, DefaultUpgrader is used.
	Upgrader *websocket.Upgrader
	// contains filtered or unexported fields
}

WebsocketProxy is an HTTP Handler that takes an incoming WebSocket connection and proxies it to another server.

func NewWsProxy

func NewWsProxy(ser *ProxyServe) *WebsocketProxy

NewProxy returns a new Websocket reverse proxy that rewrites the URL's to the scheme, host and base path provider in target.

func (*WebsocketProxy) ServeHTTP

func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler that proxies WebSocket connections.

Jump to

Keyboard shortcuts

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