FedP2P/web_seed.go

69 lines
1.1 KiB
Go
Raw Normal View History

2020-05-30 15:52:27 +08:00
package torrent
import (
"net/http"
2020-06-01 16:25:45 +08:00
"github.com/anacrolix/torrent/segments"
"github.com/anacrolix/torrent/webseed"
2020-05-30 15:52:27 +08:00
)
2020-06-01 16:25:45 +08:00
type httpRequestResult struct {
resp *http.Response
err error
}
type requestPart struct {
req *http.Request
e segments.Extent
result chan httpRequestResult
}
type webseedRequest struct {
cancel func()
}
2020-05-30 15:52:27 +08:00
type webSeed struct {
2020-06-01 16:25:45 +08:00
client webseed.Client
peer peer
2020-05-31 11:09:56 +08:00
}
2020-06-01 16:25:45 +08:00
type webseedClientEvent interface{}
type webseedRequestFailed struct {
r request
err error
}
var _ PeerImpl = (*webSeed)(nil)
2020-05-31 11:22:36 +08:00
func (ws *webSeed) PostCancel(r request) {
2020-06-01 16:25:45 +08:00
ws.Cancel(r)
2020-05-30 15:52:27 +08:00
}
2020-05-31 11:22:36 +08:00
func (ws *webSeed) WriteInterested(interested bool) bool {
2020-05-30 15:52:27 +08:00
return true
}
2020-05-31 11:22:36 +08:00
func (ws *webSeed) Cancel(r request) bool {
2020-06-01 16:25:45 +08:00
//panic("implement me")
return true
2020-05-30 15:52:27 +08:00
}
2020-05-31 11:22:36 +08:00
func (ws *webSeed) Request(r request) bool {
2020-06-01 16:25:45 +08:00
ws.client.Request(webseed.RequestSpec{ws.peer.t.requestOffset(r), int64(r.Length)})
return true
2020-05-30 15:52:27 +08:00
}
2020-05-31 11:22:36 +08:00
func (ws *webSeed) ConnectionFlags() string {
2020-05-30 15:52:27 +08:00
return "WS"
}
2020-05-31 11:22:36 +08:00
func (ws *webSeed) Drop() {
2020-05-30 15:52:27 +08:00
}
2020-05-31 11:22:36 +08:00
func (ws *webSeed) UpdateRequests() {
2020-05-30 15:52:27 +08:00
ws.peer.doRequestState()
}
2020-05-31 11:09:56 +08:00
2020-05-31 11:22:36 +08:00
func (ws *webSeed) Close() {}