Skip to content

Update ssrf_proxy.py - #8564

Closed
kong3916 wants to merge 1 commit into
langgenius:mainfrom
kong3916:patch-1
Closed

kong3916 wants to merge 1 commit into
langgenius:mainfrom
kong3916:patch-1

Conversation

@kong3916

@kong3916 kong3916 commented Sep 19, 2024 •

Copy link
Copy Markdown

In the original code, it only attempts a request using either SSRF_PROXY_ALL_URL or proxies once, without any proxy-switching logic. If one proxy fails, it doesn't automatically switch to another proxy. The retry logic is based on the same proxy configuration. If a request fails, it keeps retrying the same proxy until the maximum retry count is reached.

This applies to cases where you need to attempt multiple proxies or in an unstable network. When the network environment may fluctuate, or the proxy servers might be unavailable, the second version of the code can automatically attempt other proxies, increasing the likelihood of successful requests.

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. Close issue syntax: Fixes #<issue number>, see documentation for more details.

Fixes

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

In the original code, it only attempts a request using either SSRF_PROXY_ALL_URL or proxies once, without any proxy-switching logic. If one proxy fails, it doesn't automatically switch to another proxy. The retry logic is based on the same proxy configuration. If a request fails, it keeps retrying the same proxy until the maximum retry count is reached.

This applies to cases where you need to attempt multiple proxies or in an unstable network. When the network environment may fluctuate, or the proxy servers might be unavailable, the second version of the code can automatically attempt other proxies, increasing the likelihood of successful requests.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐍 python 💪 enhancement New feature or request labels Sep 19, 2024
@crazywoola
crazywoola requested a review from Yeuoly September 21, 2024 09:23
@kong3916

Copy link
Copy Markdown
Author

fix:#6244

@Yeuoly

Yeuoly commented Sep 23, 2024 •

Copy link
Copy Markdown
Contributor

Thanks so much for your works, but I'm sorry for that you should configure upstream proxies of SSRF_PROXY outside of Dify, such as squid, as it's a security policy, allowing custom proxies will cause security issues like intranet sniffing.

@crazywoola crazywoola closed this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants