修订tun文档,代码;前几个commit一直在修tun linux auto route,修好了

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 18e216326b
commit 60271dcabd
3 changed files with 11 additions and 11 deletions

View File

@@ -3,8 +3,7 @@
###############################################################
# 你要配置好路由表才能让tun正常使用。
# 在mac/windows上路由表不是那么好配置尤其是没有linux那么灵活
# 而如果是在linux上的话直接推荐使用tproxy
# 路由表不是那么好配置,见下面指导
# 对于小白来说,下面的指导太过于高级,难以看懂,因此对于小白来说推荐全自动化的方案。
@@ -55,10 +54,15 @@ protocol = "tun"
# 使用 extra.tun_selfip 作为 tun向外拨号的ip, 若不给出, 默认为 10.1.0.10 windows上不配置该项
# 如果 extra.tun_auto_route 给出vs_gui会试图自动配置路由表.
# 此时必须额外给出需要 直连的ip列表, 比如你的 代理服务器的ip地址; 如果不给出, 则不会自动配置路由表
# 此时必须通过 tun_auto_route_direct_list 额外给出需要 直连的ip列表, 比如你的 代理服务器的ip地址 (替换掉127.0.0.1);
# 如果不给出, 则不会自动配置路由表
# 这是为了防回环。
# 目前的自动配置逻辑 完全仿照上面的路由配置指导。
# 如果你在linux上则也可以不用配置direct_list, 而是直接用linux的 bindToDevice功能 给dial绑定自己拨号网卡, 这就可以轻松防回环了。
extra.tun_auto_route = true
extra.tun_auto_route_direct_list = [ "127.0.0.1" ]

View File

@@ -106,11 +106,7 @@ func init() {
if manualRoute {
promptManual(strs)
} else {
// defer func() {
// //发现在vs退出之前是无法成功运行 ip tuntap del mode tun 的
// utils.Warn("please run this command belowmanually after exit vs:\nip tuntap del mode tun dev " + tunDevName)
// }()
if e := utils.LogExecCmdList(strs); e != nil {
if ce := utils.CanLogErr("recover auto route failed"); ce != nil {
ce.Write(zap.Error(e))

View File

@@ -135,7 +135,7 @@ type Server struct {
infoChan chan<- netLayer.TCPRequestInfo
udpRequestChan chan<- netLayer.UDPRequestInfo
lwipCloser io.Closer
stackCloser io.Closer
tunDev device.Device
devName, realIP, selfip string //selfip 只在 darwin 上用到
@@ -181,7 +181,7 @@ func (s *Server) Stop() {
close(s.infoChan)
close(s.udpRequestChan)
s.lwipCloser.Close()
s.stackCloser.Close()
s.tunDev.Close()
if s.autoRoute && autoRouteDownAfterCloseFunc != nil {
@@ -242,7 +242,7 @@ func (s *Server) StartListen(tcpRequestChan chan<- netLayer.TCPRequestInfo, udpR
s.infoChan = tcpRequestChan
s.udpRequestChan = udpRequestChan
newTchan, newUchan, closer, err := tun.Listen(tunDev)
newTchan, newUchan, stackCloser, err := tun.Listen(tunDev)
if err != nil {
if ce := utils.CanLogErr("tun listen failed"); ce != nil {
@@ -276,7 +276,7 @@ func (s *Server) StartListen(tcpRequestChan chan<- netLayer.TCPRequestInfo, udpR
udpRequestChan <- ur
}
}()
s.lwipCloser = closer
s.stackCloser = stackCloser
s.tunDev = tunDev
return s