Skip to content
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

Add support for Unifi Network Server running remotely #65

Merged
merged 39 commits into from
Oct 18, 2024

Conversation

aki263
Copy link
Contributor

@aki263 aki263 commented Oct 16, 2024

Added new env variable called CONTROLLER_TYPE: NETWORK_SERVER which will trigger the code path that will login and update dns record on remote unifi network server. This is applicable for gateway max and lite which dont have unifi server build in.

This is tested locally, test results are in #63 (comment)

I have also added lot more logging so its easier to catch errors in http requests.

Image that can be tested: ghcr.io/aki263/external-dns-unifi-webhook:main

@kashalls
Copy link
Owner

CC @onedr0p

Copy link
Owner

@kashalls kashalls left a comment

Choose a reason for hiding this comment

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

Incomplete review, please look into these changes for now.

internal/.DS_Store Outdated Show resolved Hide resolved
internal/unifi/types.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
internal/unifi/client.go Outdated Show resolved Hide resolved
internal/unifi/client.go Outdated Show resolved Hide resolved
Copy link
Contributor

@onedr0p onedr0p left a comment

Choose a reason for hiding this comment

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

Personally I'd like to see logging improvements in a separate PR.

log.Debug("Making request", zap.String("method", method), zap.String("path", path))

// Convert body to bytes for logging and reuse
var bodyBytes []byte
Copy link
Owner

Choose a reason for hiding this comment

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

Little worried about reading the body here, I tried doing it last time and it messed up exdns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not very comfortable with GO so if you think this can cause trouble, please remove it.

Copy link
Owner

Choose a reason for hiding this comment

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

I am not very comfortable with GO so if you think this can cause trouble, please remove it.

It's fine, we will test and verify it functions.

@kashalls
Copy link
Owner

@aki263 Testing to ensure gateway functionality isn't impaired. Please test in your situation.

@aki263
Copy link
Contributor Author

aki263 commented Oct 16, 2024

@aki263 Testing to ensure gateway functionality isn't impaired. Please test in your situation.

I just tested, it works for me with env UNIFI_EXTERNAL_CONTROLLER set to True.

image

On unifi side

image

@aki263 aki263 requested review from kashalls and onedr0p October 16, 2024 22:26
@kashalls
Copy link
Owner

Latest commit is working fine for me. Deleted all records and webhook recovered in less than a couple seconds.

Copy link
Owner

@kashalls kashalls left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@kashalls kashalls merged commit 86386ba into kashalls:main Oct 18, 2024
2 checks passed
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.

4 participants