commands

package
v0.0.0-...-1f13f73 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInterval = 60 //in seconds
View Source
const DisconnectInterval = time.Minute //in seconds
View Source
const SoftLimit = 5 //in seconds

Variables

This section is empty.

Functions

func Execute

func Execute()

func ValidateReq

func ValidateReq(req AnnounceReq) error

func WriteResp

func WriteResp(w http.ResponseWriter, res interface{}, compact bool)

Types

type AnnounceReq

type AnnounceReq struct {
	InfoHash      []byte
	PeerID        []byte
	RemoteAddr    net.IP
	Port          int
	Event         string
	Uploaded      int64
	Downloaded    int64
	SupportCrypto bool
	Left          int64
	Compact       bool
}

func ParseRequest

func ParseRequest(r *http.Request) (AnnounceReq, error)

type AnnounceReqWithTime

type AnnounceReqWithTime struct {
	AnnounceReq
	UpdatedAt time.Time
}

/announce?compact=1 &downloaded=0 &event="started" &info_hash=D%22%5C%80%F7%FD%12Z%EA%9B%F0%A5z%DA%AF%1F%A4%E1je &left=0 &peer_id=-GT0002-9%EA%FB+%BF%B3%AD%DE%8Ae%D0%B7 &port=53631 &supportcrypto=1 &uploaded=0"

type ErrResponse

type ErrResponse struct {
	FailureReason string `bencode:"failure reason" json:"failure_reason"`
}

type HttpResponse

type HttpResponse struct {
	Interval   int32                    `bencode:"interval" json:"interval"`
	TrackerId  string                   `bencode:"tracker id" json:"tracker_id"`
	Complete   int32                    `bencode:"complete" json:"complete"`
	Incomplete int32                    `bencode:"incomplete" json:"incomplete"`
	Peers      []map[string]interface{} `bencode:"peers" json:"peers"`
}

type Peer

type Peer struct {
	IP     string
	Port   int
	PeerID []byte
}

type ScrapeData

type ScrapeData struct {
	Complete   int32 `bencode:"complete" json:"complete"`
	Downloaded int32 `json:"downloaded" bencode:"downloaded"`
	Incomplete int32 `json:"incomplete" bencode:"incomplete"`
}

type ScrapeResponse

type ScrapeResponse struct {
	Files map[string]*ScrapeData `json:"files" bencode:"files"`
}

type Tracker

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

func (*Tracker) ServeHTTP

func (t *Tracker) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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