mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
fixup! PY-59608: Support ``wslproxy`` when routing is broken by VPN. When user runs VPN with default gateway pointing to the VPN server and configures interface weight, we can't connect to WSL using its egress IP (traffic to ``172.0.0.0/8`` goes to VPN instead of WSL). With ``wsl.proxy.connect.localhost`` enabled in registry we bind ``wslproxy`` to ``127.0.0.1`` which could be used in latest WSL2 to connect from Windows to Linux. It is a little bit slow, but still works. fixup! PY-59608: Support ``wslproxy`` when routing is broken by VPN. PY-59608: Support ``wslproxy`` when routing is broken by VPN. When user runs VPN with default gateway pointing to the VPN server and configures interface weight, we can't connect to WSL using its egress IP (traffic to ``172.0.0.0/8`` goes to VPN instead of WSL). With ``wsl.proxy.connect.localhost`` enabled in registry we bind ``wslproxy`` to ``127.0.0.1`` which could be used in latest WSL2 to connect from Windows to Linux. It is a little bit slow, but still works. Co-authored-by: Vladimir Lagunov <vladimir.lagunov@jetbrains.com> Merge-request: IJ-MR-105285 Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com> GitOrigin-RevId: 74b5ad4df9c5e95ca4ef53a465f07855a92aa324
25 lines
1008 B
Python
25 lines
1008 B
Python
# Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
|
|
|
import subprocess
|
|
import threading
|
|
|
|
|
|
def read_stderr(stderr):
|
|
while not stderr.closed:
|
|
text = stderr.readline()
|
|
if text:
|
|
print(f"STDERR: {text}")
|
|
|
|
|
|
process = subprocess.Popen(["./wslproxy", "--loopback"], shell=False,
|
|
stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE)
|
|
threading.Thread(target=read_stderr, args=[process.stderr], daemon=True).start()
|
|
egress_ip_addr = ".".join([str(byte) for byte in process.stdout.read(4)])
|
|
ingress_port = int.from_bytes(process.stdout.read(2), 'little')
|
|
print(f"Please go to WSL and connect to 127.0.0.1:{ingress_port}")
|
|
while True:
|
|
egress_port = int.from_bytes(process.stdout.read(2), 'little')
|
|
print(f"Please go to Windows and connect to {egress_ip_addr}:{egress_port}")
|