예제 #1
0
 public void CopyServer(Server Server)
 {
     protocoldata    = Server.protocoldata;
     obfsdata        = Server.obfsdata;
     serverSpeedLog  = Server.serverSpeedLog;
     dnsBuffer       = Server.dnsBuffer;
     dnsTargetBuffer = Server.dnsTargetBuffer;
     Connections     = Server.Connections;
     enable          = Server.enable;
 }
 private double Algorithm3(ServerSpeedLog serverSpeedLog) // perfer less error
 {
     if (serverSpeedLog.ErrorContinurousTimes >= 20)
     {
         return(1);
     }
     else if (serverSpeedLog.ErrorContinurousTimes >= 10)
     {
         return(MIN_CHANCE);
     }
     else if (serverSpeedLog.AvgConnectTime < 0 && serverSpeedLog.TotalConnectTimes >= 3)
     {
         return(MIN_CHANCE);
     }
     else if (serverSpeedLog.TotalConnectTimes < 1)
     {
         return(MAX_CHANCE);
     }
     else
     {
         long avgConnectTime = serverSpeedLog.AvgConnectTime <= 0 ? 1 : serverSpeedLog.AvgConnectTime / 1000;
         if (serverSpeedLog.TotalConnectTimes >= 1 && serverSpeedLog.AvgConnectTime < 0)
         {
             avgConnectTime = 5000;
         }
         long   connections = serverSpeedLog.TotalConnectTimes - serverSpeedLog.TotalDisconnectTimes;
         double chance      = MAX_CHANCE * 1.0 / (avgConnectTime / 500 + 1) - connections * CONNECTION_PENALTY;
         if (chance > MAX_CHANCE)
         {
             chance = MAX_CHANCE;
         }
         chance -= serverSpeedLog.ErrorContinurousTimes * ERROR_PENALTY;
         if (chance < MIN_CHANCE)
         {
             chance = MIN_CHANCE;
         }
         return(chance);
     }
 }
예제 #3
0
 public void SetServerSpeedLog(ServerSpeedLog log)
 {
     serverSpeedLog = log;
 }