status-go/vendor/github.com/anacrolix/torrent/tracker/udp/options.go

25 lines
366 B
Go
Raw Normal View History

2022-03-10 09:44:48 +00:00
package udp
import (
"math"
)
type Options struct {
RequestUri string
}
func (opts Options) Encode() (ret []byte) {
for {
l := len(opts.RequestUri)
if l == 0 {
break
}
if l > math.MaxUint8 {
l = math.MaxUint8
}
ret = append(append(ret, optionTypeURLData, byte(l)), opts.RequestUri[:l]...)
opts.RequestUri = opts.RequestUri[l:]
}
return
}