Commit 27e02c33 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

TTL adjustment rules

parent 4ff16c68
......@@ -472,6 +472,17 @@ attribute named **classify**, must specify the class using the
**class** attribute. These rules apply to the both directions of the
matching traffic.
#### TTL Adjustment Rules
TTL adjustment rules are used to set the TTL field of the IPv4 packets
matching the specified criteria. The TTL adjustment rules are contained
in the top-level list attribute named **ttl** and define an attribute
named **ttl**. If the value is a non-negative integer, the TTL of the
packet is set to the value. If it is a negative integer, the TTL value
is decremented accordingly. The TTL value can be incremented by a
constant by setting the attribute value to a string representing a
positive integer, prepended with the plus sign (**+**).
#### Transparent Proxy Rules
Transparent proxy rules divert the matching packets to a local proxy
......
--[[
TTL adjustment module for Alpine Wall
Copyright (C) 2012-2016 Kaarle Ritvanen
See LICENSE file for license details
]]--
local model = require('awall.model')
local TTLRule = model.class(model.Rule)
function TTLRule:trules()
local res = {}
for _, rule in ipairs(TTLRule.super(self):trules()) do
if rule.family == 'inet' then table.insert(res, rule) end
end
return res
end
function TTLRule:table() return 'mangle' end
function TTLRule:target()
if not self.ttl then self:error('TTL not specified') end
if type(self.ttl) == 'string' then
if self.ttl:sub(1, 1) == '+' then
return 'TTL --ttl-inc '..self.ttl:sub(2, -1)
else self.ttl = tonumber(self.ttl) end
end
if type(self.ttl) ~= 'number' then
self:error('Invalid TTL specification')
end
return 'TTL --ttl-'..(self.ttl < 0 and 'dec' or 'set')..' '..
math.abs(self.ttl)
end
return {export={ttl={class=TTLRule}}}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment