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: use remote address instead of client ip #1831

Merged
merged 3 commits into from
Apr 30, 2021

Conversation

starsz
Copy link
Contributor

@starsz starsz commented Apr 27, 2021

Please answer these questions before submitting a pull request, or your PR will get closed.

Why submit this pull request?
Now, we use the gin's context.ClientIP.This function will parse the IP from the header X-Forwarded-For and X-Real-Ip
which will bypass the ipfilter middleware.

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What changes will this PR take into?

Use remote address instead of client ip.

Checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@netlify
Copy link

netlify bot commented Apr 27, 2021

Deploy preview for apisix-dashboard ready!

Built with commit 5c52a25

https://deploy-preview-1831--apisix-dashboard.netlify.app

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2021

Codecov Report

Merging #1831 (5e04afc) into master (f146898) will decrease coverage by 9.81%.
The diff coverage is 100.00%.

❗ Current head 5e04afc differs from pull request most recent head 5c52a25. Consider uploading reports for the commit 5c52a25 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1831      +/-   ##
==========================================
- Coverage   71.62%   61.81%   -9.82%     
==========================================
  Files         172       47     -125     
  Lines        6119     3177    -2942     
  Branches      711        0     -711     
==========================================
- Hits         4383     1964    -2419     
+ Misses       1487      899     -588     
- Partials      249      314      +65     
Flag Coverage Δ
backend-e2e-test 46.08% <100.00%> (-0.03%) ⬇️
backend-e2e-test-ginkgo 49.03% <100.00%> (-0.04%) ⬇️
backend-unit-test ?
frontend-e2e-test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
api/internal/filter/ip_filter.go 56.09% <100.00%> (-15.70%) ⬇️
api/internal/utils/runtime/runtime.go 0.00% <0.00%> (-64.29%) ⬇️
api/internal/core/store/validate_mock.go 0.00% <0.00%> (-50.00%) ⬇️
api/internal/filter/authentication.go 47.22% <0.00%> (-30.56%) ⬇️
api/internal/core/store/store.go 59.88% <0.00%> (-28.15%) ⬇️
api/internal/handler/service/service.go 66.08% <0.00%> (-26.09%) ⬇️
api/internal/handler/global_rule/global_rule.go 64.51% <0.00%> (-19.36%) ⬇️
...pi/internal/handler/plugin_config/plugin_config.go 59.57% <0.00%> (-18.09%) ⬇️
api/internal/handler/consumer/consumer.go 75.00% <0.00%> (-16.08%) ⬇️
api/internal/utils/json_patch.go 44.82% <0.00%> (-13.80%) ⬇️
... and 140 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f146898...5c52a25. Read the comment docs.

api/internal/filter/ip_filter_test.go Outdated Show resolved Hide resolved
@starsz starsz merged commit b54c195 into apache:master Apr 30, 2021
@starsz starsz deleted the fix_client_ip branch April 30, 2021 07:07
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.

5 participants