Skip to content

Comments

fix(ns-plug): inventory, better public IP retrival#1344

Merged
gsanchietti merged 1 commit intomainfrom
improve_inventory
Aug 22, 2025
Merged

fix(ns-plug): inventory, better public IP retrival#1344
gsanchietti merged 1 commit intomainfrom
improve_inventory

Conversation

@gsanchietti
Copy link
Member

The ifconfig.co site sometimes returns an HTML page and this info is wrongly sent to my.nethesis.it

New behavior:

  • send an HTTP request to ifconfig.co and parse the response, if the remote server returns a valid IP address, return it
  • otherwise, try to obtain the same info by executing a DNS query to OpenDNS
  • return an empty string if none of the above responses are valid IP addresses

@gsanchietti gsanchietti requested a review from Copilot August 19, 2025 06:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the reliability of public IP address retrieval for the ns-plug inventory system. The change addresses issues where ifconfig.co sometimes returns HTML error pages instead of IP addresses, which could cause incorrect data to be sent to my.nethesis.it.

  • Implements proper IP address validation using the ipaddress module
  • Adds fallback mechanism using OpenDNS when ifconfig.co fails
  • Returns empty string when neither method provides a valid IP address

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

The ifconfig.co site sometimes returns an HTML page and
this info is wrongly sent to my.nethesis.it

New behavior:
- send an HTTP request to ifconfig.co and parse the response,
  if the remote server returns a valid IP address, return it
- otherwise, try to obtain the same info by executing a DNS query to OpenDNS
- return an empty string if none of the above responses are valid IP
  addresses
@gsanchietti gsanchietti merged commit de9e91d into main Aug 22, 2025
1 of 2 checks passed
@gsanchietti gsanchietti deleted the improve_inventory branch August 22, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants