コード例 #1
0
ファイル: V2rayConfigUtils.cs プロジェクト: xwuchen/Netch
        private static void inbound(Server server, ref V2rayConfig v2rayConfig)
        {
            try
            {
                var inbound = new Inbounds
                {
                    port     = Global.Settings.Socks5LocalPort,
                    protocol = "socks",
                    listen   = Global.Settings.LocalAddress,
                    settings = new Inboundsettings
                    {
                        udp = true
                    }
                };

                v2rayConfig.inbounds = new List <Inbounds>
                {
                    inbound
                };
            }
            catch
            {
                // ignored
            }
        }
コード例 #2
0
        private static void routing(Server server, Mode mode, ref V2rayConfig v2rayConfig)
        {
            try
            {
                var directRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "direct"
                };

                var blockRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "block"
                };

                if (mode.Type is ModeType.Process or ModeType.ProxyRuleIPs or ModeType.BypassRuleIPs)
                {
                    blockRuleObject.ip.Add("0.0.0.0/8");
                    blockRuleObject.ip.Add("224.0.0.0/4");
                    blockRuleObject.ip.Add("255.255.255.255/32");
                    blockRuleObject.ip.Add("fc00::/8");
                }
コード例 #3
0
        private static void routing(Server server, Mode mode, ref V2rayConfig v2rayConfig)
        {
            try
            {
                var directRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "direct"
                };

                var blockRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "block"
                };

                if (mode.BypassChina)
                {
                    switch (mode.Type)
                    {
                    case 0:
                        directRuleObject.ip.Add("geoip:cn");
                        break;

                    case 1:
                    case 2:
                        if (Global.Flags.SupportFakeDns && Global.Settings.TUNTAP.UseFakeDNS)
                        {
                            directRuleObject.domain.Add("geosite:cn");
                        }
                        else
                        {
                            directRuleObject.ip.Add("geoip:cn");
                        }

                        break;

                    default:
                        directRuleObject.domain.Add("geosite:cn");
                        break;
                    }
                }

                if (mode.Type is 0 or 1 or 2)
                {
                    blockRuleObject.ip.Add("geoip:private");
                }

                v2rayConfig.routing = new Routing
                {
                    rules = new List <RulesItem>()
                };
コード例 #4
0
        public static string GenerateClientConfig(Server server, Mode mode)
        {
            var v2rayConfig = new V2rayConfig();

            inbound(server, ref v2rayConfig);

            routing(server, mode, ref v2rayConfig);

            outbound(server, mode, ref v2rayConfig);

            return(JsonSerializer.Serialize(v2rayConfig, Global.NewDefaultJsonSerializerOptions));
        }
コード例 #5
0
        private static void routing(Server server, Mode mode, ref V2rayConfig v2rayConfig)
        {
            try
            {
                var directRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "direct"
                };

                var blockRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "block"
                };
コード例 #6
0
        private static void routing(Server server, Mode mode, ref V2rayConfig v2rayConfig)
        {
            try
            {
                var directRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "direct"
                };

                var blockRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "block"
                };

                if (mode.BypassChina)
                {
                    switch (mode.Type)
                    {
                    case 0:
                        directRuleObject.ip.Add("geoip:cn");
                        break;

                    case 1:
                    case 2:
                        // directRuleObject.ip.Add("geoip:cn");
                        break;

                    default:
                        directRuleObject.domain.Add("geosite:cn");
                        break;
                    }
                }

                if (mode.Type is 0 or 1 or 2)
                {
                    blockRuleObject.ip.Add("geoip:private");
                }
コード例 #7
0
ファイル: V2rayConfigUtils.cs プロジェクト: xwuchen/Netch
        public static string GenerateClientConfig(Server server, Mode mode)
        {
            try
            {
                var v2rayConfig = new V2rayConfig();

                inbound(server, ref v2rayConfig);

                routing(server, mode, ref v2rayConfig);

                outbound(server, mode, ref v2rayConfig);

                return(JsonConvert.SerializeObject(v2rayConfig, Formatting.Indented, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }));
            }
            catch
            {
                return("");
            }
        }
コード例 #8
0
ファイル: V2rayConfigUtils.cs プロジェクト: jssycszyj/Netch
        public static async Task <V2rayConfig> GenerateClientConfigAsync(Server server)
        {
            var v2rayConfig = new V2rayConfig
            {
                inbounds = new object[]
                {
                    new
                    {
                        port     = Global.Settings.Socks5LocalPort,
                        protocol = "socks",
                        listen   = Global.Settings.LocalAddress,
                        settings = new
                        {
                            udp = true
                        }
                    }
                }
            };

            v2rayConfig.outbounds = new[] { await outbound(server) };

            return(v2rayConfig);
        }
コード例 #9
0
        private static void routing(Server server, Mode mode, ref V2rayConfig v2rayConfig)
        {
            try
            {
                var directRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "direct"
                };

                var blockRuleObject = new RulesItem
                {
                    type        = "field",
                    ip          = new List <string>(),
                    domain      = new List <string>(),
                    outboundTag = "block"
                };

                if (mode.Type is 0 or 1 or 2)
                {
                    blockRuleObject.ip.Add("geoip:private");
                }