diff options
Diffstat (limited to 'config/pfflowd/pfflowd.xml')
-rw-r--r-- | config/pfflowd/pfflowd.xml | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/config/pfflowd/pfflowd.xml b/config/pfflowd/pfflowd.xml new file mode 100644 index 00000000..2470e2b2 --- /dev/null +++ b/config/pfflowd/pfflowd.xml @@ -0,0 +1,143 @@ +<packagegui> + <name>pfflowd</name> + <version>0.8.3 pkg v1.0.1</version> + <title>pfflowd: Settings</title> + <aftersaveredirect>pkg_edit.php?xml=pfflowd.xml&id=0</aftersaveredirect> + <menu> + <name>pfflowd</name> + <tooltiptext>Modify pfflowd settings.</tooltiptext> + <section>Services</section> + <configfile>pfflowd.xml</configfile> + <url>/pkg_edit.php?xml=pfflowd.xml&id=0</url> + </menu> + <service> + <name>pfflowd</name> + <rcfile>pfflowd.sh</rcfile> + <executable>pfflowd</executable> + </service> + <configpath>installedpackages->package->$packagename->configuration->settings</configpath> + <fields> + <field> + <fielddescr>Host</fielddescr> + <fieldname>host</fieldname> + <description>Specify the host that datagrams are to be sent to.</description> + <type>input</type> + </field> + <field> + <fielddescr>Port</fielddescr> + <fieldname>port</fieldname> + <description>Enter the port that datagrams are to be sent to.</description> + <type>input</type> + </field> + <field> + <fielddescr>Source Hostname/IP</fielddescr> + <fieldname>sourcehost</fieldname> + <description>Specify the hostname or IP address that datagrams are to be sent from. The hostname/IP must be local to this system.</description> + <type>input</type> + </field> + <field> + <fielddescr>pf rule direction restriction</fielddescr> + <fieldname>direction</fieldname> + <description>Restrict creation of flow records to states matching a certain direction (in, out, or any).</description> + <type>select</type> + <options> + <option> + <name>Any</name> + <value>any</value> + </option> + <option> + <name>In</name> + <value>in</value> + </option> + <option> + <name>Out</name> + <value>out</value> + </option> + </options> + </field> + <field> + <fielddescr>Netflow version</fielddescr> + <fieldname>version</fieldname> + <description>Select which version of the NetFlow protocol to use.</description> + <type>select</type> + <options> + <option> + <name>9</name> + <value>9</value> + </option> + <option> + <name>5</name> + <value>5</value> + </option> + <option> + <name>1</name> + <value>1</value> + </option> + </options> + </field> + </fields> + <custom_php_global_functions> + <![CDATA[ + function sync_package_pfflowd() { + conf_mount_rw(); + config_lock(); + global $config; + foreach($config['installedpackages']['pfflowd']['config'] as $cf) { + if($cf['host'] != "") { + $start = "\n/sbin/ifconfig pfsync0 up\n"; + $start .= "/usr/local/sbin/pfflowd "; + $start .= " -n {$cf['host']}"; + if($cf['port'] != "") + $start .= ":{$cf['port']}"; + if(!empty($cf['sourcehost'])) + $start .= " -s {$cf['sourcehost']} "; + if($cf['direction'] != "") + $start .= " -S {$cf['direction']}"; + if($cf['version'] != "") + $start .= " -v {$cf['version']}"; + write_rcfile(array( + "file" => "pfflowd.sh", + "start" => $start, + "stop" => "/usr/bin/killall pfflowd" + ) + ); + restart_service("pfflowd"); + break; + } + } + conf_mount_ro(); + config_unlock(); + } + + function validate_form_pfflowd($post, &$input_errors) { + if(($post['host'] == "") || !is_ipaddr($post['host'])) + $input_errors[] = 'You must specify a valid ip address in the \'Host\' field'; + if(($post['port'] == "") || !is_port($post['port'])) + $input_errors[] = 'You must specify a valid port number in the \'Port\' field'; + } + + function cleanup_config_pfflowd() { + global $a_pkg; + $pffconf = array(); + if (is_array($a_pkg)) { + foreach($a_pkg as $cf) { + if($cf['host'] != "") { + $pffconf = $cf; + } + } + } + $a_pkg = array(); + $a_pkg[0] = $pffconf; + } + ]]> + </custom_php_global_functions> + <custom_php_resync_config_command> + sync_package_pfflowd(); + </custom_php_resync_config_command> + <custom_php_validation_command> + validate_form_pfflowd($_POST, $input_errors); + </custom_php_validation_command> + <custom_php_command_before_form> + cleanup_config_pfflowd(); + </custom_php_command_before_form> +</packagegui> |