Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto switch server #506

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion shadowsocks-csharp/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ protected ConfigurationWarning(System.Runtime.Serialization.SerializationInfo in
[Serializable]
public class Configuration
{
public int errorCount;
public int errorThreshold = 10;
public List<Server> configs;
public int index;
public bool random;
Expand Down Expand Up @@ -169,7 +171,13 @@ public static bool SetPasswordTry(string old_password, string password)

public bool KeepCurrentServer(int localPort, string targetAddr, string id)
{
if (sameHostForSameTarget && targetAddr != null)
if (errorThreshold)
{
if(errorCount < errorThreshold) return true;
errorCount = 0;
return false;
}
else if (sameHostForSameTarget && targetAddr != null)
{
lock (serverStrategyMap)
{
Expand Down Expand Up @@ -414,6 +422,8 @@ public Configuration()

public void CopyFrom(Configuration config)
{
errorCount = config.errorCount;
errorThreshold = config.errorThreshold;
configs = config.configs;
index = config.index;
random = config.random;
Expand Down
Loading