Commit f668c1eb authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

transparent proxy module

fixes #1582
parent bcddde58
--[[
Transparent proxy module for Alpine Wall
Copyright (C) 2012-2013 Kaarle Ritvanen
Licensed under the terms of GPL2
]]--
module(..., package.seeall)
local class = require('awall.model').class
local combinations = require('awall.optfrag').combinations
local util = require('awall.util')
local MarkRule = require('awall').loadclass('mark')
local TProxyRule = class(MarkRule)
function TProxyRule:target()
if not self['to-port'] then self:error('Proxy port not specified') end
return 'TPROXY --tproxy-mark '..self.mark..' --on-port '..self['to-port']
end
function TProxyRule:mangleoptfrag(ofrag)
local dof = util.copy(ofrag)
dof.target = nil
local res = combinations(
{dof},
{{opts='-m socket', target=self:newchain('divert')}}
)
table.insert(res, ofrag)
return res
end
function TProxyRule:extraoptfrags()
return combinations(
{{chain=self:newchain('divert')}},
{{target=MarkRule.target(self)}, {target='ACCEPT'}}
)
end
export = {tproxy={class=TProxyRule, before={'clamp-mss', '%mark-rt'}}}
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