// Add DHT nodes URLs for trackerless mode
func (b *Builder) AddDhtNodes(group []string) {
- b.node_list = append(b.node_list, group)
+ b.node_list = append(b.node_list, group...)
}
// Sets creation date. The default is time.Now() when the .Build method was
}
}
+func emptyStringsFiltered(ss []string) (ret []string) {
+ for _, s := range ss {
+ if s != "" {
+ ret = append(ret, s)
+ }
+ }
+ return
+}
+
func (b *Builder) check_parameters() error {
// should be at least one file
if len(b.filesmap) == 0 {
// let's clean up the announce_list and node_list
b.announce_list = cleanUpLists(b.announce_list)
- b.node_list = cleanUpLists(b.node_list)
+ b.node_list = emptyStringsFiltered(b.node_list)
if len(b.announce_list) == 0 && len(b.node_list) == 0 {
return errors.New("no announce group or DHT nodes specified")
pieces []byte
private bool
announce_list [][]string
- node_list [][]string
+ node_list []string
creation_date time.Time
comment string
created_by string
Info InfoEx `bencode:"info"`
Announce string `bencode:"announce,omitempty"`
AnnounceList [][]string `bencode:"announce-list,omitempty"`
- Nodes [][]string `bencode:"nodes,omitempty"`
+ Nodes []string `bencode:"nodes,omitempty"`
CreationDate int64 `bencode:"creation date,omitempty"`
Comment string `bencode:"comment,omitempty"`
CreatedBy string `bencode:"created by,omitempty"`
--- /dev/null
+package metainfo
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestNodesListStrings(t *testing.T) {
+ mi, err := LoadFromFile("testdata/trackerless.torrent")
+ require.NoError(t, err)
+ assert.EqualValues(t, []string{
+ "udp://tracker.openbittorrent.com:80",
+ "udp://tracker.openbittorrent.com:80",
+ }, mi.Nodes)
+}
+
+func TestNodesListPairsBEP5(t *testing.T) {
+}
-d7:comment19:This is just a test10:created by12:Johnny Bravo13:creation datei1430648794e8:encoding5:UTF-84:infod6:lengthi1128e4:name12:testfile.bin12:piece lengthi32768e6:pieces20:Õ\88ë =\91U\8cäiÎ^æ °Eâ?ÇÒe5:nodesll35:udp://tracker.openbittorrent.com:8035:udp://tracker.openbittorrent.com:80eee
\ No newline at end of file
+d7:comment19:This is just a test10:created by12:Johnny Bravo13:creation datei1430648794e8:encoding5:UTF-84:infod6:lengthi1128e4:name12:testfile.bin12:piece lengthi32768e6:pieces20:Õ\88ë =\91U\8cäiÎ^æ °Eâ?ÇÒe5:nodesl35:udp://tracker.openbittorrent.com:8035:udp://tracker.openbittorrent.com:80ee