Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit which pfctl command the rule_get call does #13

Closed
buttersausage opened this issue Sep 13, 2017 · 4 comments
Closed

Edit which pfctl command the rule_get call does #13

buttersausage opened this issue Sep 13, 2017 · 4 comments

Comments

@buttersausage
Copy link

buttersausage commented Sep 13, 2017

Hi there! First things first, awesome work on this one!

I would like to know if I can get the equivalent of the pfctl -vvs rules command from the faux_api call, but the call does pfctl -sr -vv instead. Is there any way I can amend this to use the option I need?

Need this because the -vvs gives a nice list with the rule number included, while -sr -vv does not. I need this so I am able to parse the rules according to its rule number in a single call. Any help would be appreciated

@buttersausage
Copy link
Author

buttersausage commented Sep 13, 2017

Upon further testing, it seems that the rule number is in the command itself, but is not returned in the curl output.

@334(0) anchor "tftp-proxy/*" all
  [ Evaluations: 7112201   Packets: 0         Bytes: 0           States: 0     ]
  [ Inserted: pid 3540 State Creations: 0     ]
@335(0) anchor "miniupnpd" all
  [ Evaluations: 7112453   Packets: 0         Bytes: 0           States: 0     ]
  [ Inserted: pid 3540 State Creations: 0     ]

vs

      {
        "rule": "anchor \"tftp-proxy/*\" all",
        "evaluations": "7010222",
        "packets": "0",
        "bytes": "0",
        "states": "0",
        "inserted": "3540",
        "statecreations": "0"
      },
      {
        "rule": "anchor \"miniupnpd\" all",
        "evaluations": "7010467",
        "packets": "0",
        "bytes": "0",
        "states": "0",
        "inserted": "3540",
        "statecreations": "0"
      }

@ndejong
Copy link
Owner

ndejong commented Sep 13, 2017 via email

@ndejong
Copy link
Owner

ndejong commented Sep 14, 2017

I've taken a look at the code behind this and can confirm that fauxapi is correctly parsing the pf-source-of-truth rule number, it might be entirely obvious because the array index number is the rule number

Right now, this means for you to obtain the rule number you will need to adjust your code to discover the array index number in your code.

I'll improve this in the next release to include a rule_number attribute that explicitly names the rule number to avoid any doubt.

I'll be adjusting the statecreations attribute to be more correct as well with state_creations instead

@ndejong
Copy link
Owner

ndejong commented Jul 2, 2018

Following up on this

New release (1.3) is due shortly and will add a number (as in rule number) attribute and changes statecreations to the slightly more correct state_creations

Closing

@ndejong ndejong closed this as completed Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants