summaryrefslogtreecommitdiff
path: root/manifests/rules/torify/reject_non_tor.pp
blob: 80240ec7eac37105566088caa443249fb9f82972 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
define shorewall::rules::torify::reject_non_tor(
  $user = '-',
  $originaldest = '-',
  $allow_rfc1918 = true
){

  # hash the destination as it may contain slashes
  $originaldest_sha1 = sha1($originaldest)
  $rule = "reject-non-tor-from-${user}-to=${originaldest_sha1}"

  if $originaldest == '-' {
    $originaldest_real = $allow_rfc1918 ? {
      false   => '!127.0.0.1',
      default => '!127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16',
    }
  } else {
    $originaldest_real = $originaldest
  }

  if !defined(Shorewall::Rule["$rule"]) {
    shorewall::rule {
      "$rule":
        source          => '$FW',
        destination     => 'all',
        originaldest    => $originaldest_real,
        user            => $user,
        order           => 120,
        action          => 'REJECT';
    }
  }

}