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] Fix ssh tunnel always return 127.0.0.1 #2808

Closed
wants to merge 6 commits into from

Conversation

bwcxyk
Copy link

@bwcxyk bwcxyk commented Sep 14, 2024

修复ssh隧道始终返回127.0.0.1,改为动态获取本地地址

修复ssh隧道始终返回127.0.0.1,改为动态获取本地地址
Copy link

codecov bot commented Sep 14, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.05%. Comparing base (54bb3dc) to head (1720601).

Files with missing lines Patch % Lines
sql/utils/ssh_tunnel.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2808      +/-   ##
==========================================
- Coverage   78.05%   78.05%   -0.01%     
==========================================
  Files         122      122              
  Lines       17286    17290       +4     
==========================================
+ Hits        13493    13495       +2     
- Misses       3793     3795       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

LeoQuote
LeoQuote previously approved these changes Sep 14, 2024
Comment on lines 1520 to 1526
def test_get_local_ip(mocker: MockerFixture):
from sql.utils.ssh_tunnel import SSHTunnelForwarder

mock_start = mocker.patch.object(SSHTunnelForwarder, "start")
tunnel = SSHConnection("mysql", 3306, "tunnel", 22, "root", "password", "", "")
assert tunnel.get_local_ip() != "127.0.0.1"
assert mock_start.assert_called_once()
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bwcxyk 你能像这样描述下你的预期吗? 我这边测试这个结果返回就是 127.0.0.1 , 你要不按之前的实现, 从环境变量里读监听地址

Copy link
Author

Choose a reason for hiding this comment

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

返回127.0.0.1也算是正常的

Copy link
Collaborator

Choose a reason for hiding this comment

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

那什么环境下不返回 127? 能否描述下你的预期?

Copy link
Author

@bwcxyk bwcxyk Sep 14, 2024

Choose a reason for hiding this comment

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

那什么环境下不返回 127? 能否描述下你的预期?

如果机器没连接网络是会返回127.0.0.1的,python获取本地主机IP地址都是这个方法。
我在Archery容器中测试了是正常的。

Copy link
Author

Choose a reason for hiding this comment

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

我更换一种写法看看

Copy link
Author

Choose a reason for hiding this comment

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

我不知道这个测试是什么流程,但是我本地测试是没有问题的
image

@bwcxyk bwcxyk closed this Sep 14, 2024
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.

2 participants