Through an instance of this class, you have complete control over
your firewall.
Methods
|
|
|
|
__init__
|
__init__ (
self,
firewallBrand=None,
substitutionDict={},
)
Return an instance of the Firewall class.
Initialize a Firewall object.
- firewallBrand
a string or a list of strings amongst
which the firewall will be selected.
- substitutionDict
the dictionary used to substitute some
predefined strings in XML files.
|
|
__repr__
|
__repr__ ( self )
Return the representation for a Firewall object.
|
|
_create
|
_create (
self,
action='append',
pos='-1',
target='drop',
chain='input',
source='0.0.0.0/0.0.0.0',
destination='0.0.0.0/0.0.0.0',
interface='',
proto='',
sport='',
dport='',
log=0,
)
Create a set of rules with the given parameters.
By default the chain is input and the target is drop .
|
|
_loadFirewall
|
_loadFirewall ( self, brand=None )
Detect the firewall, and import related modules.
Exceptions
|
|
DetectFirewallError, 'unable to detect the firewall'
|
|
|
_parseXMLFile
|
_parseXMLFile ( self, fname )
Parse a XML file, return a list of rules.
|
|
_parseXMLString
|
_parseXMLString ( self, s )
Parse a XML string, with substitution of the user supplied
substituition dictionary.
|
|
_runCommand
|
_runCommand ( self, cmd )
Execute a given command.
|
|
_subDictSubstitution
|
_subDictSubstitution ( self, s )
Substitute well known strings in the given XML string with
user supplied data.
|
|
checkRule
|
checkRule ( self, r )
If a rule is actually running, return the rule number,
otherwise -1.
|
|
createNewRules
|
createNewRules (
self,
*args,
*kw,
)
Create new rules with the given parameters.
|
|
forceFirewall
|
forceFirewall ( self, firewallBrand )
Force the use of the given firewall.
|
|
getFirewallName
|
getFirewallName ( self )
Return the name of the running firewall.
|
|
getRuleBuilder
|
getRuleBuilder ( self )
Return the RuleBuilder object used to create new rules.
|
|
getRuleClass
|
getRuleClass ( self )
Return the class that represents a Rule for this firewall.
|
|
getRuleCommands
|
getRuleCommands ( self, l )
Return a list of commands for the given rule or list of rules.
|
|
getSubstitutionDict
|
getSubstitutionDict ( self )
Get the substitution dictionary.
|
|
getXMLRules
|
getXMLRules ( self, l )
Return a list of XML strings for the given rule or list of rules.
|
|
isForced
|
isForced ( self )
Return true if the used firewall was forced.
|
|
listChains
|
listChains ( self )
Return the list of chains available for this firewall.
|
|
listCommandRules
|
listCommandRules ( self, chain )
Return a list of commands for the given chain.
|
|
listRules
|
listRules ( self, chain )
Return the list of rules in the given chain.
|
|
listXMLRules
|
listXMLRules ( self, chain )
Return a list of XML strings; one for every running rule.
|
|
newRulesFromXMLFile
|
newRulesFromXMLFile ( self, fileName )
Parse XML file.
Parse a XML file, and return a list of rules.
- fileName
the name of the file to parse.
|
|
newRulesFromXMLString
|
newRulesFromXMLString ( self, s )
New rules from XML strings.
Parse a XML string and return a list of rules.
|
|
runNewRules
|
runNewRules (
self,
*args,
*kw,
)
Create and run new rules with the given parameters.
|
|
runRules
|
runRules ( self, l )
Execute a given rule or list of rules.
|
|
runXMLFile
|
runXMLFile ( self, fileName )
Parse an XML file and run the resulting set of rules.
|
|
runXMLString
|
runXMLString ( self, s )
Parse an XML string and run the resulting set of rules.
|
|
setSubstitutionDict
|
setSubstitutionDict ( self, substitutionDict )
Set the substitution dictionary.
|