Skip to content

Commit

Permalink
Increase subscription renewal time
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jun 26, 2022
1 parent aa8369a commit 2841767
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 6 deletions.
4 changes: 3 additions & 1 deletion clashN/clashN/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ private void InitProfilesView()
lvProfiles.Columns.Add(ResUI.LvAddress, 60, HorizontalAlignment.Center);
lvProfiles.Columns.Add(ResUI.LvEnableTun, 60, HorizontalAlignment.Center);
lvProfiles.Columns.Add(ResUI.LvEnableUpdateSub, 100, HorizontalAlignment.Center);
lvProfiles.Columns.Add(ResUI.LvUpdateTime, 80, HorizontalAlignment.Center);

if (statistics != null && statistics.Enable)
{
Expand Down Expand Up @@ -289,7 +290,8 @@ private void RefreshProfilesView()
Utils.AddSubItem(lvItem, EProfileColName.address.ToString(), item.address.IsNullOrWhiteSpace() ? "" : Global.CheckMark);
Utils.AddSubItem(lvItem, EProfileColName.enableTun.ToString(), item.enableTun ? Global.CheckMark : "");
Utils.AddSubItem(lvItem, EProfileColName.enableUpdateSub.ToString(), (item.enabled ? Global.CheckMark : "") + (item.enableConvert ? $"({Global.CheckMark})" : ""));

Utils.AddSubItem(lvItem, EProfileColName.updateTime.ToString(), item.GetUpdateTime());

if (statistics != null && statistics.Enable)
{
string totalUp = string.Empty,
Expand Down
1 change: 1 addition & 0 deletions clashN/clashN/Handler/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ public static int SortProfiles(ref Config config, ref List<ProfileItem> lstProfi
case EProfileColName.remarks:
case EProfileColName.url:
case EProfileColName.testResult:
case EProfileColName.updateTime:
propertyName = name.ToString();
break;
default:
Expand Down
7 changes: 4 additions & 3 deletions clashN/clashN/Handler/UpdateHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public void UpdateSubscriptionProcess(Config config, bool blProxy, List<ProfileI
int ret = ConfigHandler.AddBatchProfiles(ref config, result, indexId, groupId);
if (ret == 0)
{
item.updateTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
_updateFunc(false, $"{hashCode}{ResUI.MsgUpdateSubscriptionEnd}");
}
else
Expand All @@ -237,7 +238,7 @@ public void UpdateSubscriptionProcess(Config config, bool blProxy, List<ProfileI
}
_updateFunc(false, $"-------------------------------------------------------");

}
}
//restore system proxy
if (bSysProxyType)
{
Expand Down Expand Up @@ -306,7 +307,7 @@ private async void CheckUpdateAsync(ECoreType type)
try
{
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);
string url = coreInfo.coreLatestUrl;
string url = coreInfo.coreLatestUrl;

var result = await (new DownloadHandle()).UrlRedirectAsync(url, true);
if (!Utils.IsNullOrEmpty(result))
Expand Down Expand Up @@ -378,7 +379,7 @@ private void responseHandler(ECoreType type, string redirectUrl)
{
string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
var coreInfo = LazyConfig.Instance.GetCoreInfo(type);

string curVersion;
string message;
string url;
Expand Down
16 changes: 14 additions & 2 deletions clashN/clashN/Mode/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Config

public int httpPort { get; set; }

public int socksPort { get; set; }
public int socksPort { get; set; }

public int APIPort { get; set; }

Expand All @@ -42,7 +42,7 @@ public class Config

public int autoUpdateInterval { get; set; } = 0;
public int autoUpdateSubInterval { get; set; } = 0;

public bool enableSecurityProtocolTls13 { get; set; }

#endregion
Expand Down Expand Up @@ -119,6 +119,7 @@ public ProfileItem()
testResult = string.Empty;
groupId = string.Empty;
enableTun = false;
enableConvert = false;
}

#region function
Expand All @@ -132,6 +133,15 @@ public void SetTestResult(string value)
{
testResult = value;
}
public string GetUpdateTime()
{
if (updateTime <= 0)
{
return String.Empty;
}
var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
return dateTime.AddSeconds(updateTime).ToLocalTime().ToString("MM/dd HH:mm");
}
#endregion

public string indexId
Expand Down Expand Up @@ -183,6 +193,8 @@ public string userAgent
public bool enableTun { get; set; }

public bool enableConvert { get; set; }

public long updateTime { get; set; }
}

[Serializable]
Expand Down
1 change: 1 addition & 0 deletions clashN/clashN/Mode/EProfileColName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum EProfileColName
enableTun,
enableUpdateSub,
testResult,
updateTime,

todayDown,
todayUp,
Expand Down
9 changes: 9 additions & 0 deletions clashN/clashN/Resx/ResUI.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 clashN/clashN/Resx/ResUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,7 @@
<data name="MsgUpdateCoreCoreFailed" xml:space="preserve">
<value>Update Core failed, see the log for details</value>
</data>
<data name="LvUpdateTime" xml:space="preserve">
<value>UpdateTime</value>
</data>
</root>
3 changes: 3 additions & 0 deletions clashN/clashN/Resx/ResUI.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,7 @@
<data name="MsgUpdateCoreCoreFailed" xml:space="preserve">
<value>更新Core失败,详情见日志</value>
</data>
<data name="LvUpdateTime" xml:space="preserve">
<value>更新时间</value>
</data>
</root>

0 comments on commit 2841767

Please sign in to comment.