def form_addNAT(self, data): form = formal.Form() ifs = [] for i in Utils.getInterfaces(): if i[:3] in ['eth', 'ppp', 'tap', 'tun']: # Only allow tap and eth binds... ifs.append((i, i)) form.addField('dstif', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "External Interface", description = "The interface to which this traffic will be NATed.") form.addField('srcif', formal.String(), formal.widgetFactory(formal.SelectChoice, options = ifs), label = "Source Interface", description = "The interface which will have NAT applied to it") form.addField('destip', formal.String(), label = "Destination IP", description = ["Destination IP or network (Leave blank for ANY). ", "This is the destination network you would like to NAT to"]) form.addField('srcip', formal.String(), label = "Source IP", description = ["Source IP or network (Leave blank for ANY). ", "This is the source network you would like to NAT from."]) form.addField('natip', formal.String(), label = "NAT IP", description = ["The IP address that you would like to NAT the connections as.", "Leave this blank to let the firewall decide based on the interface configuration."]) form.addField('proto', formal.String(), formal.widgetFactory(formal.SelectChoice, options = self.protocols), label = "Protocol", description = "Protocol to NAT") form.addField('srcport', formal.String(strip=True, validators=[PageHelpers.PortRangeValidator()]), label = "Source port", description = "TCP/UDP port to NAT.") form.addAction(self.submitNAT) return form
def form_forwardPort(self, data): form = formal.Form() form.addField( 'szone', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options=self.getZones()), label="Source Zone", description="Source zone from which this rule will catch packets. " ) form.addField( 'dzone', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options=self.getZones()), label="Destination Zone", description= "Destination Zone to which this rule will forward packets.") form.addField( 'port', formal.String(strip=True, validators=[PageHelpers.PortRangeValidator()]), label="Port", description= "TCP/UDP port to forward. Blank for protocol forward (like PPTP). Use separate ranges with a colon." ) form.addField('destip', formal.String(required=True, strip=True, validators=[PageHelpers.IPValidator()]), label="Forward To", description="Destination IP address to forward to") form.addField( 'dstport', formal.String(strip=True, validators=[PageHelpers.PortValidator()]), label="Forward To:Port", description="TCP/UDP port to forward to. Blank for the same port.") form.addField('sourceip', formal.String(strip=True, validators=[PageHelpers.IPValidator()]), label="Destination IP", description="External IP to forward from") form.addField('source', formal.String(strip=True, validators=[PageHelpers.IPValidator()]), label="Source IP", description="External IP to accept connections from") form.addField('proto', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options=self.protocols), label="Protocol") form.data['proto'] = 'tcp' form.data['szone'] = 'net' form.data['dzone'] = 'loc' form.addAction(self.submitForwardPort) return form
def form_allowRange(self, data): form = formal.Form() form.addField('action', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = [ ("ACCEPT", "Accept"), ("REJECT", "Reject") ]), label = "Action") # Source form.addField('sip', formal.String(), label = "Source IP", description = "Source IP address of connecting host or network (Blank for Any)") form.addField('szone', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = self.getZones()), label = "Source Zone") form.addField('sport', formal.String(strip=True, validators=[PageHelpers.PortRangeValidator()]), label = "Source Port", description = "Source port (Blank for Any)") # Destination form.addField('dip', formal.String(), label = "Destination IP", description = "Destination IP address or network (Leave blank for ANY)") form.addField('dzone', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = self.getZones()), label = "Destination Zone") form.addField('dport', formal.String(strip=True, validators=[PageHelpers.PortRangeValidator()]), label = "Destination Port/Type", description = "Destination port OR other protocol subtype (Blank for any)") form.addField('proto', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = self.protocols), label = "Protocol") form.data['szone']="all" form.data['dzone']="all" form.data['proto']="-" form.addAction(self.submitAllowRange) return form
def form_addQos(self, data): tos = [ ('16', 'Minimize Delay'), ('8', 'Maximize Throughput'), ('4', 'Maximize Reliability'), ('2', 'Minimize Cost'), ('0', 'Normal Service') ] form = formal.Form() protocols = [('tcp', 'TCP'), ('udp', 'UDP'), ('47', 'PPTP')] form.addField('port', formal.String(required=True, strip=True, validators=[PageHelpers.PortRangeValidator()]), label = "Port") form.addField('proto', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = protocols), label = "Protocol") form.addField('qos', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options = tos), label = "Type of service") form.addAction(self.submitQosForm) return form