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 @@