Documentation ¶
Index ¶
- Constants
- Variables
- func MakeDiff(old []byte, new_ []byte) []byte
- func NewCacheCompressorWriter(writer io.Writer, cache Cache, cacheKey []byte, cacheDigest []byte, ...) io.WriteCloser
- func Patch(old []byte, patch []byte) []byte
- type Body
- type Cache
- type CacheCompressor
- type CacheCompressorWriter
- type CacheItem
- type CacheManager
- type CacheShareData
- type CacheWorker
- type CachedTunnelReader
- type CachedTunnelWriter
- type Compressor
- type CompressorWriter
- type DiffContent
- type ErrorData
- type Header
- func (h *Header) AddFlag(flag uint16)
- func (h *Header) GetStreamId() UID
- func (h *Header) IsEndOfStream() bool
- func (h *Header) MarshalBinary() ([]byte, error)
- func (h *Header) SetFlag(flag uint16)
- func (h *Header) SetStreamId(sid UID)
- func (h *Header) TestFlag(flag uint16) bool
- func (h *Header) UnmarshalBinary(data []byte) error
- type HttpProxyServer
- type HttpTransport
- type HttpWorker
- type HttpWorkerFactory
- type LocalCache
- type Msg
- type MsgBuilder
- type MultiStreamWorker
- type PeerCache
- type StreamWorkerMaker
- type TcpData
- type TcpTransport
- type TcpWorker
- type TcpWorkerFactory
- type TimeoutWriter
- type TunnelClient
- type TunnelConn
- type TunnelReader
- type TunnelServer
- type TunnelWriter
- type UID
- type Worker
Constants ¶
View Source
const ( MAX_CACHE_SIZE int = 5 * 1024 * 1024 MAX_BUFF_SIZE int = 500 * 1024 )
View Source
const ( INVALID uint16 = 0 TCP_CONNECT uint16 = 1 TCP_CONNECT_REP uint16 = 2 TCP_DATA uint16 = 3 HTTP_CONNECT uint16 = 11 HTTP_DATA uint16 = 12 CACHE_SHARE uint16 = 21 //CACHE_SHARE uint16 = 51 ERROR uint16 = 255 )
View Source
const ( FLAG_TCP uint16 = 1 FLAG_UDP uint16 = 2 FLAG_HTTP uint16 = 4 FLAG_STREAM_BEGIN uint16 = 8 FLAG_STREAM_END uint16 = 16 )
View Source
const ( CT_RAW uint16 = 0 CT_CACHE_DIFF uint16 = 1 )
View Source
const (
HEADER_SIZE = 18
)
View Source
const (
VERSION_1 uint8 = 1
)
Variables ¶
View Source
var CT_NAMES map[uint16]string = map[uint16]string{ CT_RAW: "CT_RAW", CT_CACHE_DIFF: "CT_CACHE_DIFF", }
View Source
var ErrorCompressFail = errors.New("CompressFail")
View Source
var ErrorDecompressFail = errors.New("DecompressFail")
View Source
var FLAG_NAMES map[uint16]string = map[uint16]string{ FLAG_TCP: "FLAG_TCP", FLAG_UDP: "FLAG_UDP", FLAG_HTTP: "FLAG_HTTP", FLAG_STREAM_BEGIN: "FLAG_STREAM_BEGIN", FLAG_STREAM_END: "FLAG_STREAM_END", }
View Source
var InvalidBody error = errors.New("Invalid Body")
View Source
var InvalidFrameCount error = errors.New("Invalid Frame Count")
View Source
var InvalidHeader error = errors.New("Invalid Header")
View Source
var TYPE_NAMES map[uint16]string = map[uint16]string{ TCP_CONNECT: "TCP_CONNECT", TCP_CONNECT_REP: "TCP_CONNECT_REP", TCP_DATA: "TCP_DATA", CACHE_SHARE: "CACHE_SHARE", ERROR: "ERROR", }
Functions ¶
Types ¶
type Body ¶
type Body interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler String() string }
type CacheCompressor ¶
type CacheCompressor struct { *CacheCompressorWriter // contains filtered or unexported fields }
func (*CacheCompressor) Bytes ¶
func (c *CacheCompressor) Bytes() []byte
type CacheCompressorWriter ¶
type CacheCompressorWriter struct {
// contains filtered or unexported fields
}
func (*CacheCompressorWriter) Close ¶
func (c *CacheCompressorWriter) Close() error
func (*CacheCompressorWriter) Flush ¶
func (c *CacheCompressorWriter) Flush() error
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
func (*CacheManager) GetPeer ¶
func (cm *CacheManager) GetPeer(pid string) (peer *PeerCache, ok bool)
func (*CacheManager) GetPeerDigest ¶
func (cm *CacheManager) GetPeerDigest(pid string, key []byte) (digest []byte, ok bool)
func (*CacheManager) UpdatePeer ¶
func (cm *CacheManager) UpdatePeer(pid string, item *CacheItem) error
type CacheShareData ¶
type CacheShareData struct {
}func (*CacheShareData) MarshalBinary ¶
func (d *CacheShareData) MarshalBinary() (b []byte, err error)
func (*CacheShareData) String ¶
func (d *CacheShareData) String() string
func (*CacheShareData) UnmarshalBinary ¶
func (d *CacheShareData) UnmarshalBinary(b []byte) (err error)
type CacheWorker ¶
type CacheWorker struct {
// contains filtered or unexported fields
}
func NewCacheWorker ¶
func NewCacheWorker(cm *CacheManager) *CacheWorker
func (*CacheWorker) GetReqChannel ¶
func (w *CacheWorker) GetReqChannel() chan *Msg
func (*CacheWorker) Run ¶
func (w *CacheWorker) Run(repChan chan *Msg) error
type CachedTunnelReader ¶
type CachedTunnelReader struct { *TunnelReader // contains filtered or unexported fields }
func (*CachedTunnelReader) Close ¶
func (c *CachedTunnelReader) Close() error
type CachedTunnelWriter ¶
type CachedTunnelWriter struct { *TunnelWriter // contains filtered or unexported fields }
A CachedTunnelWriter will cache the data, send them with one msg when close
func NewCachedTunnelWriter ¶
func NewCachedTunnelWriter(w *TunnelWriter, comp Compressor) *CachedTunnelWriter
func (*CachedTunnelWriter) Close ¶
func (c *CachedTunnelWriter) Close() (err error)
type Compressor ¶
func NewCacheCompressor ¶
func NewCacheCompressor(cache Cache, cacheKey []byte, cacheDigest []byte, update bool) Compressor
type CompressorWriter ¶
type CompressorWriter interface { io.WriteCloser }
type DiffContent ¶
type Header ¶
20 bytes
func (*Header) GetStreamId ¶
func (*Header) IsEndOfStream ¶
func (*Header) MarshalBinary ¶
func (*Header) SetStreamId ¶
func (*Header) UnmarshalBinary ¶
type HttpProxyServer ¶
type HttpProxyServer struct {
// contains filtered or unexported fields
}
func NewHttpProxyServer ¶
func NewHttpProxyServer(tc *TunnelClient) *HttpProxyServer
func (*HttpProxyServer) ListenAndServe ¶
func (s *HttpProxyServer) ListenAndServe(bind string) error
func (*HttpProxyServer) ServeHTTP ¶
func (s *HttpProxyServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HttpTransport ¶
type HttpTransport interface {
RoundTrip(r *http.Request) (io.ReadCloser, error)
}
type HttpWorker ¶
type HttpWorker struct {
// contains filtered or unexported fields
}
func (*HttpWorker) GetReqChannel ¶
func (w *HttpWorker) GetReqChannel() chan *Msg
func (*HttpWorker) Run ¶
func (w *HttpWorker) Run(repChan chan *Msg) error
type HttpWorkerFactory ¶
type HttpWorkerFactory struct {
// contains filtered or unexported fields
}
func (*HttpWorkerFactory) MakeStreamWorker ¶
func (s *HttpWorkerFactory) MakeStreamWorker(sid UID) Worker
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
func (*LocalCache) Del ¶
func (c *LocalCache) Del(key []byte) bool
func (*LocalCache) Digest ¶
func (c *LocalCache) Digest(data []byte) []byte
type MsgBuilder ¶
type MsgBuilder interface { MakeMsg(mt uint16, ct uint16, data []byte, flags uint16) *Msg MakeErrorMsg(err error, flags uint16) *Msg }
func NewMsgBuilder ¶
func NewMsgBuilder(sid UID, envelope [][]byte, flags uint16) MsgBuilder
func NewMsgBuilderFromMsg ¶
func NewMsgBuilderFromMsg(tpl *Msg) MsgBuilder
type MultiStreamWorker ¶
type MultiStreamWorker struct {
// contains filtered or unexported fields
}
func (*MultiStreamWorker) GetReqChannel ¶
func (w *MultiStreamWorker) GetReqChannel() chan *Msg
func (*MultiStreamWorker) Run ¶
func (w *MultiStreamWorker) Run(repChan chan *Msg) error
type PeerCache ¶
type PeerCache struct {
// contains filtered or unexported fields
}
handle cache update
type StreamWorkerMaker ¶
type TcpData ¶
func (*TcpData) GetPayload ¶
func (*TcpData) MarshalBinary ¶
func (*TcpData) UnmarshalBinary ¶
type TcpWorker ¶
type TcpWorker struct {
// contains filtered or unexported fields
}
func (*TcpWorker) GetReqChannel ¶
type TcpWorkerFactory ¶
type TcpWorkerFactory struct{}
func (*TcpWorkerFactory) MakeStreamWorker ¶
func (s *TcpWorkerFactory) MakeStreamWorker(sid UID) Worker
type TimeoutWriter ¶
type TimeoutWriter struct {
// contains filtered or unexported fields
}
func (*TimeoutWriter) Flush ¶
func (w *TimeoutWriter) Flush() error
type TunnelClient ¶
type TunnelClient struct {
// contains filtered or unexported fields
}
func NewTunnelClient ¶
func NewTunnelClient(remote string) (*TunnelClient, error)
func NewTunnelClientKeyPair ¶
func (*TunnelClient) Close ¶
func (c *TunnelClient) Close() error
func (*TunnelClient) ConnectTcp ¶
func (c *TunnelClient) ConnectTcp(host string) (net.Conn, error)
func (*TunnelClient) RoundTrip ¶
func (c *TunnelClient) RoundTrip(r *http.Request) (io.ReadCloser, error)
implement http.RoundTrip interface send http request via the tunnel
func (*TunnelClient) Run ¶
func (c *TunnelClient) Run() error
type TunnelConn ¶
type TunnelConn struct { io.Reader io.WriteCloser }
TunnelConn
func (*TunnelConn) LocalAddr ¶
func (c *TunnelConn) LocalAddr() net.Addr
func (*TunnelConn) RemoteAddr ¶
func (c *TunnelConn) RemoteAddr() net.Addr
func (*TunnelConn) SetDeadline ¶
func (c *TunnelConn) SetDeadline(t time.Time) error
func (*TunnelConn) SetReadDeadline ¶
func (c *TunnelConn) SetReadDeadline(t time.Time) error
func (*TunnelConn) SetWriteDeadline ¶
func (c *TunnelConn) SetWriteDeadline(t time.Time) error
type TunnelReader ¶
type TunnelReader struct {
// contains filtered or unexported fields
}
Read bytes from Msg channel
func (*TunnelReader) Close ¶
func (c *TunnelReader) Close() error
type TunnelServer ¶
type TunnelServer struct {
// contains filtered or unexported fields
}
func NewTunnelServer ¶
func NewTunnelServer(bind string) (*TunnelServer, error)
func NewTunnelServerKeyPair ¶
func NewTunnelServerKeyPair(bind string, pub string, secret string) (*TunnelServer, error)
func (*TunnelServer) Close ¶
func (s *TunnelServer) Close() error
func (*TunnelServer) Run ¶
func (s *TunnelServer) Run() error
type TunnelWriter ¶
type TunnelWriter struct {
// contains filtered or unexported fields
}
func (*TunnelWriter) Close ¶
func (c *TunnelWriter) Close() error
type Worker ¶
func NewMultiStreamHttpWorker ¶
func NewMultiStreamHttpWorker(cm *CacheManager) Worker
func NewMultiStreamTcpWorker ¶
func NewMultiStreamTcpWorker() Worker
Source Files ¶
Click to show internal directories.
Click to hide internal directories.