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 int routingGeo(string ipOrDomain, string code, string tag, ref V2rayConfig v2rayConfig) { try { if (!Utils.IsNullOrEmpty(code)) { //IP if (ipOrDomain == "ip" || ipOrDomain == "") { RulesItem rulesItem = new RulesItem(); rulesItem.type = "field"; rulesItem.outboundTag = Global.directTag; rulesItem.ip = new List <string>(); rulesItem.ip.Add($"geoip:{code}"); v2rayConfig.routing.settings.rules.Add(rulesItem); } if (ipOrDomain == "domain" || ipOrDomain == "") { RulesItem rulesItem = new RulesItem(); rulesItem.type = "field"; rulesItem.outboundTag = Global.directTag; rulesItem.domain = new List <string>(); rulesItem.domain.Add($"geosite:{code}"); v2rayConfig.routing.settings.rules.Add(rulesItem); } } } catch { } return(0); }
private async void NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { foreach (RulesItem item in App.Rules.rules.eval) { if (item.status) { EvalScripts(item.value); } } foreach (RulesItem item in App.Rules.rules.compact.video) { if (item.status) { RemoveElementsByClassName(item.value); } } await Task.Delay(1000); InitSuccess = true; Loading.IsActive = false; Blur.Visibility = Visibility.Collapsed; Information.Visibility = Visibility.Collapsed; RulesItem TimeLine = Utils.GetRulesItemById("X006"); if (TimeLine.status) { Thread thread = new Thread(new ThreadStart(AddToTimeLine)); thread.Start(); } }
public ShellPage() { this.InitializeComponent(); if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { SplitView.PaneBackground = new AcrylicBrush { BackgroundSource = AcrylicBackgroundSource.Backdrop, TintColor = Colors.Transparent, TintOpacity = 0.1 }; } RulesItem DefaultPage = Utils.GetRulesItemById("X002"); if (DefaultPage.status) { History.Background = Selected; ContentFrame.Navigate(typeof(History)); } else { Search.Background = Selected; ContentFrame.Navigate(typeof(Search)); } }
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>() };
private void AutoUpdateRules() { RulesItem AutoUpadte = Utils.GetRulesItemById("X005"); if (AutoUpadte.status) { Thread thread = new Thread(new ThreadStart(Utils.GetLatestRules)); thread.Start(); } }
private static int routingUserRule(List <string> userRule, string tag, ref V2rayConfig v2rayConfig) { try { if (userRule != null && userRule.Count > 0) { //Domain RulesItem rulesDomain = new RulesItem(); rulesDomain.type = "field"; rulesDomain.outboundTag = tag; rulesDomain.domain = new List <string>(); //IP RulesItem rulesIP = new RulesItem(); rulesIP.type = "field"; rulesIP.outboundTag = tag; rulesIP.ip = new List <string>(); for (int k = 0; k < userRule.Count; k++) { string url = userRule[k].Trim(); if (Utils.IsNullOrEmpty(url)) { continue; } if (Utils.IsIP(url) || url.StartsWith("geoip:")) { rulesIP.ip.Add(url); } else if (Utils.IsDomain(url) || url.StartsWith("geosite:") || url.StartsWith("regexp:") || url.StartsWith("domain:") || url.StartsWith("full:")) { rulesDomain.domain.Add(url); } } if (rulesDomain.domain.Count > 0) { v2rayConfig.routing.settings.rules.Add(rulesDomain); } if (rulesIP.ip.Count > 0) { v2rayConfig.routing.settings.rules.Add(rulesIP); } } } catch { } return(0); }
private void RoutingSettingDetailsForm_Load(object sender, EventArgs e) { if (EditIndex >= 0) { routingItem = config.rules[EditIndex]; BindingData(); } else { routingItem = new RulesItem(); ClearBind(); } }
/// <summary> /// 路由 /// </summary> /// <param name="config"></param> /// <param name="v2rayConfig"></param> /// <returns></returns> private static int routing(Config config, ref V2rayConfig v2rayConfig) { try { if (v2rayConfig.routing != null && v2rayConfig.routing.settings != null && v2rayConfig.routing.settings.rules != null) { //自定义 //需代理 routingUserRule(config.useragent, Global.agentTag, ref v2rayConfig); //直连 routingUserRule(config.userdirect, Global.directTag, ref v2rayConfig); //阻止 routingUserRule(config.userblock, Global.blockTag, ref v2rayConfig); //绕过大陆网址 if (config.chinasites) { //RulesItem rulesItem = new RulesItem(); //rulesItem.type = "chinasites"; //rulesItem.outboundTag = Global.directTag; //v2rayConfig.routing.settings.rules.Add(rulesItem); RulesItem rulesItem = new RulesItem(); rulesItem.type = "field"; rulesItem.outboundTag = Global.directTag; rulesItem.domain = new List <string>(); rulesItem.domain.Add("geosite:cn"); v2rayConfig.routing.settings.rules.Add(rulesItem); } //绕过大陆ip if (config.chinaip) { //RulesItem rulesItem = new RulesItem(); //rulesItem.type = "chinaip"; //rulesItem.outboundTag = Global.directTag; //v2rayConfig.routing.settings.rules.Add(rulesItem); RulesItem rulesItem = new RulesItem(); rulesItem.type = "field"; rulesItem.outboundTag = Global.directTag; rulesItem.ip = new List <string>(); rulesItem.ip.Add("geoip:cn"); v2rayConfig.routing.settings.rules.Add(rulesItem); } } } catch { } return(0); }
private async void AddToTimeLine() { RulesItem TimeLine = Utils.GetRulesItemById("X006"); int TimeDelay = int.Parse(TimeLine.value) * 60 * 1000; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Activity PrevousActivity = await GetActivity(); await Task.Delay(TimeDelay); Activity NowActivity = await GetActivity(); if (NowActivity == PrevousActivity) { Utils.AddToTimeLine(NowActivity); } }); }
private static void routing(Server server, Mode mode, ref V2rayConfig v2rayConfig) { try { RulesItem rulesItem; if (mode.BypassChina) { rulesItem = new RulesItem { type = "field", ip = new List <string> { "geoip:cn", "geoip:private" }, domain = new List <string> { "geosite:cn" }, outboundTag = "direct" }; } else { rulesItem = new RulesItem { type = "field", ip = new List <string> { "geoip:private" }, outboundTag = "direct" }; } v2rayConfig.routing = new Routing { rules = new List <RulesItem> { rulesItem } }; } catch { // ignored } }
/// <summary> /// AddRoutingRulesItem /// </summary> /// <param name="config"></param> /// <param name="item"></param> /// <param name="index"></param> /// <returns></returns> public static int AddRoutingRule(ref Config config, RulesItem item, int index) { if (index >= 0) { config.rules[index] = item; } else { config.rules.Add(item); } Global.reloadV2ray = true; ToJsonFile(config); return(0); }
static bool CheckRuleItem(ref RulesItem rulesItem) { bool ipResult, domainResult; if (!(ipResult = rulesItem.ip?.Any() ?? false)) { rulesItem.ip = null; } if (!(domainResult = rulesItem.domain?.Any() ?? false)) { rulesItem.domain = null; } return(ipResult || domainResult); }
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 async Task <string> LoadRules(int boardGameId) { string baseRulesUrl = "http://boardgamegeek.com/item/weblinks?ajax=1&domain=&filter=%7B%22languagefilter%22:0,%22categoryfilter%22:%222702%22%7D"; // TODO Set language filter Uri rulesUrl = new Uri(string.Format(baseRulesUrl + "&objectid={0}&objecttype=thing&pageid=1&showcount={1}&version=v2", boardGameId, 20)); try { string data = await ReadJsonData(rulesUrl); RulesItem rulesData = JsonConvert.DeserializeObject <RulesItem>(data); return(rulesData.WebLinks.FindLast(a => a.Categories.Last() == "Rules" && a.Languages.First() == "English").Url); } catch { return(string.Format("http://www.boardgamegeek.com/boardgame/{0}", boardGameId)); } }
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 void Video_Tapped(object sender, TappedRoutedEventArgs e) { //从播放页回到设置页会栈溢出,原因不明。解决办法是进入视频页之前,先进入搜索页 if (ContentFrame.Content is Settings) { RulesItem DefaultPage = Utils.GetRulesItemById("X002"); if (DefaultPage.status) { Search.Background = Normal; History.Background = Selected; Settings.Background = Normal; ContentFrame.Navigate(typeof(History)); } else { Search.Background = Selected; History.Background = Normal; Settings.Background = Normal; ContentFrame.Navigate(typeof(Search)); } } Frame.Navigate(typeof(VideoPlayer), "resume from main page"); }
public Search() { this.InitializeComponent(); RulesItem DisallowCache = Utils.GetRulesItemById("X003"); if (DisallowCache.status) { NavigationCacheMode = NavigationCacheMode.Disabled; } else { NavigationCacheMode = NavigationCacheMode.Required; } if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { Blur.Background = new AcrylicBrush { BackgroundSource = AcrylicBackgroundSource.Backdrop, TintColor = Colors.Transparent, TintOpacity = 0.1 }; } Init(); }
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"); }
private void RoutingRuleQuicklyAddForm_Load(object sender, EventArgs e) { rulesItem = new RulesItem(); ClearBind(); }