2020-10-02 18:29:25 +00:00
|
|
|
using System;
|
|
|
|
using NzbDrone.Common.Extensions;
|
2016-02-02 18:42:22 +00:00
|
|
|
|
2016-04-25 19:53:26 +00:00
|
|
|
namespace NzbDrone.Common.Http.Proxy
|
2016-02-02 18:42:22 +00:00
|
|
|
{
|
2016-04-25 19:53:26 +00:00
|
|
|
public class HttpProxySettings
|
2016-02-02 18:42:22 +00:00
|
|
|
{
|
2016-04-25 19:53:26 +00:00
|
|
|
public HttpProxySettings(ProxyType type, string host, int port, string bypassFilter, bool bypassLocalAddress, string username = null, string password = null)
|
2016-02-02 18:42:22 +00:00
|
|
|
{
|
|
|
|
Type = type;
|
2016-04-24 14:20:45 +00:00
|
|
|
Host = host.IsNullOrWhiteSpace() ? "127.0.0.1" : host;
|
2016-02-02 18:42:22 +00:00
|
|
|
Port = port;
|
2016-04-24 14:20:45 +00:00
|
|
|
Username = username ?? string.Empty;
|
|
|
|
Password = password ?? string.Empty;
|
|
|
|
BypassFilter = bypassFilter ?? string.Empty;
|
2016-04-24 15:56:31 +00:00
|
|
|
BypassLocalAddress = bypassLocalAddress;
|
2016-02-02 18:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ProxyType Type { get; private set; }
|
|
|
|
public string Host { get; private set; }
|
|
|
|
public int Port { get; private set; }
|
|
|
|
public string Username { get; private set; }
|
|
|
|
public string Password { get; private set; }
|
2016-04-24 14:20:45 +00:00
|
|
|
public string BypassFilter { get; private set; }
|
2016-02-02 18:42:22 +00:00
|
|
|
public bool BypassLocalAddress { get; private set; }
|
|
|
|
|
2016-05-02 10:24:51 +00:00
|
|
|
public string[] BypassListAsArray
|
2016-02-02 18:42:22 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2016-04-24 14:20:45 +00:00
|
|
|
if (!string.IsNullOrWhiteSpace(BypassFilter))
|
2016-02-02 18:42:22 +00:00
|
|
|
{
|
2016-05-02 10:24:51 +00:00
|
|
|
var hostlist = BypassFilter.Split(',');
|
2023-05-23 10:52:39 +00:00
|
|
|
for (var i = 0; i < hostlist.Length; i++)
|
2016-05-02 10:24:51 +00:00
|
|
|
{
|
2019-12-22 22:08:53 +00:00
|
|
|
if (hostlist[i].StartsWith("*"))
|
2016-05-02 10:24:51 +00:00
|
|
|
{
|
|
|
|
hostlist[i] = ";" + hostlist[i];
|
|
|
|
}
|
|
|
|
}
|
2019-12-22 22:08:53 +00:00
|
|
|
|
2016-05-02 10:24:51 +00:00
|
|
|
return hostlist;
|
2016-02-02 18:42:22 +00:00
|
|
|
}
|
2019-12-22 22:08:53 +00:00
|
|
|
|
2020-10-02 18:29:25 +00:00
|
|
|
return Array.Empty<string>();
|
2016-02-02 18:42:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
public string Key => string.Join("_",
|
|
|
|
Type,
|
|
|
|
Host,
|
|
|
|
Port,
|
|
|
|
Username,
|
|
|
|
Password,
|
|
|
|
BypassFilter,
|
|
|
|
BypassLocalAddress);
|
2016-02-02 18:42:22 +00:00
|
|
|
}
|
|
|
|
}
|