shadowsocks-windows-dynamic

command module
v0.0.0-...-c90a7a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 12 Imported by: 0

README

shadowsocks-windows-dynamic

namespace Shadowsocks
{
    public enum NameList : int
    {
        TYPE_LISN,
        TYPE_HOST,
        TYPE_PASS,
        TYPE_METH,
        TYPE_OBFS,
        TYPE_OBPA
    }

    public static class NativeMethods
    {
        [DllImport("shadowsocks.bin", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool ServerInfo(int name, byte[] value);

        [DllImport("shadowsocks.bin", CallingConvention = CallingConvention.Cdecl)]
        public static extern bool Create();

        [DllImport("shadowsocks.bin", CallingConvention = CallingConvention.Cdecl)]
        public static extern void Delete();
    }

    public class Shadowsocks
    {
        public static void Create()
        {
            NativeMethods.ServerInfo((int)NameList.TYPE_LISN, Encoding.UTF8.GetBytes(":1080"));
            NativeMethods.ServerInfo((int)NameList.TYPE_HOST, Encoding.UTF8.GetBytes("1.1.1.1:80"));
            NativeMethods.ServerInfo((int)NameList.TYPE_PASS, Encoding.UTF8.GetBytes("114514"));
            NativeMethods.ServerInfo((int)NameList.TYPE_METH, Encoding.UTF8.GetBytes("chacha20-ietf"));
            NativeMethods.ServerInfo((int)NameList.TYPE_OBFS, Encoding.UTF8.GetBytes("HTTP"));
            NativeMethods.ServerInfo((int)NameList.TYPE_OBPA, Encoding.UTF8.GetBytes("dash.cloudflare.com"));

            if (!NativeMethods.Create())
            {
                Console.WriteLine("!NativeMethods.Create");
                Console.ReadLine();
                return;
            }
        }

        public static void Main(string[] args)
        {
            Create();
            Console.WriteLine("STARTED");
            Console.ReadLine();

            NativeMethods.Delete();
            Console.WriteLine("STOPPED");
            Console.ReadLine();
        }
    }
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL