Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Apr 28, 2024
1 parent 8940a48 commit 19c8af5
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions clashN/clashN/Handler/UpdateHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,6 @@ public void UpdateSubscriptionProcess(Config config, bool blProxy, List<ProfileI

Task.Run(async () =>
{
//Turn off system proxy
//bool bSysProxyType = false;
//if (!blProxy && config.SysProxyType == SysProxyType.ForcedChange)
//{
// bSysProxyType = true;
// config.SysProxyType = SysProxyType.ForcedClear;
// SysProxyHandle.UpdateSysProxy(config, false);
// Thread.Sleep(3000);
//}
if (profileItems == null)
{
profileItems = config.ProfileItems;
Expand Down Expand Up @@ -216,35 +206,37 @@ public void UpdateSubscriptionProcess(Config config, bool blProxy, List<ProfileI
{
_updateFunc(false, $"{hashCode}{args.GetException().Message}");
};
var result = (await downloadHandle.DownloadStringAsync(url, blProxy, userAgent)) ?? throw new Exception();
if (blProxy && string.IsNullOrEmpty(result.Item1))
var result = (await downloadHandle.DownloadStringAsync(url, blProxy, userAgent));
if (blProxy && string.IsNullOrEmpty(result?.Item1))
{
result = (await downloadHandle.DownloadStringAsync(url, false, userAgent)) ?? throw new Exception();
result = (await downloadHandle.DownloadStringAsync(url, false, userAgent));
}
var resultContent = result?.Item1;
var resultHeader = result?.Item2;
if (string.IsNullOrEmpty(result.Item1))
if (string.IsNullOrEmpty(resultContent))
{
_updateFunc(false, $"{hashCode}{ResUI.MsgSubscriptionDecodingFailed}");
}
else
{
_updateFunc(false, $"{hashCode}{ResUI.MsgGetSubscriptionSuccessfully}");
if (result.Item1.Length < 99)
if (resultContent.Length < 99)
{
_updateFunc(false, $"{hashCode}{result}");
}
int ret = ConfigProc.AddBatchProfiles(ref config, result.Item1, indexId, groupId);
int ret = ConfigProc.AddBatchProfiles(ref config, resultContent, indexId, groupId);
if (ret == 0)
{
item.updateTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
//get remote info
try
{
if (result.Item2 != null && result.Item2 is HttpResponseHeaders)
if (resultHeader != null && resultHeader is HttpResponseHeaders)
{
var userinfo = ((HttpResponseHeaders)result.Item2)
var userinfo = ((HttpResponseHeaders)resultHeader)
.Where(t => t.Key.ToLower() == "subscription-userinfo")
.Select(t => t.Value)
.FirstOrDefault()?
Expand Down Expand Up @@ -276,12 +268,6 @@ public void UpdateSubscriptionProcess(Config config, bool blProxy, List<ProfileI
}
_updateFunc(false, $"-------------------------------------------------------");
}
//restore system proxy
//if (bSysProxyType)
//{
// config.SysProxyType = SysProxyType.ForcedChange;
// SysProxyHandle.UpdateSysProxy(config, false);
//}
_updateFunc(true, $"{ResUI.MsgUpdateSubscriptionEnd}");
});
}
Expand Down

0 comments on commit 19c8af5

Please sign in to comment.