no need to convert bytes to string

This commit is contained in:
Michał Adamski 2020-12-08 14:36:51 +01:00
parent 1fafa13c95
commit 71f3eead65

View file

@ -36,8 +36,8 @@ type AnnounceResponse struct {
Interval int `bencode:"interval"` Interval int `bencode:"interval"`
Complete int `bencode:"complete"` Complete int `bencode:"complete"`
Incomplete int `bencode:"incomplete"` Incomplete int `bencode:"incomplete"`
Peers string `bencode:"peers"` Peers []byte `bencode:"peers"`
PeersIPv6 string `bencode:"peers_ipv6"` PeersIPv6 []byte `bencode:"peers_ipv6"`
} }
func announce(c *gin.Context) { func announce(c *gin.Context) {
@ -68,8 +68,8 @@ func announce(c *gin.Context) {
Interval: interval, Interval: interval,
Complete: numSeeders, Complete: numSeeders,
Incomplete: numLeechers, Incomplete: numLeechers,
Peers: string(peersIPv4), Peers: peersIPv4,
PeersIPv6: string(peersIPv6), PeersIPv6: peersIPv6,
} }
if err := bencode.Marshal(c.Writer, resp); err != nil { if err := bencode.Marshal(c.Writer, resp); err != nil {
c.Error(err) c.Error(err)