From 3824e514bb9635176283748c88fd9bc21faa24f1 Mon Sep 17 00:00:00 2001 From: snltty <1069410172@qq.com> Date: Wed, 4 Sep 2024 17:41:53 +0800 Subject: [PATCH] sync --- linker.libs/Crypto.cs | 1 - linker.tunnel/TunnelTransfer.cs | 28 ++-- .../transport/TransportUdpPortMap.cs | 4 +- linker.web/src/apis/config.js | 3 + linker.web/src/components/full/status/Api.vue | 18 ++- .../src/components/full/status/Index.vue | 5 +- .../src/components/full/status/Share.vue | 63 +++++++++ .../src/views/full/devices/TuntapShow.vue | 2 +- .../src/views/full/devices/UpdaterBtn.vue | 2 +- linker.web/src/views/net/Head.vue | 62 +-------- linker.web/src/views/net/List.vue | 14 +- linker.web/src/views/net/TuntapEdit.vue | 121 ------------------ linker/config/Config.cs | 18 ++- linker/plugins/capi/CApiStartup.cs | 7 +- linker/plugins/client/ClientStartup.cs | 7 + linker/plugins/client/config/Config.cs | 20 ++- linker/plugins/config/ConfigApiController.cs | 97 ++++++++++++++ linker/plugins/logger/LoggerStartup.cs | 5 + linker/plugins/relay/RelayTransfer.cs | 27 +++- linker/plugins/updater/UpdaterHelper.cs | 2 +- version.txt | 2 +- 21 files changed, 283 insertions(+), 225 deletions(-) create mode 100644 linker.web/src/components/full/status/Share.vue delete mode 100644 linker.web/src/views/net/TuntapEdit.vue diff --git a/linker.libs/Crypto.cs b/linker.libs/Crypto.cs index 09dbd485..0b6a706b 100644 --- a/linker.libs/Crypto.cs +++ b/linker.libs/Crypto.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Security.Cryptography; using System.Text; diff --git a/linker.tunnel/TunnelTransfer.cs b/linker.tunnel/TunnelTransfer.cs index 94244447..9ccda737 100644 --- a/linker.tunnel/TunnelTransfer.cs +++ b/linker.tunnel/TunnelTransfer.cs @@ -7,7 +7,6 @@ using System.Collections.Concurrent; using System.Net.Sockets; using System.Net; using linker.tunnel.wanport; -using System.Collections.Generic; namespace linker.tunnel { @@ -186,9 +185,12 @@ namespace linker.tunnel LoggerHelper.Instance.Error($"tunnel {transport.Name} get remote {remoteMachineId} external ip fail "); break; } - LoggerHelper.Instance.Info($"tunnel {transport.Name} got local external ip {localInfo.Result.ToJson()}"); - LoggerHelper.Instance.Info($"tunnel {transport.Name} got remote external ip {remoteInfo.Result.ToJson()}"); - LoggerHelper.Instance.Info($"tunnel {transportItem.ToJson()}"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Info($"tunnel {transport.Name} got local external ip {localInfo.Result.ToJson()}"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Info($"tunnel {transport.Name} got remote external ip {remoteInfo.Result.ToJson()}"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Info($"tunnel {transportItem.ToJson()}"); tunnelTransportInfo = new TunnelTransportInfo @@ -332,13 +334,13 @@ namespace linker.tunnel private void OnConnecting(TunnelTransportInfo tunnelTransportInfo) { - //if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) - LoggerHelper.Instance.Info($"tunnel connecting {tunnelTransportInfo.Remote.MachineId}->{tunnelTransportInfo.Remote.MachineName}"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Info($"tunnel connecting {tunnelTransportInfo.Remote.MachineId}->{tunnelTransportInfo.Remote.MachineName}"); } private void OnConnectBegin(TunnelTransportInfo tunnelTransportInfo) { - //if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) - LoggerHelper.Instance.Info($"tunnel connecting from {tunnelTransportInfo.Remote.MachineId}->{tunnelTransportInfo.Remote.MachineName}"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Info($"tunnel connecting from {tunnelTransportInfo.Remote.MachineId}->{tunnelTransportInfo.Remote.MachineName}"); } /// @@ -347,8 +349,8 @@ namespace linker.tunnel /// private void _OnConnected(ITunnelConnection connection) { - //if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) - LoggerHelper.Instance.Debug($"tunnel connect {connection.RemoteMachineId}->{connection.RemoteMachineName} success->{connection.IPEndPoint}"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Debug($"tunnel connect {connection.RemoteMachineId}->{connection.RemoteMachineName} success->{connection.IPEndPoint}"); //调用以下别人注册的回调 if (OnConnected.TryGetValue(Helper.GlobalString, out List> callbacks)) @@ -368,7 +370,8 @@ namespace linker.tunnel } private void OnConnectFail(TunnelTransportInfo tunnelTransportInfo) { - LoggerHelper.Instance.Error($"tunnel connect {tunnelTransportInfo.Remote.MachineId} fail"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Error($"tunnel connect {tunnelTransportInfo.Remote.MachineId} fail"); } private void ParseRemoteEndPoint(TunnelTransportInfo tunnelTransportInfo) @@ -425,7 +428,8 @@ namespace linker.tunnel { if (AddBackground(remoteMachineId, transactionId) == false) { - LoggerHelper.Instance.Error($"tunnel background {remoteMachineId}@{transactionId} already exists"); + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Error($"tunnel background {remoteMachineId}@{transactionId} already exists"); return; } Task.Run(async () => diff --git a/linker.tunnel/transport/TransportUdpPortMap.cs b/linker.tunnel/transport/TransportUdpPortMap.cs index 9a4af9da..b85cbca5 100644 --- a/linker.tunnel/transport/TransportUdpPortMap.cs +++ b/linker.tunnel/transport/TransportUdpPortMap.cs @@ -308,7 +308,9 @@ namespace linker.tunnel.transport await targetSocket.SendToAsync($"{flagTexts}-{tunnelTransportInfo.Local.MachineId}-{tunnelTransportInfo.FlowId}".ToBytes(), ep).ConfigureAwait(false); await targetSocket.ReceiveFromAsync(new byte[1024], new IPEndPoint(IPAddress.Any, 0)).WaitAsync(TimeSpan.FromMilliseconds(500)).ConfigureAwait(false); - LoggerHelper.Instance.Debug($"{Name} connect to {tunnelTransportInfo.Remote.MachineId}->{tunnelTransportInfo.Remote.MachineName} {ep} success"); + + if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG) + LoggerHelper.Instance.Debug($"{Name} connect to {tunnelTransportInfo.Remote.MachineId}->{tunnelTransportInfo.Remote.MachineName} {ep} success"); TunnelConnectionUdp result = new TunnelConnectionUdp { diff --git a/linker.web/src/apis/config.js b/linker.web/src/apis/config.js index 1f91e0cf..f3fa2d00 100644 --- a/linker.web/src/apis/config.js +++ b/linker.web/src/apis/config.js @@ -6,4 +6,7 @@ export const getConfig = () => { export const install = (data) => { return sendWebsocketMsg('configclient/install', data); +} +export const exportConfig = () => { + return sendWebsocketMsg('configclient/export'); } \ No newline at end of file diff --git a/linker.web/src/components/full/status/Api.vue b/linker.web/src/components/full/status/Api.vue index adbfab71..5b24955e 100644 --- a/linker.web/src/components/full/status/Api.vue +++ b/linker.web/src/components/full/status/Api.vue @@ -1,15 +1,13 @@