sipgate-io / sipgateio-node

The official Node.js library for sipgate.io
MIT License
35 stars 7 forks source link

"Error: Caution! IP address is not from sipgate" when using webhooks #28

Open michaelSchmidMaloon opened 9 months ago

michaelSchmidMaloon commented 9 months ago

Describe the bug I'm not sure if I understand the usage of webhooks with sipgate.io correctly. I wrote some code, along with the node examples, that reacts on multiple events, e.g. newCallEvent. I host it on a dedicated machine in AWS that is assigned the WEBHOOK_SERVER_ADDRESS. This is also configured in sipgate.io. The WEBHOOK_URL is set to some Grafana incoming webhook endpoint. When starting the server and calling a number that's configured for the webhook, the log reads

Caution! IP address is not from sipgate

At this point I'm not sure if I'm supposed to host this "webhook relay" myself or if it should somehow be configured / uploaded to sipgate. But if so, I have no idea how. Would be lovely if someone can point me in the right direction.

To Reproduce Steps to reproduce the behavior.

Expected behavior Webhook data being transfered from sipgate to the configured outgoing webhook.

Environment (please complete the following information):

Additional context

const { createWebhookModule } = require("sipgateio");
require("dotenv").config();
const axios = require("axios").default;

process.on('SIGINT', function() {
  console.log("Caught interrupt signal");

  if (true)
      process.exit();
});

const outgoingWebhookUrl = process.env.OUTGOING_WEBHOOK_URL;
if (!outgoingWebhookUrl) {
  console.error(
    "Please provide a outgoing webhook URL via the environment variable OUTGOING_WEBHOOK_URL"
  );
  return;
}

const serverAddress = process.env.WEBHOOK_SERVER_ADDRESS;
if (!serverAddress) {
  console.error(
    "Please provide a server address via the environment variable WEBHOOK_SERVER_ADDRESS"
  );
  return;
}

const webhookServerOptions = {
  port: process.env.WEBHOOK_SERVER_PORT || 3000,
  serverAddress,
};

createWebhookModule()
  .createServer(webhookServerOptions)
  .then((server) => {
    console.log(
      `Server running at ${webhookServerOptions.serverAddress}:${webhookServerOptions.port}\n` + "Ready for calls"
    );
    server.onNewCall((newCallEvent) => {
      console.log(`New call from ${newCallEvent.from} to ${newCallEvent.to}`);
      axios.post(outgoingWebhookUrl, { })
    });
  });
michaelSchmidMaloon commented 9 months ago

Using skipSignatureVerification: true as in https://github.com/sipgate-io/sipgateio-node?tab=readme-ov-file#security ignores the problem. Though I'm not sure why it's logged in the first place.