Versions in this module Expand all Collapse all v0 v0.5.0 Mar 7, 2017 Changes in this version + const EntryLengthMax + const MaxPageSize + var ProtoCap = ":ap" + var ProtoCookie = "cookie" + var ProtoDhtAnnounce = "dht.announce" + var ProtoDhtEntries = "dht.entries" + var ProtoDhtEntry = "dht.entry" + var ProtoDhtFindClosest = "dht.findclosest" + var ProtoDhtQuery = "dht.query" + var ProtoDone = "done" + var ProtoHashList = "hashlist" + var ProtoHeader = "header" + var ProtoNo = "no" + var ProtoOk = "ok" + var ProtoPopular = "popular" + var ProtoPosts = "posts" + var ProtoRecent = "recent" + var ProtoRequestAddPeer = "req.addpeer" + var ProtoRequestHashList = "req.hashlist" + var ProtoRequestPiece = "req.piece" + var ProtoSearch = "search" + var ProtoSig = "sig" + var ProtoTerminate = "term" + var ProtoVersion int16 = 0x0000 + var ProtoZif int16 = 0x7a66 + func ChooseCompression(client MessageCapabilities, server MessageCapabilities) string + type Client struct + func NewClient(conn net.Conn) (*Client, error) + func (c *Client) Announce(e common.Encoder) error + func (c *Client) Bootstrap(d *dht.DHT, address dht.Address) error + func (c *Client) Close() (err error) + func (c *Client) Collection(address dht.Address, entry dht.Entry) (*MessageCollection, error) + func (c *Client) Decode(i interface{}) error + func (c *Client) FindClosest(address dht.Address) ([]*dht.Entry, error) + func (c *Client) Pieces(address dht.Address, id, length int) chan *data.Piece + func (c *Client) Popular(page int) ([]*data.Post, error) + func (c *Client) Query(address dht.Address) (*dht.Entry, error) + func (c *Client) ReadMessage() (*Message, error) + func (c *Client) Recent(page int) ([]*data.Post, error) + func (c *Client) RequestAddPeer(addr dht.Address) error + func (c *Client) Search(search string, page int) ([]*data.Post, error) + func (c *Client) SendStruct(e common.Encoder) error + func (c *Client) Terminate() + func (c *Client) WriteErr(toSend error) error + func (c *Client) WriteMessage(v interface{}) error + type ConnHeader struct + Capabilities MessageCapabilities + Client Client + Entry dht.Entry + type Message struct + Client *Client + Compression string + Content []byte + From *dht.Address + Header string + Stream net.Conn + func (m *Message) Json() ([]byte, error) + func (m *Message) Ok() bool + func (m *Message) Read(iface interface{}) error + func (m *Message) ReadInt() (int, error) + func (m *Message) Write(iface interface{}) error + type MessageCapabilities struct + Compression []string + type MessageCollection struct + Hash []byte + HashList []byte + Signature []byte + Size int + func (mhl *MessageCollection) Encode() ([]byte, error) + func (mhl *MessageCollection) Verify(root []byte) error + type MessagePiece struct + Posts interface{} + func (mp *MessagePiece) Hash() ([]byte, error) + type MessageRequestPiece struct + Address string + Id int + Length int + func (mrp *MessageRequestPiece) Encode() ([]byte, error) + type MessageSearchQuery struct + Page int + Query string + func (sq *MessageSearchQuery) Encode() ([]byte, error) + type NetworkPeer interface + AddStream func(net.Conn) + Address func() *dht.Address + FindClosest func(dht.Address) ([]common.Verifier, error) + Query func(dht.Address) (common.Verifier, error) + Session func() *yamux.Session + SetCapabilities func(MessageCapabilities) + UpdateSeen func() + type ProtocolHandler interface + GetCapabilities func() *MessageCapabilities + GetNetworkPeer func(dht.Address) NetworkPeer + HandleAddPeer func(*Message) error + HandleAnnounce func(*Message) error + HandleCloseConnection func(*dht.Address) + HandleFindClosest func(*Message) error + HandleHandshake func(ConnHeader) (NetworkPeer, error) + HandleHashList func(*Message) error + HandlePiece func(*Message) error + HandlePopular func(*Message) error + HandleQuery func(*Message) error + HandleRecent func(*Message) error + HandleSearch func(*Message) error + SetNetworkPeer func(NetworkPeer) + type Server struct + func NewServer(cap *MessageCapabilities) *Server + func (s *Server) Close() + func (s *Server) HandleStream(peer NetworkPeer, handler ProtocolHandler, stream net.Conn) + func (s *Server) Handshake(conn net.Conn, lp ProtocolHandler, data common.Encoder) + func (s *Server) Listen(addr string, handler ProtocolHandler, data common.Encoder) + func (s *Server) ListenStream(peer NetworkPeer, handler ProtocolHandler) + func (s *Server) RouteMessage(msg *Message, handler ProtocolHandler) + type StreamManager struct + Socks bool + SocksPort int + func (sm *StreamManager) AddStream(conn net.Conn) + func (sm *StreamManager) Close() + func (sm *StreamManager) ConnectClient() (*yamux.Session, error) + func (sm *StreamManager) ConnectServer() (*yamux.Session, error) + func (sm *StreamManager) GetSession() *yamux.Session + func (sm *StreamManager) GetStream(conn net.Conn) *Client + func (sm *StreamManager) Handshake(conn net.Conn, lp ProtocolHandler, data common.Encoder) (*dht.Entry, *MessageCapabilities, error) + func (sm *StreamManager) OpenSocks(addr string, lp ProtocolHandler, data common.Encoder) (*ConnHeader, error) + func (sm *StreamManager) OpenStream() (*Client, error) + func (sm *StreamManager) OpenTCP(addr string, lp ProtocolHandler, data common.Encoder) (*ConnHeader, error) + func (sm *StreamManager) RemoveStream(conn net.Conn) + func (sm *StreamManager) SetConnection(conn ConnHeader) + func (sm *StreamManager) Setup()