FedP2P/metainfo/urllist.go

26 lines
401 B
Go
Raw Normal View History

package metainfo
import (
"github.com/anacrolix/torrent/bencode"
)
type UrlList []string
2021-11-08 11:47:01 +08:00
var _ bencode.Unmarshaler = (*UrlList)(nil)
func (me *UrlList) UnmarshalBencode(b []byte) error {
if len(b) == 0 {
return nil
}
if b[0] == 'l' {
var l []string
err := bencode.Unmarshal(b, &l)
*me = l
return err
}
var s string
err := bencode.Unmarshal(b, &s)
*me = []string{s}
return err
}