firewall: improve previous by reusing a class constant #6880

This commit is contained in:
Franco Fichtner 2023-09-25 10:42:00 +02:00
parent f8ff476cff
commit f23f455bc4
5 changed files with 9 additions and 6 deletions

View File

@ -58,7 +58,7 @@ class DNatRule extends Rule
'nat' => 'parseStaticText,nat ',
'interface' => 'parseInterface',
'ipprotocol' => 'parsePlain',
'protocol' => 'parseReplaceSimple,tcp/udp:{tcp udp}|a/n:"a/n",proto ',
'protocol' => self::PARSE_PROTO,
'interface.from' => 'parseInterface, from (,:network)',
'from' => 'parsePlainCurly,to ',
'interface.to' => 'parseInterface, -> (,)',

View File

@ -46,7 +46,7 @@ class FilterRule extends Rule
'gateway' => 'parseRoute',
'reply' => 'parsePlain',
'ipprotocol' => 'parsePlain',
'protocol' => 'parseReplaceSimple,tcp/udp:{tcp udp}|a/n:"a/n",proto ',
'protocol' => self::PARSE_PROTO,
'from' => 'parsePlainCurly,from ',
'from_port' => 'parsePlainCurly, port ',
'os' => 'parsePlain, os {","}',

View File

@ -42,7 +42,7 @@ class ForwardRule extends Rule
'log' => 'parseBool,log ',
'interface' => 'parseInterface',
'ipprotocol' => 'parsePlain',
'protocol' => 'parseReplaceSimple,tcp/udp:{tcp udp}|a/n:"a/n",proto ',
'protocol' => self::PARSE_PROTO,
'from' => 'parsePlainCurly,from ',
'from_port' => 'parsePlainCurly, port ',
'to' => 'parsePlainCurly,to ',
@ -59,7 +59,7 @@ class ForwardRule extends Rule
'nat' => 'parseStaticText,nat ',
'interface' => 'parseInterface',
'ipprotocol' => 'parsePlain',
'protocol' => 'parseReplaceSimple,tcp/udp:{tcp udp}|a/n:"a/n",proto ',
'protocol' => self::PARSE_PROTO,
'interface.from' => 'parseInterface, from (,:network)',
'target.to' => 'parsePlainCurly,to ',
'localport' => 'parsePlainCurly,port ',

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (C) 2017-2022 Deciso B.V.
* Copyright (C) 2017-2023 Deciso B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -38,6 +38,9 @@ abstract class Rule
protected $interfaceMapping = array();
protected $ruleDebugInfo = array();
/* ease the reuse of parsing for pf keywords by using class constants */
const PARSE_PROTO = 'parseReplaceSimple,tcp/udp:{tcp udp}|a/n:"a/n",proto ';
/**
* init Rule
* @param array $interfaceMapping internal interface mapping

View File

@ -40,7 +40,7 @@ class SNatRule extends Rule
'log' => 'parseBool,log',
'interface' => 'parseInterface',
'ipprotocol' => 'parsePlain',
'protocol' => 'parseReplaceSimple,tcp/udp:{tcp udp}|a/n:"a/n",proto ',
'protocol' => self::PARSE_PROTO,
'from' => 'parsePlain,from ',
'sourceport' => 'parsePlain, port ',
'to' => 'parsePlain,to ',