private double Algorithm3(ServerSpeedLog serverSpeedLog) { if (serverSpeedLog.ErrorContinurousTimes > 30) { return(1); } else if (serverSpeedLog.TotalConnectTimes < 3) { return(500); } else if (serverSpeedLog.AvgConnectTime < 0) { return(1); } else { long connections = serverSpeedLog.TotalConnectTimes - serverSpeedLog.TotalDisconnectTimes; double chance = 20.0 / (serverSpeedLog.AvgConnectTime / 500 + 1) - connections; if (chance > 500) { chance = 500; } chance -= serverSpeedLog.ErrorContinurousTimes * 2; if (chance < 1) { chance = 1; } return(chance); } }
private double Algorithm2(ServerSpeedLog serverSpeedLog) { if (serverSpeedLog.ErrorContinurousTimes > 30) { return(1); } else if (serverSpeedLog.TotalConnectTimes < 3) { return(500); } else if (serverSpeedLog.AvgConnectTime < 0) { return(1); } else if (serverSpeedLog.AvgConnectTime <= 20) { return(500); } else { double chance = 10000.0 / serverSpeedLog.AvgConnectTime; if (chance > 500) { chance = 500; } chance -= serverSpeedLog.ErrorContinurousTimes * 10; if (chance < 1) { chance = 1; } return(chance); } }
public void CopyServer(Server Server) { this.serverSpeedLog = Server.serverSpeedLog; this.dnsBuffer = Server.dnsBuffer; this.dnsTargetBuffer = Server.dnsTargetBuffer; this.Connections = Server.Connections; this.enable = Server.enable; }
public void CopyServer(Server Server) { protocoldata = Server.protocoldata; obfsdata = Server.obfsdata; serverSpeedLog = Server.serverSpeedLog; dnsBuffer = Server.dnsBuffer; Connections = Server.Connections; enable = Server.enable; }
public void InheritDataFrom(Server Server) { protocoldata = Server.protocoldata; obfsdata = Server.obfsdata; serverSpeedLog = Server.serverSpeedLog; dnsBuffer = Server.dnsBuffer; Connections = Server.Connections; //enable = Server.enable; }
private double Algorithm4(ServerSpeedLog serverSpeedLog, long avg_speed, double zero_chance) // perfer fast speed { if (serverSpeedLog.ErrorContinuousTimes >= 20) { return(1); } if (serverSpeedLog.ErrorContinuousTimes >= 10) { return(MIN_CHANCE); } if (serverSpeedLog.AvgConnectTime < 0 && serverSpeedLog.TotalConnectTimes >= 3) { return(MIN_CHANCE); } if (serverSpeedLog.TotalConnectTimes < 1) { return(MAX_CHANCE); } long avgConnectTime = serverSpeedLog.AvgConnectTime <= 0 ? 1 : serverSpeedLog.AvgConnectTime / 2000 * 2000; serverSpeedLog.GetTransSpeed(out _, out var speed_d); if (serverSpeedLog.TotalConnectTimes >= 1 && serverSpeedLog.AvgConnectTime < 0) { avgConnectTime = 5000; } var speed_mul = speed_d > avg_speed ? 1.0 : speed_d == 0 ? zero_chance : speed_d < avg_speed / 2 ? 0.001 : 0.005; var connections = serverSpeedLog.TotalConnectTimes - serverSpeedLog.TotalDisconnectTimes; var chance = MAX_CHANCE * speed_mul / (avgConnectTime / 500 + 1) - connections * CONNECTION_PENALTY; if (chance > MAX_CHANCE) { chance = MAX_CHANCE; } chance -= serverSpeedLog.ErrorContinuousTimes * ERROR_PENALTY; if (chance < MIN_CHANCE) { chance = MIN_CHANCE; } return(chance); }
private double Algorithm3(ServerSpeedLog serverSpeedLog) { if (serverSpeedLog.ErrorContinurousTimes > 30) return 1; else if (serverSpeedLog.TotalConnectTimes < 3) return 500; else if (serverSpeedLog.AvgConnectTime < 0) return 1; else { double chance = 20.0 / (serverSpeedLog.AvgConnectTime / 500 + 1); if (chance > 500) chance = 500; chance -= serverSpeedLog.ErrorContinurousTimes * 2; if (chance < 1) chance = 1; return chance; } }
private double Algorithm3(ServerSpeedLog serverSpeedLog) // perfer less error { if (serverSpeedLog.ErrorContinuousTimes >= 20) { return(1); } if (serverSpeedLog.ErrorContinuousTimes >= 10) { return(MIN_CHANCE); } if (serverSpeedLog.AvgConnectTime < 0 && serverSpeedLog.TotalConnectTimes >= 3) { return(MIN_CHANCE); } if (serverSpeedLog.TotalConnectTimes < 1) { return(MAX_CHANCE); } long avgConnectTime = serverSpeedLog.AvgConnectTime <= 0 ? 1 : serverSpeedLog.AvgConnectTime / 1000 * 1000; if (serverSpeedLog.TotalConnectTimes >= 1 && serverSpeedLog.AvgConnectTime < 0) { avgConnectTime = 5000; } var connections = serverSpeedLog.TotalConnectTimes - serverSpeedLog.TotalDisconnectTimes; var chance = MAX_CHANCE * 1.0 / (avgConnectTime / 500 + 1) - connections * CONNECTION_PENALTY; if (chance > MAX_CHANCE) { chance = MAX_CHANCE; } chance -= serverSpeedLog.ErrorContinuousTimes * ERROR_PENALTY; if (chance < MIN_CHANCE) { chance = MIN_CHANCE; } return(chance); }
private double Algorithm2(ServerSpeedLog serverSpeedLog) { if (serverSpeedLog.ErrorContinurousTimes > 30) return 1; else if (serverSpeedLog.TotalConnectTimes < 3) return 500; else if (serverSpeedLog.AvgConnectTime < 0) return 1; else if (serverSpeedLog.AvgConnectTime <= 20) return 500; else { long connections = serverSpeedLog.TotalConnectTimes - serverSpeedLog.TotalDisconnectTimes; double chance = 10000.0 / serverSpeedLog.AvgConnectTime - connections * 5; if (chance > 500) chance = 500; chance -= serverSpeedLog.ErrorContinurousTimes * 10; if (chance < 1) chance = 1; return chance; } }
private double Algorithm2(ServerSpeedLog serverSpeedLog) // perfer less delay { 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; if (serverSpeedLog.TotalConnectTimes >= 1 && serverSpeedLog.AvgConnectTime < 0) { avgConnectTime = 5000; } long connections = serverSpeedLog.TotalConnectTimes - serverSpeedLog.TotalDisconnectTimes; double chance = MAX_CHANCE * 10.0 / avgConnectTime - connections * CONNECTION_PENALTY; if (chance > MAX_CHANCE) { chance = MAX_CHANCE; } chance -= serverSpeedLog.ErrorContinurousTimes * ERROR_PENALTY; if (chance < MIN_CHANCE) { chance = MIN_CHANCE; } return(chance); } }
public void SetServerSpeedLog(ServerSpeedLog log) { serverSpeedLog = log; }
public void SetServerSpeedLog(ServerSpeedLog log) { log.AvgConnectTime = serverSpeedLog.AvgConnectTime; serverSpeedLog = log; }