fix tun config
This commit is contained in:
parent
e8be8d625a
commit
9be710dc19
@ -29,16 +29,22 @@ type serverConn struct {
|
||||
limiterOut limiter.Limiter
|
||||
expIn int64
|
||||
expOut int64
|
||||
opts []limiter.Option
|
||||
}
|
||||
|
||||
func WrapConn(limiter limiter.TrafficLimiter, c net.Conn) net.Conn {
|
||||
if limiter == nil {
|
||||
func WrapConn(tlimiter limiter.TrafficLimiter, c net.Conn) net.Conn {
|
||||
if tlimiter == nil {
|
||||
return c
|
||||
}
|
||||
|
||||
return &serverConn{
|
||||
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"
|
||||
"time"
|
||||
|
||||
"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
|
||||
expIn int64
|
||||
expOut int64
|
||||
opts []traffic.Option
|
||||
opts []limiter.Option
|
||||
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 {
|
||||
return rw
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func (l *tunListener) createTun() (ifce io.ReadWriteCloser, name string, ip net.
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ func (l *tunListener) createTun() (ifce io.ReadWriteCloser, name string, ip net.
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ func (l *tunListener) createTun() (ifce io.ReadWriteCloser, name string, ip net.
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user