rpc

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ParamAction = "action"
View Source
const ParamInfohash = "infohash"
View Source
const ParamMethod = "method"
View Source
const ParamN = "n"
View Source
const ParamSwarm = "swarm"
View Source
const ParamSwarms = "swarms"
View Source
const ParamURL = "url"
View Source
const RPCAddTorrent = RPCName + ".AddTorrent"
View Source
const RPCChangeTorrent = RPCName + ".ChangeTorrent"
View Source
const RPCContentType = "text/json; encoding=UTF-8"
View Source
const RPCDelTorrent = RPCName + ".DelTorrent"
View Source
const RPCListTorrentStatus = RPCName + ".SwarmStatus"
View Source
const RPCListTorrents = RPCName + ".ListTorrents"
View Source
const RPCName = "XD"
View Source
const RPCPath = "/ecksdee/api"
View Source
const RPCSetPieceWindow = RPCName + ".SetPieceWindow"
View Source
const RPCSwarmCount = RPCName + ".SwarmCount"
View Source
const RPCTorrentStatus = RPCName + ".TorrentStatus"
View Source
const TorrentChangeDelete = "delete"
View Source
const TorrentChangeRemove = "remove"
View Source
const TorrentChangeStart = "start"
View Source
const TorrentChangeStop = "stop"

Variables

View Source
var ErrInvalidAction = errors.New("invalid torrent action")
View Source
var ErrNoTorrent = errors.New("no such torrent")

Functions

This section is empty.

Types

type AddTorrentRequest

type AddTorrentRequest struct {
	BaseRequest
	URL string `json:"url"`
}

func (*AddTorrentRequest) MarshalJSON

func (atr *AddTorrentRequest) MarshalJSON() (data []byte, err error)

func (*AddTorrentRequest) ProcessRequest

func (atr *AddTorrentRequest) ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)

type BaseRequest

type BaseRequest struct {
	Swarm string `json:"-"`
}

type ChangeTorrentRequest

type ChangeTorrentRequest struct {
	BaseRequest
	Infohash string `json:"infohash"`
	Action   string `json:"action"`
}

func (*ChangeTorrentRequest) MarshalJSON

func (r *ChangeTorrentRequest) MarshalJSON() (data []byte, err error)

func (*ChangeTorrentRequest) ProcessRequest

func (r *ChangeTorrentRequest) ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)

type Client

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

func NewClient

func NewClient(url string, swarmno int) *Client

func (*Client) AddTorrent

func (cl *Client) AddTorrent(url string) (err error)

func (*Client) DeleteTorrent

func (cl *Client) DeleteTorrent(ih string) error

func (*Client) GetSwarmStatus

func (cl *Client) GetSwarmStatus() (status swarm.SwarmStatus, err error)

func (*Client) ListTorrents

func (cl *Client) ListTorrents() (torrents swarm.TorrentsList, err error)

func (*Client) RemoveTorrent

func (cl *Client) RemoveTorrent(ih string) error

func (*Client) SetPieceWindow

func (cl *Client) SetPieceWindow(n int) (err error)

func (*Client) StartTorrent

func (cl *Client) StartTorrent(ih string) error

func (*Client) StopTorrent

func (cl *Client) StopTorrent(ih string) error

func (*Client) SwarmStatus

func (cl *Client) SwarmStatus(ih string) (st swarm.TorrentStatus, err error)

type ListTorrentStatusRequest

type ListTorrentStatusRequest struct {
	BaseRequest
}

func (*ListTorrentStatusRequest) MarshalJSON

func (req *ListTorrentStatusRequest) MarshalJSON() (data []byte, err error)

func (*ListTorrentStatusRequest) ProcessRequest

func (req *ListTorrentStatusRequest) ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)

type ListTorrentsRequest

type ListTorrentsRequest struct {
	BaseRequest
}

func (*ListTorrentsRequest) MarshalJSON

func (ltr *ListTorrentsRequest) MarshalJSON() (data []byte, err error)

func (*ListTorrentsRequest) ProcessRequest

func (ltr *ListTorrentsRequest) ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)

type Request

type Request interface {
	// handle request on server
	ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)
	// convert request to json
	MarshalJSON() ([]byte, error)
}

type ResponseWriter

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

func (*ResponseWriter) Return

func (rw *ResponseWriter) Return(obj interface{})

func (*ResponseWriter) SendError

func (rw *ResponseWriter) SendError(msg string)

func (*ResponseWriter) SendJSON

func (rw *ResponseWriter) SendJSON(obj interface{})

type Server

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

Bittorrent Swarm RPC Handler

func NewServer

func NewServer(sw []*swarm.Swarm, host string) *Server

func (*Server) ServeHTTP

func (r *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

type SetPieceWindowRequest

type SetPieceWindowRequest struct {
	BaseRequest
	N int `json:"n"`
}

func (*SetPieceWindowRequest) MarshalJSON

func (r *SetPieceWindowRequest) MarshalJSON() (data []byte, err error)

func (*SetPieceWindowRequest) ProcessRequest

func (r *SetPieceWindowRequest) ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)

type SwarmCountRequest

type SwarmCountRequest struct {
	BaseRequest
	N int
}

func (*SwarmCountRequest) MarshalJSON

func (scr *SwarmCountRequest) MarshalJSON() (data []byte, err error)

func (*SwarmCountRequest) ProcessRequest

func (scr *SwarmCountRequest) ProcessRequest(_ *swarm.Swarm, w *ResponseWriter)

type TorrentStatusRequest

type TorrentStatusRequest struct {
	BaseRequest
	Infohash string `json:"infohash"`
}

func (*TorrentStatusRequest) MarshalJSON

func (r *TorrentStatusRequest) MarshalJSON() (data []byte, err error)

func (*TorrentStatusRequest) ProcessRequest

func (r *TorrentStatusRequest) ProcessRequest(sw *swarm.Swarm, w *ResponseWriter)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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