kong
kong copied to clipboard
feat(ip-restriction): Add TCP Support
Summary
This change adds TCP support to the ip-restriction plugin by implementing the Stream module's preread function.
When a TCP connection is rejected due to IP restriction rules, a JSON error response is written to the stream and the connection is closed.
Checklist
- [x] The Pull Request has tests
- [x] There's an entry in the CHANGELOG
- [x] Link to docs pr: https://github.com/Kong/docs.konghq.com/pull/5736
Full changelog
- Add protocols to schema: "tcp", "tls", "grpc", "grpcs"
- Implement preread function
- Make handler logic generic to be shared by HTTP and TCP
Issue reference
Fix #6679
KAG-722
This PR is almost the same with #10229, What is the relation?
We work on the same team. We need this feature in 2.8.x because we can't upgrade to v3 yet.
Could you add some test cases for this PR? Thanks.
Could you add some test cases for this PR? Thanks.
Sure, but I'm completely lost on how testing works here. is this the test for this plugin : https://github.com/Kong/kong/blob/master/t/01-pdk/03-ip/01-is_trusted.t
Also, is there some docs on how testing works? Thanks.
This plugin's test should be spec/03-plugins/17-ip-restriction.
Perhaps we do not have a proper doc for the test, but don't worry, we can implement the feature first.
Yeah, I found the tests right after I asked :-)
I'm actually working on the other suggested changed ATM. I'll also try to fix the test that are broken from the change in response message.
@scrudge Did you mean to add a test for the new functionality? I only see changes to the existing test. Please rebase to the master branch as well. Thanks!
@scrudge Could you please address the latest feedback?
Missing test for new functionality.
As I mentioned early, I have know idea how to test TCP. Is there some example you can suggest. Thanks.
@chronolaw How do we test this feature? Could you please share some thoughts on this here?
I think we could find some example code in spec/02-integration/05-proxy, such as 28-stream_plugins_triggering_spec.lua and 19-grpc_proxy_spec.lua.
@scrudge Mind digging in those files and getting back?
Yes, thanks.
On Tue, Mar 14, 2023, 3:01 PM Harry @.***> wrote:
@scrudge https://github.com/scrudge Mind digging in those files and getting back?
— Reply to this email directly, view it on GitHub https://github.com/Kong/kong/pull/10245#issuecomment-1468745254, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS4RZQXMOATSMPC7MMKJZ3W4DFB3ANCNFSM6AAAAAAUS4K6SQ . You are receiving this because you were mentioned.Message ID: @.***>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Who do I need to yell at to reopen this
@hbagdi can we re-open this? We are about to update with some tests.
Reopening. Tests to be added soon
Sorry, I tried applying a last minute suggestion and it broke the build. I've rolled it back and added tests, which are all passing. I believe this is ready for review.
@hanshuebner @bungle
There's one remaining comment. I think I've resolved the issue, just waiting for feedback. https://github.com/Kong/kong/pull/10245#discussion_r1123420637
Please add an entry to CHANGELOG.md.
Could you please add some return statements (it makes code cleaner about its intent).
@bungle can you please approve changes you requested? Thank you.
Could you please add some return statements (it makes code cleaner about its intent).
@bungle can you please approve changes you requested? Thank you.
@hanshuebner @hbagdi I believe this PR is held waiting for a response from @bungle but I haven't heard from him since his original comment. Is there anyway to get this completed? Thanks for all the help.
@scrudge Thank your for your contribution!
Thank you for all your help.
On Sat, Jul 8, 2023, 8:54 AM Hans Hübner @.***> wrote:
@scrudge https://github.com/scrudge Thank your for your contribution!
— Reply to this email directly, view it on GitHub https://github.com/Kong/kong/pull/10245#issuecomment-1626877380, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS4RZRV36J36FL3EPKEGUTXPDYXZANCNFSM6AAAAAAUS4K6SQ . You are receiving this because you were mentioned.Message ID: @.***>