Skip to content

Commit 17535a2

Browse files
Merge pull request #49 from jaredhendrickson13/firewall_fixes
Firewall endpoint adjustments
2 parents acddc9c + 5c3e709 commit 17535a2

13 files changed

Lines changed: 350 additions & 269 deletions

README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -886,14 +886,6 @@ URL: https://{{$hostname}}/api/v1/firewall/alias
886886

887887

888888

889-
***Query params:***
890-
891-
| Key | Value | Description |
892-
| --- | ------|-------------|
893-
| id | string | Name of alias to delete. This alias must NOT be in use elsewhere in configuration |
894-
895-
896-
897889
***Body:***
898890

899891
```js
@@ -1741,8 +1733,8 @@ URL: https://{{$hostname}}/api/v1/firewall/rule
17411733
| icmptype | string or array | Set the ICMP subtype of the firewall rule. Multiple values may be passed in as array, single values may be passed as string. _Only available when `protocol` is set to `icmp`. If `icmptype` is not specified all subtypes are assumed_ |
17421734
| src | string | Set the source address of the firewall rule. This may be a single IP, network CIDR, alias name, or interface. When specifying an interface, you may use the physical interface ID, the descriptive interfance name, or the pfSense ID. To use only interface address, add `ip` to the end of the interface name otherwise the entire interface's subnet is implied. To negate the context of the source address, you may prepend the address with `!` |
17431735
| dst | string | Set the destination address of the firewall rule. This may be a single IP, network CIDR, alias name, or interface. When specifying an interface, you may use the physical interface ID, the descriptive interface name, or the pfSense ID. To only use interface address, add `ip` to the end of the interface name otherwise the entire interface's subnet is implied. To negate the context of the source address, you may prepend the address with `!` |
1744-
| srcport | string or integer | Set the TCP and/or UDP source port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` |
1745-
| dstport | string or integer | Set the TCP and/or UDP destination port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` |
1736+
| srcport | string or integer | Set the TCP and/or UDP source port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` |
1737+
| dstport | string or integer | Set the TCP and/or UDP destination port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` |
17461738
| gateway | string | Set the routing gateway traffic will take upon match (optional) |
17471739
| disabled | boolean | Disable the rule upon creation (optional) |
17481740
| descr | string | Set a description for the rule (optional) |
@@ -1868,9 +1860,9 @@ URL: https://{{$hostname}}/api/v1/firewall/rule
18681860
| icmptype | string or array | Update the ICMP subtype of the firewall rule. Multiple values may be passed in as array, single values may be passed as string. _Only available when `protocol` is set to `icmp`. If `icmptype` is not specified all subtypes are assumed_ (optional) |
18691861
| src | string | Update the source address of the firewall rule. This may be a single IP, network CIDR, alias name, or interface. When specifying an interface, you may use the physical interface ID, the descriptive interfance name, or the pfSense ID. To use only interface address, add `ip` to the end of the interface name otherwise the entire interface's subnet is implied. To negate the context of the source address, you may prepend the address with `!` (optional) |
18701862
| dst | string | Update the destination address of the firewall rule. This may be a single IP, network CIDR, alias name, or interface. When specifying an interface, you may use the physical interface ID, the descriptive interface name, or the pfSense ID. To only use interface address, add `ip` to the end of the interface name otherwise the entire interface's subnet is implied. To negate the context of the source address, you may prepend the address with `!` (optional) |
1871-
| srcport | string or integer | Update the TCP and/or UDP source port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` (optional) |
1872-
| dstport | string or integer | Update the TCP and/or UDP destination port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` |
1873-
| gateway | string | UPdate the routing gateway traffic will take upon match (optional) |
1863+
| srcport | string or integer | Update the TCP and/or UDP source port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` (optional) |
1864+
| dstport | string or integer | Update the TCP and/or UDP destination port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` |
1865+
| gateway | string | Update the routing gateway traffic will take upon match (optional) |
18741866
| disabled | boolean | Disable the rule upon modification (optional) |
18751867
| descr | string | Update the description of the rule (optional) |
18761868
| log | boolean | Enable rule matched logging (optional) |

docs/documentation.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@
19801980
{
19811981
"key": "type",
19821982
"value": "string",
1983-
"description": "Change type of alias (optional)",
1983+
"description": "Change type of alias. Alias type can only be changed when the targetted alias is not in use (optional)",
19841984
"disabled": true
19851985
},
19861986
{
@@ -2022,7 +2022,7 @@
20222022
}
20232023
},
20242024
"url": {
2025-
"raw": "https://{{$hostname}}/api/v1/firewall/alias?id=string",
2025+
"raw": "https://{{$hostname}}/api/v1/firewall/alias",
20262026
"protocol": "https",
20272027
"host": [
20282028
"{{$hostname}}"
@@ -2037,7 +2037,8 @@
20372037
{
20382038
"key": "id",
20392039
"value": "string",
2040-
"description": "Name of alias to delete. This alias must NOT be in use elsewhere in configuration"
2040+
"description": "Name or ID of alias to delete. This alias cannot be in use elsewhere in configuration",
2041+
"disabled": true
20412042
}
20422043
]
20432044
},
@@ -2174,12 +2175,12 @@
21742175
{
21752176
"key": "srcport",
21762177
"value": "string or integer",
2177-
"description": "Set the TCP and/or UDP source port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp`"
2178+
"description": "Set the TCP and/or UDP source port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp`"
21782179
},
21792180
{
21802181
"key": "dstport",
21812182
"value": "string or integer",
2182-
"description": "Set the TCP and/or UDP destination port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp`"
2183+
"description": "Set the TCP and/or UDP destination port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp`"
21832184
},
21842185
{
21852186
"key": "gateway",
@@ -2287,17 +2288,17 @@
22872288
{
22882289
"key": "srcport",
22892290
"value": "string or integer",
2290-
"description": "Update the TCP and/or UDP source port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` (optional)"
2291+
"description": "Update the TCP and/or UDP source port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp` (optional)"
22912292
},
22922293
{
22932294
"key": "dstport",
22942295
"value": "string or integer",
2295-
"description": "Update the TCP and/or UDP destination port of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp`"
2296+
"description": "Update the TCP and/or UDP destination port or port alias of the firewall rule. This is only necessary if you have specified the `protocol` to `tcp`, `udp`, `tcp/udp`"
22962297
},
22972298
{
22982299
"key": "gateway",
22992300
"value": "string",
2300-
"description": "UPdate the routing gateway traffic will take upon match (optional)"
2301+
"description": "Update the routing gateway traffic will take upon match (optional)"
23012302
},
23022303
{
23032304
"key": "disabled",

pfSense-pkg-API/files/etc/inc/api/framework/APIResponse.inc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ function get($id, $data=[], $all=false) {
12121212
"status" => "bad request",
12131213
"code" => 400,
12141214
"return" => $id,
1215-
"message" => "Firewall alias name must be type string"
1215+
"message" => "Invalid firewall alias name"
12161216
],
12171217
4054 => [
12181218
"status" => "bad request",
@@ -1254,7 +1254,7 @@ function get($id, $data=[], $all=false) {
12541254
"status" => "bad request",
12551255
"code" => 400,
12561256
"return" => $id,
1257-
"message" => "Invalid firewall alias port"
1257+
"message" => "Invalid firewall alias port or port range"
12581258
],
12591259
4061 => [
12601260
"status" => "bad request",
@@ -1530,7 +1530,19 @@ function get($id, $data=[], $all=false) {
15301530
"status" => "bad request",
15311531
"code" => 400,
15321532
"return" => $id,
1533-
"message" => "Alias details cannot contain more items than alias addresses"
1533+
"message" => "Firewall alias details cannot contain more items than alias addresses"
1534+
],
1535+
4107 => [
1536+
"status" => "bad request",
1537+
"code" => 400,
1538+
"return" => $id,
1539+
"message" => "Firewall alias type cannot be changed while in use"
1540+
],
1541+
4108 => [
1542+
"status" => "bad request",
1543+
"code" => 400,
1544+
"return" => $id,
1545+
"message" => "Firewall alias cannot be deleted while in use"
15341546
],
15351547

15361548
//5000-5999 reserved for /users API calls

pfSense-pkg-API/files/etc/inc/api/framework/APITools.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,6 @@ function alias_in_use($alias_name) {
593593
alias_find_references(array('nat', 'rule'), array('target'), $alias_name, $is_alias_referenced, $referenced_by);
594594
alias_find_references(array('nat', 'rule'), array('local-port'), $alias_name, $is_alias_referenced, $referenced_by);
595595
// NAT 1:1 Rules
596-
//alias_find_references(array('nat', 'onetoone'), array('external'), $alias_name, $is_alias_referenced, $referenced_by);
597-
//alias_find_references(array('nat', 'onetoone'), array('source', 'address'), $alias_name, $is_alias_referenced, $referenced_by);
598596
alias_find_references(array('nat', 'onetoone'), array('destination', 'address'), $alias_name, $is_alias_referenced, $referenced_by);
599597
// NAT Outbound Rules
600598
alias_find_references(array('nat', 'outbound', 'rule'), array('source', 'network'), $alias_name, $is_alias_referenced, $referenced_by);

0 commit comments

Comments
 (0)