Documentation
¶
Index ¶
- func DOSColorToANSI(dosAttr int) (fg int, bg int, bold bool)
- func DefaultArchiveExtensions() []string
- func RunZipLabView(s ssh.Session, terminal *term.Terminal, filePath string, filename string, ...)
- type AddCommentConfig
- type ArchiveType
- type Config
- type IncludeFileConfig
- type NFOConfig
- type NFOEntry
- type PipelineResult
- type Processor
- func (p *Processor) DisplayPipeline(w io.Writer, nfo *NFOConfig, ansiContent []byte, archivePath string) PipelineResult
- func (p *Processor) RunPipeline(archivePath string, statusFn StatusCallback) PipelineResult
- func (p *Processor) StepAddComment(archivePath string) error
- func (p *Processor) StepExtract(archivePath string) (string, error)
- func (p *Processor) StepIncludeFile(archivePath string) error
- func (p *Processor) StepRemoveAdsAndDIZ(workDir, archivePath string) (string, error)
- func (p *Processor) StepTestIntegrity(archivePath string) error
- func (p *Processor) StepVirusScan(workDir string) error
- type RemoveAdsConfig
- type Status
- type StatusCallback
- type StepConfig
- type StepNumber
- type StepResult
- type StepsConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DOSColorToANSI ¶
DOSColorToANSI converts a DOS color attribute (bg*16 + fg) to ANSI components. Returns foreground color (0-15), background color (0-7), and whether bold is needed.
func DefaultArchiveExtensions ¶
func DefaultArchiveExtensions() []string
DefaultArchiveExtensions returns the list of archive extensions from the default config.
func RunZipLabView ¶
func RunZipLabView(s ssh.Session, terminal *term.Terminal, filePath string, filename string, outputMode ansi.OutputMode)
RunZipLabView presents an interactive archive viewer that lets the user browse entries and extract individual files via ZMODEM.
Types ¶
type AddCommentConfig ¶
type AddCommentConfig struct {
StepConfig
CommentFile string `json:"commentFile,omitempty"` // Path to ZCOMMENT.TXT
}
AddCommentConfig extends StepConfig with a comment file.
type ArchiveType ¶
type ArchiveType struct {
Extension string `json:"extension"` // e.g., ".zip", ".rar"
Native bool `json:"native"` // true = handled by Go stdlib
ExtractCommand string `json:"extractCommand,omitempty"` // External extract command
ExtractArgs []string `json:"extractArgs,omitempty"` // Extract arguments
TestCommand string `json:"testCommand,omitempty"` // Integrity test command
TestArgs []string `json:"testArgs,omitempty"` // Test arguments
AddCommand string `json:"addCommand,omitempty"` // Add file command
AddArgs []string `json:"addArgs,omitempty"` // Add arguments
CommentCommand string `json:"commentCommand,omitempty"` // Add comment command
CommentArgs []string `json:"commentArgs,omitempty"` // Comment arguments
}
ArchiveType defines how to handle a specific archive format.
type Config ¶
type Config struct {
Enabled bool `json:"enabled"`
RunOnUpload bool `json:"runOnUpload"`
ScanFailBehavior string `json:"scanFailBehavior"` // "delete" or "quarantine"
QuarantinePath string `json:"quarantinePath,omitempty"`
Steps StepsConfig `json:"steps"`
ArchiveTypes []ArchiveType `json:"archiveTypes"`
}
Config holds the complete ZipLab configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
func LoadConfig ¶
LoadConfig loads ZipLab configuration from ziplab.json in the given config directory. Returns defaults if the file doesn't exist.
func (*Config) GetArchiveType ¶
func (c *Config) GetArchiveType(filename string) (ArchiveType, bool)
GetArchiveType returns the ArchiveType config for a given filename.
func (*Config) IsArchiveSupported ¶
IsArchiveSupported checks if a filename matches a configured archive type.
type IncludeFileConfig ¶
type IncludeFileConfig struct {
StepConfig
FilePath string `json:"filePath,omitempty"` // Path to BBS.AD or similar
}
IncludeFileConfig extends StepConfig with the file to include.
type NFOConfig ¶
NFOConfig holds all parsed entries from ZIPLAB.NFO.
func ParseNFO ¶
ParseNFO reads and parses a ZIPLAB.NFO file. Format: {step}{status} = X,Y,NormalColor,HiColor,DisplayChars
func (*NFOConfig) BuildStatusSequence ¶
BuildStatusSequence generates an ANSI escape sequence that positions the cursor and renders the status indicator for a given step+status.
type NFOEntry ¶
type NFOEntry struct {
Step int
Status Status
Col int // X position (1-based)
Row int // Y position (1-based)
NormalColor int // DOS color attribute (bg*16 + fg)
HiColor int // DOS highlight color attribute
DisplayChars string // Characters to display (e.g., "███")
}
NFOEntry holds the parsed display coordinates and colors for one step+status.
type PipelineResult ¶
type PipelineResult struct {
Success bool
Description string // Extracted FILE_ID.DIZ content, if found
StepResults []StepResult
Error error
}
PipelineResult holds the outcome of a ZipLab pipeline run.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor runs the ZipLab pipeline steps against an uploaded archive.
func NewProcessor ¶
NewProcessor creates a new ZipLab processor.
func (*Processor) DisplayPipeline ¶
func (p *Processor) DisplayPipeline(w io.Writer, nfo *NFOConfig, ansiContent []byte, archivePath string) PipelineResult
DisplayPipeline shows the ZIPLAB.ANS screen and runs the pipeline, updating NFO status indicators in real time. This is the main entry point for the visual ZipLab experience.
func (*Processor) RunPipeline ¶
func (p *Processor) RunPipeline(archivePath string, statusFn StatusCallback) PipelineResult
RunPipeline executes the full ZipLab processing pipeline on an archive file. The statusFn callback is invoked before/after each step to update the display. Returns a PipelineResult with the outcome and any extracted FILE_ID.DIZ.
func (*Processor) StepAddComment ¶
StepAddComment (Step 6) adds a ZIP comment from the configured comment file.
func (*Processor) StepExtract ¶
StepExtract (Step 2) extracts the archive to a temporary work directory. Returns the path to the work directory.
func (*Processor) StepIncludeFile ¶
StepIncludeFile (Step 7) adds a file (e.g., BBS.AD) into the archive.
func (*Processor) StepRemoveAdsAndDIZ ¶
StepRemoveAdsAndDIZ (Step 5) extracts FILE_ID.DIZ content and removes unwanted files matching patterns from REMOVE.TXT. workDir is used to find FILE_ID.DIZ; archivePath is the ZIP to strip ad files from.
func (*Processor) StepTestIntegrity ¶
StepTestIntegrity (Step 1) tests the archive for corruption. For native ZIP, it opens and reads every file entry. For external formats, it runs the configured test command.
func (*Processor) StepVirusScan ¶
StepVirusScan (Step 3) runs a configurable external virus scanner.
type RemoveAdsConfig ¶
type RemoveAdsConfig struct {
StepConfig
PatternsFile string `json:"patternsFile,omitempty"` // Path to REMOVE.TXT
}
RemoveAdsConfig extends StepConfig with a patterns file.
type StatusCallback ¶
type StatusCallback func(step StepNumber, status Status)
StatusCallback is called when a step's status changes, allowing the caller to update the ANSI display in real time.
type StepConfig ¶
type StepConfig struct {
Enabled bool `json:"enabled"`
Command string `json:"command,omitempty"` // External command path
Args []string `json:"args,omitempty"` // Command arguments (supports {FILE}, {WORKDIR} placeholders)
Timeout int `json:"timeoutSeconds,omitempty"` // Timeout in seconds (0 = default 60s)
}
StepConfig holds the configuration for an individual ZipLab pipeline step.
type StepNumber ¶
type StepNumber int
StepNumber maps to the original ZipLab step numbering (1-7, skip 4).
const ( StepIntegrity StepNumber = 1 StepExtract StepNumber = 2 StepVirusScan StepNumber = 3 StepRemoveAds StepNumber = 5 StepAddComment StepNumber = 6 StepInclude StepNumber = 7 )
type StepResult ¶
type StepResult struct {
Step StepNumber
Name string
Status Status // StatusDoing, StatusPass, StatusFail
Elapsed time.Duration
Error error
}
StepResult records the outcome of a single pipeline step.
type StepsConfig ¶
type StepsConfig struct {
TestIntegrity StepConfig `json:"testIntegrity"`
ExtractToTemp StepConfig `json:"extractToTemp"`
VirusScan StepConfig `json:"virusScan"`
RemoveAds RemoveAdsConfig `json:"removeAds"`
AddComment AddCommentConfig `json:"addComment"`
IncludeFile IncludeFileConfig `json:"includeFile"`
}
StepsConfig holds all pipeline step configurations.