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 } }
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"); }
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>() };
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)); }
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" };
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"); }
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(""); } }
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); }
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"); }