Merge pull request #164 from mrd0ll4r/http-smallfix
http: fixed bencoding, compact, added log
This commit is contained in:
commit
d453bf7a75
3 changed files with 6 additions and 3 deletions
|
@ -34,7 +34,7 @@ func announceRequest(r *http.Request, cfg *httpConfig) (*chihaya.AnnounceRequest
|
|||
}
|
||||
|
||||
compactStr, _ := q.String("compact")
|
||||
request.Compact = compactStr != "0"
|
||||
request.Compact = compactStr != "" && compactStr != "0"
|
||||
|
||||
infoHashes := q.InfoHashes()
|
||||
if len(infoHashes) < 1 {
|
||||
|
|
|
@ -112,7 +112,10 @@ func (s *httpServer) serveAnnounce(w http.ResponseWriter, r *http.Request, p htt
|
|||
return
|
||||
}
|
||||
|
||||
writeAnnounceResponse(w, resp)
|
||||
err = writeAnnounceResponse(w, resp)
|
||||
if err != nil {
|
||||
log.Println("error serializing response", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *httpServer) serveScrape(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
||||
|
|
|
@ -91,7 +91,7 @@ func compact(peer chihaya.Peer) (buf []byte) {
|
|||
|
||||
func dict(peer chihaya.Peer) bencode.Dict {
|
||||
return bencode.Dict{
|
||||
"peer id": peer.ID,
|
||||
"peer id": string(peer.ID),
|
||||
"ip": peer.IP.String(),
|
||||
"port": peer.Port,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue