Refactor: name, namespace

This commit is contained in:
ChsBuffer
2021-04-30 15:24:37 +08:00
parent 258880ef95
commit fb64951003
33 changed files with 137 additions and 115 deletions

View File

@@ -0,0 +1,14 @@
using System.Net;
using System.Net.NetworkInformation;
namespace Netch.Interfaces
{
public interface IAdapter
{
ulong InterfaceIndex { get; }
IPAddress Gateway { get; }
NetworkInterface NetworkInterface { get; }
}
}

View File

@@ -0,0 +1,15 @@
namespace Netch.Interfaces
{
public interface IController
{
/// <summary>
/// 控制器名
/// </summary>
public string Name { get; }
/// <summary>
/// 停止
/// </summary>
public void Stop();
}
}

View File

@@ -0,0 +1,14 @@
using Netch.Models;
namespace Netch.Interfaces
{
public interface IModeController : IController
{
/// <summary>
/// 启动
/// </summary>
/// <param name="mode">模式</param>
/// <returns>是否成功</returns>
public abstract void Start(in Mode mode);
}
}

View File

@@ -0,0 +1,32 @@
using Netch.Models;
namespace Netch.Interfaces
{
public interface IServerController : IController
{
public ushort? Socks5LocalPort { get; set; }
public string? LocalAddress { get; set; }
/// <summary>
/// 启动
/// </summary>
/// <param name="s">服务器</param>
/// <param name="mode">模式</param>
/// <returns>是否启动成功</returns>
public abstract void Start(in Server s, in Mode mode);
}
public static class ServerControllerExtension
{
public static ushort Socks5LocalPort(this IServerController controller)
{
return controller.Socks5LocalPort ?? Global.Settings.Socks5LocalPort;
}
public static string LocalAddress(this IServerController controller)
{
return controller.LocalAddress ?? Global.Settings.LocalAddress;
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using Netch.Models;
namespace Netch.Interfaces
{
public interface IServerUtil
{
/// <summary>
/// Collection order basis
/// </summary>
ushort Priority { get; }
/// <summary>
/// Server.Type
/// </summary>
string TypeName { get; }
/// <summary>
/// Protocol Name
/// </summary>
string FullName { get; }
string ShortName { get; }
/// <summary>
/// Support URI
/// </summary>
string[] UriScheme { get; }
public abstract Type ServerType { get; }
public void Edit(Server s);
public void Create();
string GetShareLink(Server s);
public abstract IServerController GetController();
public abstract IEnumerable<Server> ParseUri(string text);
bool CheckServer(Server s);
}
}