Browse Source

fix speed test display

pull/2101/head
2dust 3 years ago
parent
commit
4d7cf140cd
  1. 6
      v2rayN/v2rayN/Forms/MainForm.cs
  2. 2
      v2rayN/v2rayN/Handler/SpeedtestHandler.cs
  3. 17
      v2rayN/v2rayN/Handler/V2rayConfigHandler.cs
  4. 22
      v2rayN/v2rayN/Mode/Config.cs

6
v2rayN/v2rayN/Forms/MainForm.cs

@ -288,7 +288,7 @@ namespace v2rayN.Forms
Utils.AddSubItem(lvItem, EServerColName.security.ToString(), item.security);
Utils.AddSubItem(lvItem, EServerColName.network.ToString(), item.network);
Utils.AddSubItem(lvItem, EServerColName.streamSecurity.ToString(), item.streamSecurity);
Utils.AddSubItem(lvItem, EServerColName.subRemarks.ToString(), item.getSubRemarks(config));
Utils.AddSubItem(lvItem, EServerColName.subRemarks.ToString(), item.GetSubRemarks(config));
Utils.AddSubItem(lvItem, EServerColName.testResult.ToString(), item.testResult);
if (stats)
{
@ -336,7 +336,7 @@ namespace v2rayN.Forms
for (int k = 0; k < lstVmess.Count; k++)
{
VmessItem item = lstVmess[k];
string name = item.getSummary();
string name = item.GetSummary();
if (config.IsActiveNode(item))
{
@ -355,7 +355,7 @@ namespace v2rayN.Forms
for (int k = 0; k < lstVmess.Count; k++)
{
VmessItem item = lstVmess[k];
string name = item.getSummary();
string name = item.GetSummary();
ToolStripMenuItem ts = new ToolStripMenuItem(name)
{

2
v2rayN/v2rayN/Handler/SpeedtestHandler.cs

@ -142,6 +142,7 @@ namespace v2rayN.Handler
string status = GetRealPingTime(_config.constItem.speedPingTestUrl, webProxy, out responseTime);
string output = Utils.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : status;
_config.GetVmessItem(it.indexId)?.SetTestResult(output);
_updateFunc(it.indexId, output);
}
catch (Exception ex)
@ -210,6 +211,7 @@ namespace v2rayN.Handler
DownloadHandle downloadHandle2 = new DownloadHandle();
downloadHandle2.UpdateCompleted += (sender2, args) =>
{
_config.GetVmessItem(testIndexId)?.SetTestResult(args.Msg);
_updateFunc(testIndexId, args.Msg);
};
downloadHandle2.Error += (sender2, args) =>

17
v2rayN/v2rayN/Handler/V2rayConfigHandler.cs

@ -80,7 +80,7 @@ namespace v2rayN.Handler
Utils.ToJsonFile(v2rayConfig, fileName, false);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{config.GetGroupRemarks(node.groupId)}] {node.getSummary()}");
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{config.GetGroupRemarks(node.groupId)}] {node.GetSummary()}");
}
catch
{
@ -584,7 +584,7 @@ namespace v2rayN.Handler
{
var config = LazyConfig.Instance.GetConfig();
//远程服务器底层传输配置
streamSettings.network = node.getNetwork();
streamSettings.network = node.GetNetwork();
string host = node.requestHost.TrimEx();
string sni = node.sni;
@ -596,7 +596,7 @@ namespace v2rayN.Handler
TlsSettings tlsSettings = new TlsSettings
{
allowInsecure = Utils.ToBool(node.allowInsecure),
alpn = node.getAlpn()
alpn = node.GetAlpn()
};
if (!string.IsNullOrWhiteSpace(sni))
{
@ -617,7 +617,7 @@ namespace v2rayN.Handler
TlsSettings xtlsSettings = new TlsSettings
{
allowInsecure = Utils.ToBool(node.allowInsecure),
alpn = node.getAlpn()
alpn = node.GetAlpn()
};
if (!string.IsNullOrWhiteSpace(sni))
{
@ -631,7 +631,7 @@ namespace v2rayN.Handler
}
//streamSettings
switch (node.getNetwork())
switch (node.GetNetwork())
{
//kcp基本配置暂时是默认值,用户能自己设置伪装类型
case "kcp":
@ -921,7 +921,7 @@ namespace v2rayN.Handler
}
File.Copy(addressFileName, fileName);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{LazyConfig.Instance.GetConfig().GetGroupRemarks(node.groupId)}] {node.getSummary()}");
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{LazyConfig.Instance.GetConfig().GetGroupRemarks(node.groupId)}] {node.GetSummary()}");
}
catch
{
@ -984,7 +984,7 @@ namespace v2rayN.Handler
Utils.ToJsonFile(v2rayConfig, fileName, false);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), node.getSummary());
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), node.GetSummary());
}
catch
{
@ -1471,9 +1471,8 @@ namespace v2rayN.Handler
inbound.tag = Global.InboundHttp + inbound.port.ToString();
v2rayConfig.inbounds.Add(inbound);
var index = configCopy.FindIndexId(it.indexId);
V2rayConfig v2rayConfigCopy = Utils.FromJson<V2rayConfig>(result);
outbound(configCopy.vmess[index], ref v2rayConfigCopy);
outbound(configCopy.GetVmessItem(it.indexId), ref v2rayConfigCopy);
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);

22
v2rayN/v2rayN/Mode/Config.cs

@ -245,6 +245,15 @@ namespace v2rayN.Mode
return vmess.FindIndex(it => it.indexId == id);
}
public VmessItem GetVmessItem(string id)
{
if (string.IsNullOrEmpty(id))
{
return null;
}
return vmess.FirstOrDefault(it => it.indexId == id);
}
public List<string> GetShadowsocksSecuritys()
{
if (coreType == ECoreType.v2fly_core)
@ -306,7 +315,7 @@ namespace v2rayN.Mode
}
#region function
public string getSummary()
public string GetSummary()
{
string summary = string.Format("[{0}] ", ((EConfigType)configType).ToString());
string[] arrAddr = address.Split('.');
@ -356,7 +365,7 @@ namespace v2rayN.Mode
}
return summary;
}
public string getSubRemarks(Config config)
public string GetSubRemarks(Config config)
{
string subRemarks = string.Empty;
if (Utils.IsNullOrEmpty(subid))
@ -377,7 +386,7 @@ namespace v2rayN.Mode
return subid.Substring(0, 4);
}
public List<string> getAlpn()
public List<string> GetAlpn()
{
if (alpn != null && alpn.Count > 0)
{
@ -388,7 +397,7 @@ namespace v2rayN.Mode
return null;
}
}
public string getNetwork()
public string GetNetwork()
{
if (Utils.IsNullOrEmpty(network) || !Global.networks.Contains(network))
{
@ -396,6 +405,11 @@ namespace v2rayN.Mode
}
return network.TrimEx();
}
public void SetTestResult(string value)
{
testResult = value;
}
#endregion
public string indexId

Loading…
Cancel
Save