diff --git a/src/NSmartProxy.ServerHost/ServerHost.cs b/src/NSmartProxy.ServerHost/ServerHost.cs index a92641f..a74f405 100644 --- a/src/NSmartProxy.ServerHost/ServerHost.cs +++ b/src/NSmartProxy.ServerHost/ServerHost.cs @@ -51,7 +51,7 @@ static void Main(string[] args) string msg = "Another instance of the program is running.It may cause fatal error."; //Logger.Error(msg, new Exception(msg)); Console.ForegroundColor = ConsoleColor.DarkRed; - Console.Write(msg); + Console.WriteLine(msg); //return; //Console.ForegroundColor = default(ConsoleColor); } diff --git a/src/NSmartProxy/Server.cs b/src/NSmartProxy/Server.cs index 1379321..f042267 100644 --- a/src/NSmartProxy/Server.cs +++ b/src/NSmartProxy/Server.cs @@ -389,22 +389,19 @@ private async Task ProcessHeartbeatProtocol(TcpClient client) int heartBeatLength = 2; byte[] appRequestBytes = new byte[heartBeatLength]; int resultByte = await nstream.ReadAsync(appRequestBytes, 0, appRequestBytes.Length, Global.DefaultConnectTimeout); - //Server.Logger.Debug("appRequestBytes received."); if (resultByte < 1) { CloseClient(client); return; } - //1.2 响应ACK - await nstream.WriteAndFlushAsync(new byte[] { 0x01 }, 0, 1); + int clientID = StringUtil.DoubleBytesToInt(appRequestBytes[0], appRequestBytes[1]); -#if DEBUG - //Server.Logger.Debug($"Now processing {clientID}'s Heartbeat protocol...."); -#endif ServerContext.ClientConnectCount += 1; //2.更新最后更新时间 if (ServerContext.Clients.ContainsKey(clientID)) { + //2.2 响应ACK + await nstream.WriteAndFlushAsync(new byte[] { 0x01 }, 0, 1); ServerContext.Clients[clientID].LastUpdateTime = DateTime.Now; } else @@ -438,10 +435,7 @@ private async Task ProcessAppRequestProtocol(TcpClient client, bool IsReco return false; } - //if (IsReconnect) 因为加入了始终校验的机制,取消重连规则 - //{ ServerContext.CloseAllSourceByClient(clientIdFromToken); - // } //1.3 获取客户端请求数 int configRequestLength = 3; diff --git a/src/NSmartProxyClient/appsettings.json b/src/NSmartProxyClient/appsettings.json index 84d4796..37da034 100644 --- a/src/NSmartProxyClient/appsettings.json +++ b/src/NSmartProxyClient/appsettings.json @@ -2,7 +2,7 @@ "ProviderPort": "19974", //反向连接的端口 "ProviderConfigPort": "12308", //配置服务的端口 //"ProviderAddress": "47.90.204.25", //配置服务的地址,可以是域名(eg.:www.tmoonlight.com)也可以是ip(eg.:211.54.5.4) - "ProviderAddress": "127.0.0.1", + "ProviderAddress": "192.168.0.106", //"ProviderAddress": "124.116.157.31", //反向代理客户端,可以配置多个