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

Fix for header IP with source port #14085

Closed
AnythingOverIP opened this issue Oct 19, 2023 · 1 comment · Fixed by #14235
Closed

Fix for header IP with source port #14085

AnythingOverIP opened this issue Oct 19, 2023 · 1 comment · Fixed by #14235
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@AnythingOverIP
Copy link

NetBox version

v3.6.4

Feature type

Change to existing functionality

Proposed functionality

Based on a Slack Discussion, I'm submitting what could be a half bug / half feature request/issue...

When NetBox is behind an IIS reverse proxy, it appears that the header information is different. We can use it without any issue, except if a user enter a wrong credential set, which results in an error message:
image

The user IP returned has source port, which breaks the get_client_ip function defined in netbox/utilities/request.py

I worked around the issue by adding a single line of code:
client_ip = client_ip.split(':')[0] just before try

Use case

To prevent error message, which lead the user to think that server is down instead of him entering a wrong password.

Database changes

none

External dependencies

none

@AnythingOverIP AnythingOverIP added the type: feature Introduction of new functionality to the application label Oct 19, 2023
@abhi1693 abhi1693 self-assigned this Nov 9, 2023
@abhi1693 abhi1693 added the status: accepted This issue has been accepted for implementation label Nov 9, 2023
abhi1693 added a commit that referenced this issue Nov 9, 2023
jeremystretch pushed a commit that referenced this issue Nov 9, 2023
@candlerb
Copy link
Contributor

candlerb commented Dec 1, 2023

Unfortunately this breaks when given an IPv6 address, including an IPv4 mapped one like ::ffff:192.168.6.2 - see discussion #14307.

Proposal:

  • if the IP address contains only a single colon, then it can't possibly be an IPv6 address, so you can do the IIS workaround (urgh).
  • if the address looks like [addr] or [addr]:nnn then strip the port and the brackets. This is on the assumption that if IIS were ever to add a port to an IPv6 address, it would have to wrap it this way
  • otherwise, leave it alone

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants