ndejong / pfsense_fauxapi

REST based API interface for pfSense 2.3.x and 2.4.x to facilitate devops
Apache License 2.0
354 stars 61 forks source link

Problem calling function #17

Closed Vaibhav1587 closed 6 years ago

Vaibhav1587 commented 6 years ago

Trying to block the host using command line but getting exception, command : curl -X POST --silent --insecure --header "Content Type: application/json" --header "fauxapi-auth:XXX" http://xx.xxx.xxx.xx:xxxx/fauxapi/v1/\?action=function_call --data '{"function":"easyrule_block_alias_add","host":"xxx.xxx.xxx.xx","$int":"wan"}'

Response :

{"callid":"5a3ab9fa764ac","action":"function_call","message":"problem calling function","logs":[{"INFO":"20171220Z192858 :: fauxapi\v1\fauxApi::__call","DATA":{"user_action":"function_call","callid":"5a3ab9fa764ac","client_ip":"xx.xxx.xxx.xx"}},{"INFO":"20171220Z192858 :: valid auth for call","DATA":{"apikey":"PFFAwZz0dFMaX1nrlr095Ei2","callid":"5a3ab9fa764ac","client_ip":"xx.xxx.xxx.xx"}},{"ERROR":"20171220Z192858 :: function not defined as valid in function calls reference file","DATA":{"function":"easyrule_block_alias_add","function calls reference file":"\/etc\/fauxapi\/pfsense_function_calls.txt"}}],"error":{"error":{"xdebug_message":"\nException: function not defined as valid in function calls reference file in \/etc\/inc\/fauxapi\/fauxapi_pfsense_interface.inc on line 633\n\nCall Stack:\n 0.0001 119368 1. {main}() \/usr\/local\/www\/fauxapi\/v1\/index.php:0\n 0.0022 289984 2. fauxapi\v1\fauxApi->function_call() \/usr\/local\/www\/fauxapi\/v1\/index.php:32\n 0.0022 290456 3. fauxapi\v1\fauxApi->__call() \/usr\/local\/www\/fauxapi\/v1\/index.php:32\n 0.0031 297616 4. fauxapi\v1\fauxApiActions->function_call() \/etc\/inc\/fauxapi\/fauxapi.inc:83\n 0.0032 298228 5. fauxapi\v1\fauxApiPfsenseInterface->function_call() \/etc\/inc\/fauxapi\/fauxapi_actions.inc:388\n"}}}

ndejong commented 6 years ago

Yes, notice this part of the error message - I've added some line breaks to make reading it easier:-

"ERROR":"20171220Z192858 :: function not defined as valid in function calls reference file",
"DATA":{
"function":"easyrule_block_alias_add",
"function calls reference file":"/etc/fauxapi/pfsense_function_calls.txt"
}

You MUST allow (via uncommenting in the file /etc/fauxapi/pfsense_function_calls.txt) the function you are trying to access.

ndejong commented 6 years ago

I note that there was a typo in the documentation here, the correct location of the pfsense_function_calls.txt file is /etc/fauxapi/pfsense_function_calls.txt - documentation has been updated.