Documentation
¶
Overview ¶
Package proxy implements a http proxy.
Support GET, POST, CONNECT method and so on. Support proxy auth and web management. Support web cache.
Index ¶
- Variables
- func Check(user, passwd string) bool
- func CheckAdmin(user, passwd string) bool
- func ClearHeaders(headers http.Header)
- func CopyHeaders(dst, src http.Header)
- func CopyResponse(dest *http.Response, src *http.Response)
- func GetBuf() []byte
- func NeedAuth(rw http.ResponseWriter, challenge []byte) error
- func NewServer() *http.Server
- func PutBuf(buf []byte)
- func RmProxyHeaders(req *http.Request)
- type BufferPool
- type Server
- func (proxy *Server) Auth(rw http.ResponseWriter, req *http.Request) bool
- func (proxy *Server) Ban(rw http.ResponseWriter, req *http.Request) bool
- func (proxy *Server) CacheHandler(rw http.ResponseWriter, req *http.Request)
- func (proxy *Server) HTTPHandler(rw http.ResponseWriter, req *http.Request)
- func (proxy *Server) HTTPSHandler(rw http.ResponseWriter, req *http.Request)
- func (proxy *Server) ReverseHandler(req *http.Request)
- func (proxy *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- type WebServer
- func (ws *WebServer) HomeHandler(rw http.ResponseWriter, req *http.Request)
- func (ws *WebServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (ws *WebServer) SettingHandler(rw http.ResponseWriter, req *http.Request)
- func (ws *WebServer) UserHandler(rw http.ResponseWriter, req *http.Request)
- func (ws *WebServer) WebAuth(rw http.ResponseWriter, req *http.Request) error
Constants ¶
This section is empty.
Variables ¶
var HTTP200 = []byte("HTTP/1.1 200 Connection Established\r\n\r\n")
HTTP200 http 200 response
var HTTP401 = []byte("HTTP/1.1 401 Authorization Required\r\nWWW-Authenticate: Basic realm=\"Secure Web\"\r\n\r\n")
HTTP401 http 401 response
var HTTP407 = []byte("HTTP/1.1 407 Proxy Authorization Required\r\nProxy-Authenticate: Basic realm=\"Secure Proxys\"\r\n\r\n")
HTTP407 http 407 response
Functions ¶
func CopyHeaders ¶
CopyHeaders copy headers from source to destination. Nothing would be returned.
func CopyResponse ¶
CopyResponse copys response from src to dest.
func NeedAuth ¶
func NeedAuth(rw http.ResponseWriter, challenge []byte) error
NeedAuth requires authorization
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool holds a pool of buffer
func NewBufferPool ¶
func NewBufferPool(size int) *BufferPool
NewBufferPool creates a new buffer pool.
type Server ¶
Server is a server of proxy.
func (*Server) Auth ¶
Auth provides basic authorization for proxy server.
func (*Server) Ban ¶
Ban forbids requested URL in GFWList.
func (*Server) CacheHandler ¶
func (proxy *Server) CacheHandler(rw http.ResponseWriter, req *http.Request)
CacheHandler handles "Get" request
func (*Server) HTTPHandler ¶
func (proxy *Server) HTTPHandler(rw http.ResponseWriter, req *http.Request)
HTTPHandler handles http connections. 处理普通的http请求
func (*Server) HTTPSHandler ¶
func (proxy *Server) HTTPSHandler(rw http.ResponseWriter, req *http.Request)
HTTPSHandler handles any connection which need connect method. 处理https连接,主要用于CONNECT方法
func (*Server) ReverseHandler ¶
ReverseHandler handles request for reverse proxy.
type WebServer ¶
type WebServer struct {
Port string
}
WebServer is a manager server
func (*WebServer) HomeHandler ¶
func (ws *WebServer) HomeHandler(rw http.ResponseWriter, req *http.Request)
HomeHandler handles web home page
func (*WebServer) ServeHTTP ¶
func (ws *WebServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP handles web admin pages
func (*WebServer) SettingHandler ¶
func (ws *WebServer) SettingHandler(rw http.ResponseWriter, req *http.Request)
SettingHandler allows admin modifies proxy's setting.
Source Files
¶
- auth.go
- ban.go
- buf.go
- cache.go
- headers.go
- init.go
- proxy.go
- reverse.go
- web.go