effigies / BitTornado

UNMAINTAINED - John Hoffman's fork of the original bittorrent
Other
150 stars 44 forks source link

BF: Ignore bad announce lists and HTTP seed lists #37

Closed effigies closed 8 years ago

effigies commented 8 years ago

Turned out btreannounce wasn't working correctly, so fix that in the process.

Perhaps we should warn when changing MetaInfo?

Another alternative is to update TypedList to simply ignore empty strings, which has the dubious advantage of not fixing broken metafiles on resave.

Closes #36.

effigies commented 8 years ago

Updated SplitList to permit silent rejection of empty elements, which makes sense in these cases. It also works for announce-list, as [['']] reduces by this rule to [[]], which reduces to [], so any of these possible representations of an empty announce-list will be ignored.

So we end up in the following situation:

  1. AnnounceList(x) = [] for the following values of x: "", [], [""], [[]], [[""]].
  2. A MetaInfo that is created with an empty announce-list will remove it immediately, so it won't be saved. This includes a MetaInfo that is read from a file, so malformed .torrent files won't cause problems when run, and will be fixed if re-saved.
  3. A MetaInfo that has an empty announce-list inserted will represent it as []. {'announce-list': []} has a bencoding value of d13:announce-listlee. This will be written, wasting 18 bytes, but an empty list shouldn't cause programs trouble.

This seems to resolve the issues in #36, namely passing '' to Announce() and creating .torrent files with empty fields.