Skip to content

[enhancement] Added WhoIs details alongside devices #1065

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

Draft
wants to merge 16 commits into
base: gsoc25-whois
Choose a base branch
from

Conversation

DragnEmperor
Copy link
Member

@DragnEmperor DragnEmperor commented Jun 10, 2025

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1026.

Description of Changes

To fetch WhoIs details in device REST APIs, created two serializers : BriefWhoIsSerializer and WhoIsSerializer for listing and detail endpoints respectively

@DragnEmperor
Copy link
Member Author

There are some commits which are related to another PR #1054. Once its merged, this branch will be rebased.

Added WHOIS model with the required fields.
Implemented a new celery task to fetch WHOIS
details using the `geoip2` web service.
In order to trigger the task whenever `last_ip`
changes, using existing logic of `_changed_fields`
to track the changes.

Closes #1032
Closes #1033

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Added tests for checking if `fetch_whois_details` task
is called properly or not, and for checking creation
of WHOIS record for a device if the last_ip recorded
is public.
As now whois record is also fetched whenever fetching
a device, there is an increase in query count in some
of the tests.

Closes #1045

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Closes #1037

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Using JSONField for address gives the flexibility to
format address as per convenience. Added fallbacks
for typical address fields in `fetch_whois_details`.
Updated docs for WhoIs feature with steps to obtain
and setup the required Credentials.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
To reduce data redundancy for duplicate IPs,
WhoIs model now uses IP address as primary key
and devices are mapped to it via manual lookups.
Updated the test cases to reflect the same.
Formatting changes in WhoIs doc page and
settings variables.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
To improve modularity and flexibility, all
WhoIs related code is kept under `whois` subdirectory
under `config` module.
This includes tests, tasks, on delete handlers as well.
Added `cache` to prevent repeated lookups during
multiple WhoIs details fetch during device listing.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Moved all tasks to service file to keep one source.
Refactored the way whois_info is fetcehd for a device.
Modified the order of whois checks to keep
expensive checks at the bottom.
As in views like `DeviceChecksumView` whole device
instance is being cached, now org settings will be
fetched from db rather than through device to
maintain consistency. This has led to increase in
queries in some test cases.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Org config settings are now cached to ensure
DeviceChecksumview is not degraded. This will
be invalidated on org settings update/delete
which are rare.
Refactored code and tests for readability.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Migrated all receivers related to WhoIs to the
model class.
Includes minor refactoring as well.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
The imports are restructured to avoid app
registry errors and aid whois task discovery.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
There was an issue that the task was triggered
for a device whose last_ip is updated but without
checking if we already have WhoIs for the latest
ip. Have added a check to return from the task
if that is the case.

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
The checks in `_need_who_is_lookup` are split for better readability

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Added new test cases and validator for
who_is model fields. Also refactored
the way address is being computed

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
To get who_is details in device listing and
detail views, added BriefWhoIsSerializer and
WhoIsSerializer respectively.
As these are accessed via SerializerMethodField,
created a Mixin to reduce duplicated logic.

Closes #1026

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
@DragnEmperor DragnEmperor force-pushed the issues/1026-whois-display branch from b50598f to a9b7891 Compare June 16, 2025 20:02
Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
@DragnEmperor DragnEmperor force-pushed the issues/1026-whois-display branch from a9b7891 to dddfb45 Compare June 17, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement gsoc Part of a Google Summer of Code project
Development

Successfully merging this pull request may close these issues.

1 participant