server

package
v0.0.0-...-43d8f34 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TestSpoofChannel can be set, causing spoofed packets to go to it rather than a pcap
	TestSpoofChannel chan []byte
)

Functions

func SetupSpoofingSockets

func SetupSpoofingSockets(config Config) error

SetupSpoofingSockets opens a raw pcap socket for sending packets

func SpoofIPv4Message

func SpoofIPv4Message(packet []byte) error

SpoofIPv4Message sends a serialized packet on the raw socket.

func SpoofProbe

func SpoofProbe(ctx context.Context, probe *traas2.Probe, inReplyTo gopacket.Packet, trace *traas2.Trace, withDelay bool)

SpoofProbe will inject the message specified by probe in repsonse to a given TCP packet.

func SpoofTCPMessage

func SpoofTCPMessage(src net.IP, dest net.IP, request *layers.TCP, requestLength uint16, ttl byte, payload []byte, trace *traas2.Trace) error

SpoofTCPMessage constructs and sends a tcp message sent in the same stream as 'request' with a specified payload.

Types

type Config

type Config struct {
	ServePort  uint16      // What port for webServer
	ListenPort uint16      // What port for pcap
	Path       string      // What web path does traas live at
	Root       string      // where is the go code (and static files) for traas
	Device     string      // What network interface is listened to
	Dst        string      // Ethernet address of the gateway network interface
	IPHeader   string      // If client ips should be checked from e.g. an x-forwarded-for header
	TraceFile  string      // file to log traces.
	Debug      bool        // If diagnostic debugging should be enabled
	TraceLog   *log.Logger `json:"-"`
}

Config stores longterm state of how the server behaves

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder is the state of the pcap listener. Use begintrace / endTrace to interact with it, and let it know which packets it's watching for.

func MakeRecorder

func MakeRecorder(netDev string, path string, port uint16, probe *traas2.Probe, debug bool) (*Recorder, error)

MakeRecorder initializes the system / pcap listening thread for a given device.

func (*Recorder) BeginTrace

func (r *Recorder) BeginTrace(to net.IP) *traas2.Trace

BeginTrace initializes a trace on a specific IP. Triggers sending of 302 probes and recording responses.

func (*Recorder) EndTrace

func (r *Recorder) EndTrace(to net.IP)

EndTrace cleans up after an active trace.

func (*Recorder) GetTrace

func (r *Recorder) GetTrace(to net.IP) *traas2.Trace

GetTrace returns the trace if present for a given IP

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server contains the state of the active server

func NewServer

func NewServer(conf Config) *Server

NewServer creates an HTTP server with a given config.

func (*Server) EndHandler

func (s *Server) EndHandler(w http.ResponseWriter, r *http.Request)

EndHandler finishes traces

func (*Server) ErrorHandler

func (s *Server) ErrorHandler(w http.ResponseWriter, r *http.Request)

ErrorHandler prints a standard message when errors are encountered

func (*Server) ProbeHandler

func (s *Server) ProbeHandler(w http.ResponseWriter, r *http.Request)

ProbeHandler waits for probes to be received, then prints state.

func (*Server) Serve

func (s *Server) Serve() error

Serve begins listening for web connections on the port specified in config

func (*Server) StartHandler

func (s *Server) StartHandler(w http.ResponseWriter, r *http.Request)

StartHandler triggers the start of traces.

Jump to

Keyboard shortcuts

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