● Notice //GitHub (@shehzade) is temporarily suspended pending an automated false-positive review. All tools are hosted on this Code Mirror and available on request (contact); GitHub links will return once reinstated.
PUBLIC MIRRORGo v1.0

Multi-protocol network egress assessment and DLP verification framework featuring automated L4 sweeps, corporate proxy traversal, and covert protocol smuggling across 20+ channels.

$ git clone https://shehzade.io/repos/contraband.git Copy
Source ZIP (1.93 MB)
Code 174 Commits 1
contraband / pkg / server / state.go
← Back to directory
56 lines · 1.8 KB
Raw
1package server
2
3import (
4 "time"
5
6 "github.com/shehzade/contraband/pkg/common"
7 "github.com/shehzade/contraband/pkg/server/state"
8)
9
10var (
11 ErrLedgerClosed = state.ErrLedgerClosed
12 ErrSessionNotFound = state.ErrSessionNotFound
13 ErrProbeNotFound = state.ErrProbeNotFound
14 ErrInvalidChunk = state.ErrInvalidChunk
15 ErrHashMismatch = state.ErrHashMismatch
16 ErrSessionIncomplete = state.ErrSessionIncomplete
17)
18
19type Ledger = state.Ledger
20type LedgerObserver = state.LedgerObserver
21type MemoryLedger = state.MemoryLedger
22type SQLiteLedger = state.SQLiteLedger
23
24// NewLedger creates a polymorphic Ledger instance. If dbPath is empty or ":memory:",
25// it initializes a fast in-memory ledger. Otherwise, it opens a pure-Go SQLite ledger.
26func NewLedger(dbPath string) (Ledger, error) {
27 return state.NewLedger(dbPath)
28}
29
30// NewMemoryLedger initializes a fresh in-memory ledger.
31func NewMemoryLedger() *MemoryLedger {
32 return state.NewMemoryLedger()
33}
34
35// NewSQLiteLedger opens or creates a SQLite database at the specified path.
36func NewSQLiteLedger(dbPath string) (*SQLiteLedger, error) {
37 return state.NewSQLiteLedger(dbPath)
38}
39
40// CloneSession creates a deep copy of a Session struct to prevent data races.
41func CloneSession(s *common.Session) *common.Session {
42 return state.CloneSession(s)
43}
44
45type ReassemblyResult = state.ReassemblyResult
46
47// ReassembleChunks validates contiguous sequences, constructs the full binary payload,
48// computes the rolling SHA-256 hash, and performs cryptographic verification.
49func ReassembleChunks(chunks map[uint32][]byte, total uint32, expectedHash string) state.ReassemblyResult {
50 return state.ReassembleChunks(chunks, total, expectedHash)
51}
52
53// FormatTimeMS returns the duration formatted in milliseconds.
54func FormatTimeMS(d time.Duration) float64 {
55 return state.FormatTimeMS(d)
56}