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

新增关键词过滤 #29

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions shadowsocks-csharp/Data/cn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ URL=网址
Group name=组名
Last Update=最近更新
Auto update=自动更新
Filter Text=排除关键词

# Messages

Expand Down
1 change: 1 addition & 0 deletions shadowsocks-csharp/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class ServerSubscribe

public string URL = DEFAULT_FEED_URL;
public string Group;
public string FilterText;
public UInt64 LastUpdateTime;
}

Expand Down
20 changes: 20 additions & 0 deletions shadowsocks-csharp/View/MenuViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e) {
urls.Add(selected_server.GetSSRLinkForServer());
}
}
//排除关键词
string filterText = updateFreeNodeChecker.subscribeTask.FilterText;
string[] filter_texts = { };
if (!String.IsNullOrEmpty(filterText)) {
filter_texts = filterText.Split(',');
}

// import all, find difference
{
Expand All @@ -477,6 +483,20 @@ void updateFreeNodeChecker_NewFreeNodeFound(object sender, EventArgs e) {
}
}
old_insert_servers[server.id] = server;
//排除关键词
if (filter_texts.Length > 0)
{
foreach (string filter_text in filter_texts)
{
if (server.remarks.Contains(filter_text))
{
match = true;
Logging.Log(LogLevel.Debug, "server will be remove:" + server.remarks);
break;
}
}
}
//
if (!match) {
foreach (KeyValuePair<string, Server> pair in old_servers) {
if (server.isMatchServer(pair.Value)) {
Expand Down
113 changes: 60 additions & 53 deletions shadowsocks-csharp/View/SubscribeForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions shadowsocks-csharp/View/SubscribeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private void UpdateTexts()
buttonOK.Text = I18N.GetString("OK");
buttonCancel.Text = I18N.GetString("Cancel");
label3.Text = I18N.GetString("Last Update");
label4.Text = I18N.GetString("Filter Text");
}

private void SubscribeForm_FormClosed(object sender, FormClosedEventArgs e)
Expand Down Expand Up @@ -124,6 +125,7 @@ private void UpdateSelected(int index)
ServerSubscribe ss = _modifiedConfiguration.serverSubscribes[index];
textBoxURL.Text = ss.URL;
textBoxGroup.Text = ss.Group;
textBoxFilter.Text = ss.FilterText;
_old_select_index = index;
if (ss.LastUpdateTime != 0)
{
Expand All @@ -149,6 +151,7 @@ private void SaveSelected(int index)
ss.Group = "";
ss.LastUpdateTime = 0;
}
ss.FilterText = textBoxFilter.Text;
}
}

Expand Down