par2gen

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package par2gen builds minimal valid PAR2 index files in memory for use in tests that exercise PAR2-based filename deobfuscation.

Only FileDesc packets are emitted — enough for the par2.GetFileDescriptors path that reconstructs real filenames from obfuscated Usenet releases. No recovery blocks, IFSC, or Main packets are generated; the par2 reader used by altmount ignores those packet types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(entries ...FileEntry) []byte

Build returns the binary content of a minimal PAR2 index containing one FileDesc packet per entry. The result can be served directly from fakepool as the payload for a PAR2 index segment.

func PacketTypeFileDescT

func PacketTypeFileDescT() [16]byte

func PacketTypeIFSCT

func PacketTypeIFSCT() [16]byte

func PacketTypePARMain

func PacketTypePARMain() [16]byte

Packet type constants, duplicated from the par2 parser package to avoid a testsupport -> production import in this direction (the parser tests import par2gen, so par2gen importing the parser would be a cycle).

func PacketTypeRecvSlicT

func PacketTypeRecvSlicT() [16]byte

func VandermondeBase

func VandermondeBase(j int) gf2p16.T

VandermondeBase returns the j-th PAR2 Vandermonde generator: 2^i in GF(2^16), skipping exponents divisible by 3, 5, 17 or 257 (elements whose order is below 65535). Grows a cached table on demand.

Types

type FileEntry

type FileEntry struct {
	// Name is the real (unobfuscated) filename.
	Name string
	// Content is the file payload. The first 16 KB (zero-padded to exactly
	// 16384 bytes) determines Hash16k, which is how the importer matches
	// obfuscated files to their real names.
	Content []byte
}

FileEntry describes one file that should appear in the generated PAR2 index.

type FullSet

type FullSet struct {
	Index   []byte
	Volumes [][]byte
}

FullSet is a complete, spec-valid PAR2 set: an index file (Main + FileDesc + IFSC packets) and one volume file per recovery slice (a RecvSlic packet).

func BuildFull

func BuildFull(sliceSize int, entries []FileEntry, numRecovery int) FullSet

BuildFull produces a spec-valid PAR2 set over the given files. Recovery data is computed with the PAR2 Vandermonde construction over GF(2^16), independently of the production solver's incremental fold path, so the two can validate each other in round-trip tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL