github.com/anacrolix/torrent@v1.61.0/tracker/udp/options.go (about) 1 package udp 2 3 import ( 4 "math" 5 ) 6 7 type Options struct { 8 RequestUri string 9 } 10 11 func (opts Options) Encode() (ret []byte) { 12 for { 13 l := len(opts.RequestUri) 14 if l == 0 { 15 break 16 } 17 if l > math.MaxUint8 { 18 l = math.MaxUint8 19 } 20 ret = append(append(ret, optionTypeURLData, byte(l)), opts.RequestUri[:l]...) 21 opts.RequestUri = opts.RequestUri[l:] 22 } 23 return 24 }