mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-10-31 20:42:52 +00:00 
			
		
		
		
	Custom configuration overwrite port
This commit is contained in:
		
							parent
							
								
									b7a6004830
								
							
						
					
					
						commit
						7bb91f57ac
					
				
					 1 changed files with 24 additions and 1 deletions
				
			
		|  | @ -921,10 +921,33 @@ namespace v2rayN.Handler | |||
|                 } | ||||
|                 File.Copy(addressFileName, fileName); | ||||
| 
 | ||||
|                 //check again | ||||
|                 if (!File.Exists(fileName)) | ||||
|                 { | ||||
|                     msg = UIRes.I18N("FailedGenDefaultConfiguration"); | ||||
|                     return -1; | ||||
|                 } | ||||
| 
 | ||||
|                 //overwrite port | ||||
|                 var fileContent = File.ReadAllLines(fileName).ToList(); | ||||
|                 var coreType = LazyConfig.Instance.GetCoreType(node, node.configType); | ||||
|                 switch (coreType) | ||||
|                 { | ||||
|                     case ECoreType.v2fly: | ||||
|                     case ECoreType.Xray: | ||||
|                         break; | ||||
|                     case ECoreType.clash: | ||||
|                         fileContent.Add($"port: {LazyConfig.Instance.GetConfig().GetLocalPort(Global.InboundHttp)}"); | ||||
|                         fileContent.Add($"socks-port: {LazyConfig.Instance.GetConfig().GetLocalPort(Global.InboundSocks)}"); | ||||
|                         break; | ||||
|                 } | ||||
|                 File.WriteAllLines(fileName, fileContent); | ||||
| 
 | ||||
|                 msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{LazyConfig.Instance.GetConfig().GetGroupRemarks(node.groupId)}] {node.GetSummary()}"); | ||||
|             } | ||||
|             catch | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 Utils.SaveLog("GenerateClientCustomConfig", ex); | ||||
|                 msg = UIRes.I18N("FailedGenDefaultConfiguration"); | ||||
|                 return -1; | ||||
|             } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 2dust
						2dust