|
|
@@ -10,19 +10,30 @@ using Spire.Pdf.Exporting.XPS.Schema;
|
|
|
using System.Xml.Linq;
|
|
|
using System.Net;
|
|
|
using TencentCloud.Mrs.V20200910.Models;
|
|
|
+using static molilian.core.TkPoolCore;
|
|
|
|
|
|
|
|
|
namespace molilian.core
|
|
|
{
|
|
|
public partial class ProxyNodesCore
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+ private static string _end_point;
|
|
|
+ static ProxyNodesCore()
|
|
|
+ {
|
|
|
+ _end_point = Environment.GetEnvironmentVariable("EndPoint");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static readonly object _lockObj = new();
|
|
|
private static IEnumerable<ProxyNodesDTO> _cached;
|
|
|
public static WebProxy? GetOne(string node)
|
|
|
{
|
|
|
var list = List();
|
|
|
if (!list.Any()) return null;
|
|
|
- var ProxyNodesDTO = list.Where(s => s.name == node).FirstOrDefault();
|
|
|
+ //var ProxyNodesDTO = list.Where(s => s.name == node).FirstOrDefault();
|
|
|
+ var ProxyNodesDTO = list.Where(e => SelectEndPointUseProxy(e, node)).OrderBy(l => Guid.NewGuid()).FirstOrDefault();
|
|
|
if (ProxyNodesDTO == null) return null;
|
|
|
|
|
|
return new WebProxy
|
|
|
@@ -31,6 +42,15 @@ namespace molilian.core
|
|
|
Credentials = new NetworkCredential(ProxyNodesDTO.username, ProxyNodesDTO.password)
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ private static bool SelectEndPointUseProxy(ProxyNodesDTO item, string node)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(_end_point) && !string.IsNullOrEmpty(item.end_point))
|
|
|
+ {
|
|
|
+ if (item.end_point != _end_point) return false;
|
|
|
+ }
|
|
|
+ return item.name == node;
|
|
|
+ }
|
|
|
public static IEnumerable<ProxyNodesDTO> List(bool force = false)
|
|
|
{
|
|
|
if (!force && _cached != null) return _cached;
|