Categorygithub.com/mikehelmick/go-chaff
modulepackage
0.6.0
Repository: https://github.com/mikehelmick/go-chaff.git
Documentation: pkg.go.dev

# README

Go Chaff Tracker / Generator

GoDoc Go

This package provides the necessary tools to allow for your server to handle chaff (fake) requests from clients. This technique can be used when you want to guard against the fact that clients are connecting to your server is meaningful.

The tracker automatically captures metadata like average request time and response size, with the aim of making a chaff request indistinguishable from a real request. This is useful in situations where someone (e.g. server operator, network peer) should not be able to glean information about the system from requests, their size, or their frequency.

Clients periodically send "chaff" requests. They denote the request is chaff via a header or similar identifier. If one of your goals is to obfuscate server logs, a dedicated URL is not recommended as this will be easily distinguisable in logs.

There are two components:

  • a middleware function that implements tracking
  • an http.Handler that serves the chaff requests

Usage

  1. Option 1 - use a single handler, detect chaff based on a request property like a header. This is most useful when you don't trust the server operator and can have the performance hit of the branching logic in a single handler:

    mux := http.NewServeMux()
    mux.Handle("/", tracker.HandleTrack(chaff.HeaderDetector("X-Chaff"), myHandler))
    

    In this example, requests to / are served normally and the tracker generates heuristics automatically. When a request includes an X-Chaff header, the handler sends a chaff response.

  2. Option 2 - create the tracker on specific routes and provide a dedicated chaff endpoint. This is useful when you trust the server operator, but not the network observer:

    r := mux.NewRouter()
    tracker := chaff.New()
    defer tracker.Close()
    
    mux := http.NewServeMux()
    mux.Handle("/", tracker.Track())
    mux.Handle("/chaff", tracker.HandleChaff())
    

# Functions

No description provided by the author
HeaderDetector is a detector that searches for the header's presence to mark a request as chaff.
New creates a new tracker with the `DefaultCapacity`.
NewJSONResponse creates a new JSON responder Requres a ProduceJSONFn that will be given the random data payload and is responsible for putting it into a struct that can be marshalled as the JSON response.
NewTracker creates a tracker with custom capacity.
The default ProduceJSONFn.
RandomData generates size bytes of random base64 data.
WithMaxLatency puts a cap on the tunnel latency.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

The default JSON object that is returned.
JSONResponder implements the Responder interface and allows you to reply to chaff reqiests with a custom JSON object.
No description provided by the author
Tracker represents the status of a latency and request size tracker.

# Interfaces

No description provided by the author
Responder allows you to extend the chaff library with custom responders.

# Type aliases

No description provided by the author
Option defines a method for applying options when configuring a new tracker.
ProduceJSONFn is a function for producing JSON responses.