-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
修复ssh隧道始终返回127.0.0.1,改为动态获取本地地址
Codecov ReportAttention: Patch coverage is
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. |
sql/utils/tests.py
Outdated
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() |
There was a problem hiding this comment.
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 , 你要不按之前的实现, 从环境变量里读监听地址
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
返回127.0.0.1也算是正常的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那什么环境下不返回 127? 能否描述下你的预期?
There was a problem hiding this comment.
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容器中测试了是正常的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我更换一种写法看看
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复ssh隧道始终返回127.0.0.1,改为动态获取本地地址