2022-10-06 17:44:08 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-03-09 00:32:02 +08:00
|
|
|
using BarrageGrab.JsonEntity;
|
2022-10-06 17:44:08 +08:00
|
|
|
using static System.Configuration.ConfigurationManager;
|
|
|
|
|
namespace BarrageGrab
|
|
|
|
|
{
|
|
|
|
|
internal class Appsetting
|
|
|
|
|
{
|
|
|
|
|
private static readonly Appsetting ins = new Appsetting();
|
|
|
|
|
|
2023-03-09 00:32:02 +08:00
|
|
|
public static Appsetting Current { get => ins; }
|
2022-11-05 16:39:35 +08:00
|
|
|
|
|
|
|
|
public Appsetting()
|
|
|
|
|
{
|
2023-03-09 00:32:02 +08:00
|
|
|
try
|
|
|
|
|
{
|
2023-03-09 01:23:46 +08:00
|
|
|
ProcessFilter = AppSettings["processFilter"].Trim().Split(',');
|
2023-03-09 00:32:02 +08:00
|
|
|
WsProt = int.Parse(AppSettings["wsListenPort"]);
|
|
|
|
|
PrintBarrage = AppSettings["printBarrage"].ToLower() == "true";
|
2023-03-09 01:23:46 +08:00
|
|
|
ProxyPort = int.Parse(AppSettings["proxyPort"]);
|
2023-03-09 00:32:02 +08:00
|
|
|
PrintFilter = Enum.GetValues(typeof(BarrageMsgType)).Cast<int>().ToArray();
|
2023-03-09 01:23:46 +08:00
|
|
|
FilterHostName = bool.Parse(AppSettings["filterHostName"].Trim());
|
2023-03-09 01:39:16 +08:00
|
|
|
HostNameFilter = AppSettings["hostNameFilter"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).ToArray();
|
2023-03-09 00:32:02 +08:00
|
|
|
//RoomIds = AppSettings["roomIds"].Trim().Split(',').Where(w=>!string.IsNullOrWhiteSpace(w)).Select(s => long.Parse(s)).ToArray();
|
2022-11-05 16:39:35 +08:00
|
|
|
|
2023-03-09 00:32:02 +08:00
|
|
|
var printFilter = AppSettings["printFilter"].Trim().ToLower();
|
|
|
|
|
if (printFilter != "all")
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(printFilter)) PrintFilter = new int[0];
|
|
|
|
|
else PrintFilter = printFilter.Split(',').Select(x => int.Parse(x)).ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("配置文件读取失败,请检查配置文件是否正确");
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
2022-10-06 17:44:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 过滤的进程
|
|
|
|
|
/// </summary>
|
2023-03-09 01:23:46 +08:00
|
|
|
public string[] ProcessFilter { get; private set; }
|
2022-10-06 17:44:08 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 端口号
|
|
|
|
|
/// </summary>
|
2022-11-05 16:39:35 +08:00
|
|
|
public int WsProt { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 控制台打印消息开关
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool PrintBarrage { get; private set; }
|
2023-03-04 14:52:04 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 代理端口
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int ProxyPort { get; private set; } = 8827;
|
2023-03-09 00:32:02 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 控制台输出过滤器
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int[] PrintFilter { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 监听的房间号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public long[] RoomIds { get; private set; } = new long[0];
|
2023-03-09 01:23:46 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 使用域名过滤
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool FilterHostName { get; private set; } = true;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 域名白名单列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string[] HostNameFilter { get; private set; } = new string[0];
|
2022-10-06 17:44:08 +08:00
|
|
|
}
|
|
|
|
|
}
|