mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-07 05:31:56 -07:00
Fix invalid time serialization
This commit is contained in:
@@ -3,6 +3,7 @@ package http
|
|||||||
import (
|
import (
|
||||||
"github.com/anacrolix/torrent/bencode"
|
"github.com/anacrolix/torrent/bencode"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/chihaya/chihaya/bittorrent"
|
"github.com/chihaya/chihaya/bittorrent"
|
||||||
"github.com/chihaya/chihaya/pkg/log"
|
"github.com/chihaya/chihaya/pkg/log"
|
||||||
@@ -28,6 +29,14 @@ func WriteError(w http.ResponseWriter, err error) error {
|
|||||||
// WriteAnnounceResponse communicates the results of an Announce to a
|
// WriteAnnounceResponse communicates the results of an Announce to a
|
||||||
// BitTorrent client over HTTP.
|
// BitTorrent client over HTTP.
|
||||||
func WriteAnnounceResponse(w http.ResponseWriter, resp *bittorrent.AnnounceResponse) error {
|
func WriteAnnounceResponse(w http.ResponseWriter, resp *bittorrent.AnnounceResponse) error {
|
||||||
|
if resp.Interval > 0 {
|
||||||
|
resp.Interval /= time.Second
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.Interval > 0 {
|
||||||
|
resp.MinInterval /= time.Second
|
||||||
|
}
|
||||||
|
|
||||||
bdict := strMap{
|
bdict := strMap{
|
||||||
"complete": resp.Complete,
|
"complete": resp.Complete,
|
||||||
"incomplete": resp.Incomplete,
|
"incomplete": resp.Incomplete,
|
||||||
|
|||||||
Reference in New Issue
Block a user