pfsense-api icon indicating copy to clipboard operation
pfsense-api copied to clipboard

Multiple interaces for floating rule

Open VIKMSTR opened this issue 1 year ago • 3 comments

Since version 1.4.0 there is a possibility to manage floating firewall rules. But the meaning of floating rules is, that they can be related to multiple interfaces. When you open a firewall rule edit page, you can see "multiselect" text area to pick multiple interfaces. image

This is not possible to achieve with API.

Solution proposal:

  1. an interface string attribute in the request body can consume multiple values separated by "," delimiter (so we can set it up via existing attribute) or
  2. Duplicating the /firewall_rules endpoint to firewall_floating_rules and handling the floating rules completely separate

Cheers, Viktor

VIKMSTR avatar Jul 11 '22 07:07 VIKMSTR

Asked here while ago on the relevant PR btw: https://github.com/jaredhendrickson13/pfsense-api/pull/188#issuecomment-1070593580

VIKMSTR avatar Jul 11 '22 08:07 VIKMSTR

I took a look into the config xml, and it seems, that the interfaces are indeed saved as a "," separated value. Screenshot 2022-07-11 at 10 21 18

So if I'm looking correctly on the APIFirewallRuleCreate, only the validation should be adapted to make it work?

VIKMSTR avatar Jul 11 '22 08:07 VIKMSTR

And actually, the values from already existing floating rules are also returned in "opt1,opt9" format in interface attribute.

{
  "id": "",
  "tracker": "1656335395",
  "type": "pass",
  "interface": "opt1,opt9",
  "ipprotocol": "inet",
  "tag": "",
  "tagged": "",
  "direction": "any",
  "floating": "yes",
  "max": "",
  "max-src-nodes": "",
  "max-src-conn": "",
  "max-src-states": "",
  "statetimeout": "",
  "statetype": "keep state",
  "os": "",
  "protocol": "tcp",
  "source": {
    "any": ""
  },
  "destination": {
    "any": ""
  },
  "disabled": "",
  "descr": "",
  "updated": {
    "time": "1656335395",
    "username": "[email protected] (Local Database)"
  },
  "created": {
    "time": "1656335395",
    "username": "[email protected] (Local Database)"
  }
}

Is there any reason why not enable multiple interfaces separated by "," (without spaces) - like backwards compatibility reasons etc?

VIKMSTR avatar Jul 11 '22 14:07 VIKMSTR