fix tun config
This commit is contained in:
parent
e8be8d625a
commit
9be710dc19
@ -29,16 +29,22 @@ type serverConn struct {
|
|||||||
limiterOut limiter.Limiter
|
limiterOut limiter.Limiter
|
||||||
expIn int64
|
expIn int64
|
||||||
expOut int64
|
expOut int64
|
||||||
|
opts []limiter.Option
|
||||||
}
|
}
|
||||||
|
|
||||||
func WrapConn(limiter limiter.TrafficLimiter, c net.Conn) net.Conn {
|
func WrapConn(tlimiter limiter.TrafficLimiter, c net.Conn) net.Conn {
|
||||||
if limiter == nil {
|
if tlimiter == nil {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
return &serverConn{
|
return &serverConn{
|
||||||
Conn: c,
|
Conn: c,
|
||||||
limiter: limiter,
|
limiter: tlimiter,
|
||||||
|
opts: []limiter.Option{
|
||||||
|
limiter.NetworkOption(c.LocalAddr().Network()),
|
||||||
|
limiter.SrcOption(c.RemoteAddr().String()),
|
||||||
|
limiter.AddrOption(c.LocalAddr().String()),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-gost/core/limiter/traffic"
|
|
||||||
limiter "github.com/go-gost/core/limiter/traffic"
|
limiter "github.com/go-gost/core/limiter/traffic"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,11 +18,11 @@ type readWriter struct {
|
|||||||
limiterOut limiter.Limiter
|
limiterOut limiter.Limiter
|
||||||
expIn int64
|
expIn int64
|
||||||
expOut int64
|
expOut int64
|
||||||
opts []traffic.Option
|
opts []limiter.Option
|
||||||
key string
|
key string
|
||||||
}
|
}
|
||||||
|
|
||||||
func WrapReadWriter(limiter limiter.TrafficLimiter, rw io.ReadWriter, key string, opts ...traffic.Option) io.ReadWriter {
|
func WrapReadWriter(limiter limiter.TrafficLimiter, rw io.ReadWriter, key string, opts ...limiter.Option) io.ReadWriter {
|
||||||
if limiter == nil {
|
if limiter == nil {
|
||||||
return rw
|
return rw
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func (l *tunListener) createTun() (ifce io.ReadWriteCloser, name string, ip net.
|
|||||||
ip = l.md.config.Net[0].IP
|
ip = l.md.config.Net[0].IP
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = l.addRoutes(name, l.md.config.Routes...); err != nil {
|
if err = l.addRoutes(name); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func (l *tunListener) createTun() (ifce io.ReadWriteCloser, name string, ip net.
|
|||||||
ip = l.md.config.Net[0].IP
|
ip = l.md.config.Net[0].IP
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = l.addRoutes(name, l.md.config.Routes...); err != nil {
|
if err = l.addRoutes(name); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func (l *tunListener) createTun() (ifce io.ReadWriteCloser, name string, ip net.
|
|||||||
ip = ipNet.IP
|
ip = ipNet.IP
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = l.addRoutes(name, l.md.config.Gateway, l.md.config.Routes...); err != nil {
|
if err = l.addRoutes(name, l.md.config.Gateway); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user