Documentation
¶
Overview ¶
Package container reads the link-container files a download manager is expected to open: a plain list of links, and the encrypted formats the scene has used for twenty years — DLC, CCF and RSDF.
Only the plain formats are decoded here, and that is a deliberate line rather than a gap. A .dlc cannot be opened offline by anyone: the key lives with a service that hands it out to registered clients, which is why no open client generates or decrypts one on its own. Rather than borrow somebody else's application key and pretend to be their client, KnightLoader hands the container to the headless JDownloader it already ships as its catch-all backend, which has its own key and does this legitimately.
So this package answers two questions and refuses to guess at a third: what kind of container is this, and — when it is a plain one — which links are inside it. For an encrypted one it returns ErrNeedsBackend, having first checked that the file really is what its name claims, so the caller can say "this needs the JDownloader backend, which is not configured" instead of "something went wrong".
Index ¶
Constants ¶
const MaxBytes = 8 << 20
maxBytes caps what will be read as a container. Link lists and containers are kilobytes; a hundred megabytes of anything is either a mistake or an attempt to make the server allocate it, and neither deserves the memory.
Variables ¶
var ErrEmpty = errors.New("no links in this file")
ErrEmpty is a container with nothing usable in it. Kept separate from a parse failure because "you dropped an empty file" and "this file is not what it claims to be" are different mistakes with different fixes.
var ErrNeedsBackend = errors.New("this container is encrypted and has to be opened by the JDownloader backend")
ErrNeedsBackend means the container is real and well-formed but encrypted, so a backend holding the key has to open it. The caller is expected to hand the bytes to that backend rather than to report a failure: this is not a broken file, it is a file we deliberately do not decrypt ourselves.
Functions ¶
func Links ¶
Links returns the links in a plain container. For an encrypted one it returns ErrNeedsBackend, and for anything unrecognised an error naming what was actually seen — a caller that logs "unsupported container" without saying what it looked at leaves the user with nothing to act on.
func ValidateDLC ¶
ValidateDLC checks that a file really is a DLC before anything is done with it. The point is the error message: a truncated download, an HTML error page saved with a .dlc name, or a file the browser gzipped are all common, and each produces a different, useless failure much later — inside a backend, or in a service request — unless it is caught here.
Types ¶
type Kind ¶
type Kind string
Kind is the container format.
const ( // KindText is a plain list of links, one per line — the format every // forum post and every "links.txt" in a zip actually uses. KindText Kind = "text" KindDLC Kind = "dlc" KindCCF Kind = "ccf" KindRSDF Kind = "rsdf" // KindUnknown is a file we should not pretend to understand. KindUnknown Kind = "unknown" )