From 1a445104c259a1b440e44c8ade5a9615bec16a24 Mon Sep 17 00:00:00 2001 From: Connection Refused Date: Sat, 16 Oct 2021 07:45:57 +0800 Subject: [PATCH] [General] Run code cleaner --- RedirectorTester/Properties/AssemblyInfo.cs | 1 - RedirectorTester/RedirectorTester.cs | 140 ++++++++++---------- 2 files changed, 68 insertions(+), 73 deletions(-) diff --git a/RedirectorTester/Properties/AssemblyInfo.cs b/RedirectorTester/Properties/AssemblyInfo.cs index f6256971..6b99ddef 100644 --- a/RedirectorTester/Properties/AssemblyInfo.cs +++ b/RedirectorTester/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 diff --git a/RedirectorTester/RedirectorTester.cs b/RedirectorTester/RedirectorTester.cs index 73f95d94..54b8738f 100644 --- a/RedirectorTester/RedirectorTester.cs +++ b/RedirectorTester/RedirectorTester.cs @@ -1,87 +1,83 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace RedirectorTester { public class RedirectorTester { - public enum NameList : int - { - AIO_FILTERLOOPBACK, - AIO_FILTERINTRANET, - AIO_FILTERPARENT, - AIO_FILTERICMP, - AIO_FILTERTCP, - AIO_FILTERUDP, - AIO_FILTERDNS, - - AIO_ICMPING, - - AIO_DNSHOST, - AIO_DNSPORT, - - AIO_TGTHOST, - AIO_TGTPORT, - AIO_TGTUSER, - AIO_TGTPASS, - - AIO_CLRNAME, - AIO_ADDNAME, - AIO_BYPNAME - } - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern bool aio_register([MarshalAs(UnmanagedType.LPWStr)] string value); - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern bool aio_unregister([MarshalAs(UnmanagedType.LPWStr)] string value); - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern bool aio_dial(NameList name, [MarshalAs(UnmanagedType.LPWStr)] string value); - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern bool aio_init(); - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern void aio_free(); - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern ulong aio_getUP(); - - [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern ulong aio_getDL(); - - public static void Main(string[] args) + public enum NameList : int { - aio_dial(NameList.AIO_FILTERLOOPBACK, "false"); - aio_dial(NameList.AIO_FILTERINTRANET, "false"); - aio_dial(NameList.AIO_FILTERPARENT, "false"); - aio_dial(NameList.AIO_FILTERICMP, "true"); - aio_dial(NameList.AIO_FILTERTCP, "true"); - aio_dial(NameList.AIO_FILTERUDP, "true"); - aio_dial(NameList.AIO_FILTERDNS, "false"); + AIO_FILTERLOOPBACK, + AIO_FILTERINTRANET, + AIO_FILTERPARENT, + AIO_FILTERICMP, + AIO_FILTERTCP, + AIO_FILTERUDP, + AIO_FILTERDNS, - aio_dial(NameList.AIO_ICMPING, "10"); + AIO_ICMPING, - aio_dial(NameList.AIO_DNSHOST, "1.1.1.1"); - aio_dial(NameList.AIO_DNSPORT, "53"); + AIO_DNSHOST, + AIO_DNSPORT, - aio_dial(NameList.AIO_TGTHOST, "127.0.0.1"); - aio_dial(NameList.AIO_TGTPORT, "1080"); - aio_dial(NameList.AIO_TGTUSER, ""); - aio_dial(NameList.AIO_TGTPASS, ""); + AIO_TGTHOST, + AIO_TGTPORT, + AIO_TGTUSER, + AIO_TGTPASS, - aio_dial(NameList.AIO_CLRNAME, ""); - aio_dial(NameList.AIO_ADDNAME, "Telegram"); - aio_dial(NameList.AIO_ADDNAME, "NatTypeTester"); + AIO_CLRNAME, + AIO_ADDNAME, + AIO_BYPNAME + } - aio_init(); - Console.ReadLine(); - aio_free(); - } + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern bool aio_register([MarshalAs(UnmanagedType.LPWStr)] string value); + + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern bool aio_unregister([MarshalAs(UnmanagedType.LPWStr)] string value); + + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern bool aio_dial(NameList name, [MarshalAs(UnmanagedType.LPWStr)] string value); + + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern bool aio_init(); + + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern void aio_free(); + + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern ulong aio_getUP(); + + [DllImport("Redirector.bin", CallingConvention = CallingConvention.Cdecl)] + public static extern ulong aio_getDL(); + + public static void Main(string[] args) + { + aio_dial(NameList.AIO_FILTERLOOPBACK, "false"); + aio_dial(NameList.AIO_FILTERINTRANET, "false"); + aio_dial(NameList.AIO_FILTERPARENT, "false"); + aio_dial(NameList.AIO_FILTERICMP, "true"); + aio_dial(NameList.AIO_FILTERTCP, "true"); + aio_dial(NameList.AIO_FILTERUDP, "true"); + aio_dial(NameList.AIO_FILTERDNS, "false"); + + aio_dial(NameList.AIO_ICMPING, "10"); + + aio_dial(NameList.AIO_DNSHOST, "1.1.1.1"); + aio_dial(NameList.AIO_DNSPORT, "53"); + + aio_dial(NameList.AIO_TGTHOST, "127.0.0.1"); + aio_dial(NameList.AIO_TGTPORT, "1080"); + aio_dial(NameList.AIO_TGTUSER, ""); + aio_dial(NameList.AIO_TGTPASS, ""); + + aio_dial(NameList.AIO_CLRNAME, ""); + aio_dial(NameList.AIO_ADDNAME, "Telegram"); + aio_dial(NameList.AIO_ADDNAME, "NatTypeTester"); + + aio_init(); + Console.ReadLine(); + aio_free(); + } } }