-
Notifications
You must be signed in to change notification settings - Fork 0
/
announce.go
36 lines (30 loc) · 794 Bytes
/
announce.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package config
import (
"fmt"
"net/url"
)
// DirectAnnounce configures the target indexers that advertisement announce
// messages are sent directly to via HTTP.
type DirectAnnounce struct {
// URLs is a list of indexer URLs to send HTTP announce messages to.
URLs []string
}
// NewDirectAnnounce returns DirectAnnounce with values set to their defaults.
func NewDirectAnnounce() DirectAnnounce {
return DirectAnnounce{}
}
// ParseURLs returns parsed URLs.
func (d DirectAnnounce) ParseURLs() ([]*url.URL, error) {
if len(d.URLs) == 0 {
return nil, nil
}
urls := make([]*url.URL, len(d.URLs))
var err error
for i, u := range d.URLs {
urls[i], err = url.Parse(u)
if err != nil {
return nil, fmt.Errorf("bad DirectAnnounce url %q: %w", u, err)
}
}
return urls, nil
}