Fix first Tailscale connection fallback in Windows 0.3.14
This commit is contained in:
@@ -40,7 +40,7 @@ internal static class NodeTransportConnector
|
||||
{
|
||||
selected = fallback!;
|
||||
tailnet = false;
|
||||
diagnostic?.Invoke(new("rebind_fallback", "ping_unreachable", ""));
|
||||
diagnostic?.Invoke(new("rebind_fallback", "endpoint_unreachable", ""));
|
||||
}
|
||||
}
|
||||
await start(selected, deadline.Token);
|
||||
@@ -96,9 +96,9 @@ internal static class NodeTransportConnector
|
||||
{
|
||||
try
|
||||
{
|
||||
status("正在 Ping 代理内网 IP(最多 1 秒)");
|
||||
status("正在检测 Tailscale 代理端口(最多 5 秒)");
|
||||
if (!await endpointProbe(TailnetTransport.Address(tailnet)!, TailnetTransport.Port(tailnet), token))
|
||||
throw new IOException("代理内网 IP Ping 不通。");
|
||||
throw new IOException("Tailscale 代理端口不可达。");
|
||||
token.ThrowIfCancellationRequested();
|
||||
}
|
||||
catch (Exception e) when (e is not OperationCanceledException && e is not ClientRuntimeException)
|
||||
@@ -107,7 +107,7 @@ internal static class NodeTransportConnector
|
||||
tailnet = null;
|
||||
reason = "endpoint_unreachable";
|
||||
Report("tailnet_skipped", reason);
|
||||
status("内网 IP Ping 不通,使用同一节点公网入口");
|
||||
status("Tailscale 代理端口不可达,使用同一节点公网入口");
|
||||
}
|
||||
}
|
||||
if (tailnet is not null)
|
||||
|
||||
@@ -107,16 +107,18 @@ internal static class TailnetTransport
|
||||
token.ThrowIfCancellationRequested();
|
||||
if (!IsTailnetAddress(address) || port is < 1 or > 65535) return false;
|
||||
using var deadline = CancellationTokenSource.CreateLinkedTokenSource(token);
|
||||
deadline.CancelAfter(TimeSpan.FromSeconds(1));
|
||||
deadline.CancelAfter(TimeSpan.FromSeconds(5));
|
||||
try
|
||||
{
|
||||
RequireProbeRoute(address);
|
||||
using var ping = new Ping();
|
||||
var reply = await ping.SendPingAsync(IPAddress.Parse(address), 1000).WaitAsync(deadline.Token).ConfigureAwait(false);
|
||||
return reply.Status == IPStatus.Success;
|
||||
// The first connection may need to establish a Tailscale path.
|
||||
// Test the actual proxy listener instead of gating on ICMP.
|
||||
using var socket = new TcpClient(AddressFamily.InterNetwork);
|
||||
await socket.ConnectAsync(IPAddress.Parse(address), port, deadline.Token).ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
catch (OperationCanceledException) when (!token.IsCancellationRequested) { return false; }
|
||||
catch (Exception e) when (e is PingException or SocketException or NetworkInformationException
|
||||
catch (Exception e) when (e is SocketException or NetworkInformationException
|
||||
or InvalidOperationException or IOException or System.ComponentModel.Win32Exception) { return false; }
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ internal static class TailnetTransportProbe
|
||||
var prepared = TailnetTransport.TryPrepare(response, allowKnownEndpoints: true) ?? throw new InvalidOperationException("probe_not_eligible");
|
||||
endpoint = TailnetTransport.Address(prepared)!;
|
||||
checks["same_authorized_fallback"] = TailnetTransport.SameAuthorizedFallback(prepared, response.GetRuntimeConfigJson());
|
||||
checks["three_second_preflight"] = await TailnetTransport.ProbeEndpointAsync(endpoint, TailnetTransport.Port(prepared), deadline.Token);
|
||||
checks["tcp_endpoint_preflight"] = await TailnetTransport.ProbeEndpointAsync(endpoint, TailnetTransport.Port(prepared), deadline.Token);
|
||||
if (!checks.Values.All(v => v)) throw new IOException("probe_preflight_failed");
|
||||
var interfaceName = TailnetTransport.RequireExistingRoute(endpoint);
|
||||
var runtime = JsonNode.Parse(TunConfigBuilder.Build(prepared, interfaceName, false,
|
||||
|
||||
@@ -270,7 +270,7 @@ internal static class TailnetTransportSelfTest
|
||||
selected = await NodeTransportConnector.ConnectAsync(known,deniedPreference,Start,Stop,Healthy,Route,statuses.Add,()=>tick,CancellationToken.None,
|
||||
allowKnownEndpoints:true, endpointProbe:(_,_,_)=>Task.FromResult(false));
|
||||
checks["closed_port_skips_tailnet_start_and_stop"] = !selected && starts.SequenceEqual(new[]{"002.vpn.toplc.cn"}) && stops == beforeStops && probes == 0;
|
||||
checks["ping_unreachable_status_is_distinct_from_route_failure"] = statuses.Last() == "内网 IP Ping 不通,使用同一节点公网入口";
|
||||
checks["endpoint_unreachable_status_is_distinct_from_route_failure"] = statuses.Last() == "Tailscale 代理端口不可达,使用同一节点公网入口";
|
||||
checks["closed_port_sets_node_cooldown"] = !deniedPreference.MayTry(known.Node.Slug,tick+1);
|
||||
starts.Clear();
|
||||
selected = await NodeTransportConnector.ConnectAsync(known,deniedPreference,Start,Stop,Healthy,Route,_=>{},()=>tick+1,CancellationToken.None,
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
<ApplicationIcon>assets\zonghengjia-app-v1.ico</ApplicationIcon>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
|
||||
<Version>0.3.13</Version>
|
||||
<AssemblyVersion>0.3.13.0</AssemblyVersion>
|
||||
<FileVersion>0.3.13.0</FileVersion>
|
||||
<InformationalVersion>0.3.13</InformationalVersion>
|
||||
<Version>0.3.14</Version>
|
||||
<AssemblyVersion>0.3.14.0</AssemblyVersion>
|
||||
<FileVersion>0.3.14.0</FileVersion>
|
||||
<InformationalVersion>0.3.14</InformationalVersion>
|
||||
<Product>纵横家</Product>
|
||||
<Company>优创未来(UCVL)</Company>
|
||||
<Description>纵横家 Windows 智能网络客户端</Description>
|
||||
|
||||
Reference in New Issue
Block a user