Part 7 – Putting It All Together (Final Class)
Assemble the full FileTransferServer with configuration, routes, limits, callbacks, and logging.
Goals
Merge features into a cohesive
FileTransferServer.Provide a clean constructor with sensible defaults.
Document public methods and calling conventions.
What You’ll Build
Final class with:
Configurable
file_path,save_dir,direction(download/upload/both).limit,encodedmode, randomizedroute,port.Optional HTML landing page.
on_transfercallback,start()/stop(),__repr__.Logging wired throughout.
Sections
Constructor Design: Parameters, defaults, trade-offs.
Route Wiring: Conditional registration by
direction.Lifecycle: Start thread, shutdown watcher, admin endpoint.
Error Semantics: 400/404/410; when and why.
Security/Hygiene: Bind addresses, exposure window, directory traversal, input sizes.
Operational Recipes: Common patterns (single delivery server; exfil sink; upload receiver).
Milestone: End-to-end test: start → transfer → auto-shutdown → review logs/artifacts.
Exercises
Run with
direction=bothand exercise all endpoints.Swap random route length; verify it in logs and via curl.
Integrate into a PoC skeleton and document the exact steps.
Last updated