mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-11-03 22:12:52 +00:00 
			
		
		
		
	Previous and next proxy
This commit is contained in:
		
							parent
							
								
									b0c5f74edb
								
							
						
					
					
						commit
						0d5a9fcf4a
					
				
					 4 changed files with 76 additions and 3 deletions
				
			
		| 
						 | 
					@ -45,7 +45,7 @@ namespace v2rayN.Handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GenInbounds(singboxConfig);
 | 
					                GenInbounds(singboxConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GenOutbounds(node, singboxConfig);
 | 
					                GenOutbound(node, singboxConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GenRouting(singboxConfig);
 | 
					                GenRouting(singboxConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -202,7 +202,7 @@ namespace v2rayN.Handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region outbound private
 | 
					        #region outbound private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private int GenOutbounds(ProfileItem node, SingboxConfig singboxConfig)
 | 
					        private int GenOutbound(ProfileItem node, SingboxConfig singboxConfig)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,6 +53,8 @@ namespace v2rayN.Handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GenOutbound(node, v2rayConfig.outbounds[0]);
 | 
					                GenOutbound(node, v2rayConfig.outbounds[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                GenMoreOutbounds(node, v2rayConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GenDns(v2rayConfig);
 | 
					                GenDns(v2rayConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                GenStatistic(v2rayConfig);
 | 
					                GenStatistic(v2rayConfig);
 | 
				
			||||||
| 
						 | 
					@ -820,6 +822,64 @@ namespace v2rayN.Handler
 | 
				
			||||||
            return 0;
 | 
					            return 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (node.subid.IsNullOrEmpty())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var subItem = LazyConfig.Instance.GetSubItem(node.subid);
 | 
				
			||||||
 | 
					                if (subItem is null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    return 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //current proxy
 | 
				
			||||||
 | 
					                var outbound = v2rayConfig.outbounds[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //Previous proxy
 | 
				
			||||||
 | 
					                var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
 | 
				
			||||||
 | 
					                if (prevNode is not null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
 | 
				
			||||||
 | 
					                    var prevOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
 | 
				
			||||||
 | 
					                    GenOutbound(prevNode, prevOutbound);
 | 
				
			||||||
 | 
					                    prevOutbound.tag = $"{Global.ProxyTag}2";
 | 
				
			||||||
 | 
					                    v2rayConfig.outbounds.Add(prevOutbound);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    outbound.streamSettings.sockopt = new()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        dialerProxy = prevOutbound.tag
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                //Next proxy
 | 
				
			||||||
 | 
					                var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
 | 
				
			||||||
 | 
					                if (nextNode is not null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
 | 
				
			||||||
 | 
					                    var nextOutbound = Utils.FromJson<Outbounds4Ray>(txtOutbound);
 | 
				
			||||||
 | 
					                    GenOutbound(nextNode, nextOutbound);
 | 
				
			||||||
 | 
					                    nextOutbound.tag = Global.ProxyTag;
 | 
				
			||||||
 | 
					                    v2rayConfig.outbounds.Insert(0, nextOutbound);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    outbound.tag = $"{Global.ProxyTag}1";
 | 
				
			||||||
 | 
					                    nextOutbound.streamSettings.sockopt = new()
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        dialerProxy = outbound.tag
 | 
				
			||||||
 | 
					                    };
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Utils.SaveLog(ex.Message, ex);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region Gen speedtest config
 | 
					        #region Gen speedtest config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string GenerateClientSpeedtestConfigString(List<ServerTestItem> selecteds, out string msg)
 | 
					        public string GenerateClientSpeedtestConfigString(List<ServerTestItem> selecteds, out string msg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -130,6 +130,15 @@ namespace v2rayN.Handler
 | 
				
			||||||
            return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.indexId == indexId);
 | 
					            return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.indexId == indexId);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ProfileItem? GetProfileItemViaRemarks(string remarks)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (Utils.IsNullOrEmpty(remarks))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.remarks == remarks);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public List<RoutingItem> RoutingItems()
 | 
					        public List<RoutingItem> RoutingItems()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).OrderBy(t => t.sort).ToList();
 | 
					            return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).OrderBy(t => t.sort).ToList();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,5 +27,9 @@ namespace v2rayN.Mode
 | 
				
			||||||
        public long updateTime { get; set; }
 | 
					        public long updateTime { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public string? convertTarget { get; set; }
 | 
					        public string? convertTarget { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string? prevProfile { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public string? nextProfile { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in a new issue