OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Profile of D0doooh »
  • Show Posts »
  • Messages
  • Profile Info
    • Summary
    • Show Stats
    • Show Posts...
      • Messages
      • Topics
      • Attachments

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

  • Messages
  • Topics
  • Attachments

Messages - D0doooh

Pages: [1]
1
General Discussion / Re: Unable to add IP addresses to an alias using API
« on: March 27, 2023, 01:10:29 am »
so after a little try and error, I got it to run, the problem was the URL, this must have the alias in the URL:

Code: [Select]
var payload = {
"address": msg.payload
};
var url = https://OPNSESNE.lan/api/firewall/alias_util/add/AuthUsers;
msg.url = url; msg.method = "POST"; msg.headers = { "Content-Type": "application/json" }; msg.payload = JSON.stringify(payload);
return msg;

2
General Discussion / [Solved] Unable to add IP addresses to an alias using API
« on: March 25, 2023, 12:30:41 pm »
I am currently facing some issues adding an IP address to an alias using the API. I have followed the documentation and tried calling the corresponding endpoint, but it doesn't seem to be working.

here is my code:

Code: [Select]
function urlEncodeFormData(data) {
    return Object.keys(data)
        .map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
        .join('&');
}

let extractedIPs = [];

for (let key in msg.payload) {
    if (msg.payload.hasOwnProperty(key)) {
        extractedIPs.push(msg.payload[key].ipAddress);
    }
}

let opnsenseUrl = 'https://OPNSENSE';

msg.url = opnsenseUrl + '/api/firewall/alias/addItem';

msg.method = 'POST';

const payloadData = {
    enabled: 1,
    name: "AuthUsers",
    type: "host",
    proto: "IPv4",
    content: extractedIPs.join(","),
    description: "Auth users IP addresses"
};

msg.payload = urlEncodeFormData(payloadData);

const apiKey = 'API_KEY';
const apiSecret = 'API_SECRET';

const auth = 'Basic ' + Buffer.from(apiKey + ':' + apiSecret).toString('base64');

msg.headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': auth
};

return msg;


this is the json i am submitting:

Code: [Select]
{"User01":{"ipAddress":"1.1.1.1","timestamp":"2023-03-25T02:52:50.447Z"},"User02":{"ipAddress":"2.2.2.2","timestamp":"2023-03-25T02:52:43.386Z"}}
the api otherwise works, I can make queries, I think I understand only something small wrong or is not formatted correctly.

the post request looks like this:

Code: [Select]
enabled=1&name=AuthUsers&type=host&proto=IPv4&content=1.1.1.1%2C2.2.2.2&description=Auth%20users%20IP%20addresses
Thanks a lot!

3
General Discussion / Re: Cannot get forced redirect of DNS to Pihole
« on: February 04, 2022, 01:56:49 am »
Quote from: ChrisChros on February 03, 2022, 10:34:26 am

UPDATE:
So I think I have it now.
I checked all my port forward rules and realized that NAT reflection was set to "Use system default", this has to be set to "Disabled".

Hi
I just ran into the same problems here too, could you show your settings exactly how you set them in the end?

Pages: [1]
OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2