using FastGithub.Configuration;
using Microsoft.Extensions.Options;
using System;
using System.Net.Sockets;
namespace FastGithub.ReverseProxy
{
///
/// 端口管理服务
///
public class PortService
{
private int httpsReverseProxyPort = -1;
///
/// http代理端口
///
public int HttpProxyPort { get; }
///
/// 获取https反向代理端口
///
public int HttpsReverseProxyPort
{
get
{
if (OperatingSystem.IsWindows())
{
return 443;
}
if (this.httpsReverseProxyPort < 0)
{
this.httpsReverseProxyPort = LocalMachine.GetAvailablePort(AddressFamily.InterNetwork);
}
return this.httpsReverseProxyPort;
}
}
///
/// 端口管理服务
///
///
public PortService(IOptions options)
{
this.HttpProxyPort = options.Value.HttpProxyPort;
}
}
}