Another application for Funkensturm is: delaying packets.
Here we only delay packets with the recursion desired bit (RD)
set, but it can be easily be changed to check for other
properties of a packet, see godoc dns for all elements of
DNS packets.
The configuration is similar as described
here.
Matching pkts with RD bit set
The matching function becomes:
// the only matching we do is on the RD bit
// for incoming packets.
func match(m *dns.Msg, d int) (*dns.Msg, bool) {
// Matching criteria
var ok bool
switch d {
case IN:
// only delay pkts with RD bit
ok = m.MsgHdr.RecursionDesired == true
case OUT:
// nothing
}
// Packet Mangling
switch d {
case IN:
// nothing
case OUT:
// nothing
}
return m, ok
}
Action function
First a delay helper function. As shown here it returns true if
the delay time isn’t reached, and false if a something should be
delayed.