mirror of
				https://github.com/bjdgyc/anylink.git
				synced 2025-10-31 00:19:34 +08:00 
			
		
		
		
	Merge pull request #200 from wsczx/dev
添加配置文件示例,添加nat列表展示,修改iptables判断逻辑bug
This commit is contained in:
		| @@ -75,5 +75,7 @@ audit_interval = -1 | ||||
|  | ||||
| show_sql = false | ||||
|  | ||||
| #是否自动添加nat | ||||
| iptables_nat = false | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -33,4 +33,5 @@ ipv4_gateway = "192.168.10.1" | ||||
| ipv4_start = "192.168.10.100" | ||||
| ipv4_end = "192.168.10.200" | ||||
|  | ||||
|  | ||||
| #是否自动添加nat | ||||
| iptables_nat = false | ||||
|   | ||||
| @@ -40,12 +40,14 @@ func checkTun() { | ||||
| 		} | ||||
| 		natRule := []string{"-s", base.Cfg.Ipv4CIDR, "-o", base.Cfg.Ipv4Master, "-j", "MASQUERADE"} | ||||
| 		forwardRule := []string{"-j", "ACCEPT"} | ||||
| 		if natExists, _ := ipt.Exists("filter", "FORWARD", forwardRule...); !natExists { | ||||
| 		if natExists, _ := ipt.Exists("nat", "POSTROUTING", natRule...); !natExists { | ||||
| 			ipt.Insert("nat", "POSTROUTING", 1, natRule...) | ||||
| 		} | ||||
| 		if forwardExists, _ := ipt.Exists("filter", "FORWARD", natRule...); !forwardExists { | ||||
| 		if forwardExists, _ := ipt.Exists("filter", "FORWARD", forwardRule...); !forwardExists { | ||||
| 			ipt.Insert("filter", "FORWARD", 1, forwardRule...) | ||||
| 		} | ||||
| 		base.Info(ipt.List("nat", "POSTROUTING")) | ||||
| 		base.Info(ipt.List("filter", "FORWARD")) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user