using System.Runtime.InteropServices; namespace Netch { public static class NativeMethods { /// /// 创建路由规则 /// /// 目标地址 /// 掩码地址 /// 网关地址 /// 适配器索引 /// 跃点数 /// 是否成功 [DllImport("bin\\NetchCore", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CreateRoute")] public static extern bool CreateRoute(string address, int netmask, string gateway, int index, int metric = 0); /// /// 修改路由规则 /// /// 目标地址 /// 掩码地址 /// 网关地址 /// 适配器索引 /// 跃点数 /// 是否成功 [DllImport("bin\\NetchCore", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ChangeRoute")] public static extern bool ChangeRoute(string address, int netmask, string gateway, int index, int metric = 0); /// /// 删除路由规则 /// /// 目标地址 /// 掩码地址 /// 网关地址 /// 适配器索引 /// 跃点数 /// 是否成功 [DllImport("bin\\NetchCore", CallingConvention = CallingConvention.Cdecl, EntryPoint = "DeleteRoute")] public static extern bool DeleteRoute(string address, int netmask, string gateway, int index, int metric = 0); /// /// 设置直连 /// /// 是否成功 [DllImport("bin\\sysproxy", CallingConvention = CallingConvention.Cdecl)] public static extern bool SetDIRECT(); /// /// 设置全局 /// /// 地址 /// 绕过 /// 是否成功 [DllImport("bin\\sysproxy", CallingConvention = CallingConvention.Cdecl)] public static extern bool SetGlobal([MarshalAs(UnmanagedType.LPTStr)] string remote, [MarshalAs(UnmanagedType.LPTStr)] string bypass); /// /// 设置自动代理 /// /// URL /// 是否成功 [DllImport("bin\\sysproxy", CallingConvention = CallingConvention.Cdecl)] public static extern bool SetURL([MarshalAs(UnmanagedType.LPTStr)] string remote); public class Shadowsocks { [DllImport("bin\\shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)] public static extern bool Info(byte[] client, byte[] remote, byte[] passwd, byte[] method); [DllImport("bin\\shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)] public static extern bool Start(); [DllImport("bin\\shadowsocks-windows-dynamic", CallingConvention = CallingConvention.Cdecl)] public static extern void Stop(); } } }