Put DNS rule higher up in chain

This commit is contained in:
Armen Boursalian 2018-08-23 22:44:48 -07:00
parent d206a6430d
commit bb2ca3887c

View file

@ -32,6 +32,27 @@ func RunRule(enable bool, rule []string) (err error) {
// INPUT --protocol udp --sport 53 -j NFQUEUE --queue-num 0 --queue-bypass
func QueueDNSResponses(enable bool, queueNum int) (err error) {
// If enable, we're going to insert as #1, not append
if enable {
// FIXME: this is basically copy/paste of RunRule() above b/c we can't
// shoehorn "-I" with the boolean 'enable' switch
rule := []string{
"-I",
"INPUT",
"1",
"--protocol", "udp",
"--sport", "53",
"-j", "NFQUEUE",
"--queue-num", fmt.Sprintf("%d", queueNum),
"--queue-bypass",
}
lock.Lock()
defer lock.Unlock()
_, err := core.Exec("iptables", rule)
return err
}
// Otherwise, it's going to be disable
return RunRule(enable, []string{
"INPUT",
"--protocol", "udp",