Fix SSO support for anyconnect
This commit is contained in:
@@ -150,7 +150,7 @@ func (d *systemDevice) readLoop(tunInterface tun.Tun, mtu int) {
|
||||
return
|
||||
}
|
||||
d.options.Logger.Error(E.Cause(err, "read packet"))
|
||||
continue
|
||||
return
|
||||
}
|
||||
if readN <= tun.PacketOffset {
|
||||
continue
|
||||
@@ -162,6 +162,7 @@ func (d *systemDevice) readLoop(tunInterface tun.Tun, mtu int) {
|
||||
packetBuffer.DecRef()
|
||||
if err != nil {
|
||||
d.options.Logger.Error(E.Cause(err, "write packet"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,6 +193,7 @@ func (d *systemDevice) readLoopLinux(tunInterface tun.LinuxTUN, batchSize int, m
|
||||
}
|
||||
if writeErr != nil {
|
||||
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if readErr != nil {
|
||||
@@ -199,6 +201,7 @@ func (d *systemDevice) readLoopLinux(tunInterface tun.LinuxTUN, batchSize int, m
|
||||
return
|
||||
}
|
||||
d.options.Logger.Error(E.Cause(readErr, "batch read packet"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,6 +221,7 @@ func (d *systemDevice) readLoopDarwin(tunInterface tun.DarwinTUN) {
|
||||
writeErr := d.writeOutbound(outboundBuffers)
|
||||
if writeErr != nil {
|
||||
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if readErr != nil {
|
||||
@@ -225,6 +229,7 @@ func (d *systemDevice) readLoopDarwin(tunInterface tun.DarwinTUN) {
|
||||
return
|
||||
}
|
||||
d.options.Logger.Error(E.Cause(readErr, "batch read packet"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ func (d *stackDevice) UpdateConfiguration(configuration Configuration) error {
|
||||
defer d.stateAccess.Unlock()
|
||||
if d.logRouteOptions && hasRouteOptions(configuration.Routes) {
|
||||
d.options.Logger.Debug("OpenVPN route gateway and metric options are not representable by the gVisor stack device; routes are installed by prefix")
|
||||
d.logRouteOptions = false
|
||||
}
|
||||
if configuration.MTU != 0 {
|
||||
d.options.MTU = configuration.MTU
|
||||
|
||||
@@ -30,13 +30,14 @@ const (
|
||||
|
||||
type systemDevice struct {
|
||||
baseDevice
|
||||
stateAccess sync.RWMutex
|
||||
options DeviceOptions
|
||||
dialer N.Dialer
|
||||
device tun.Tun
|
||||
inet4Address netip.Addr
|
||||
inet6Address netip.Addr
|
||||
closed bool
|
||||
stateAccess sync.RWMutex
|
||||
options DeviceOptions
|
||||
dialer N.Dialer
|
||||
device tun.Tun
|
||||
inet4Address netip.Addr
|
||||
inet6Address netip.Addr
|
||||
logRouteOptions bool
|
||||
closed bool
|
||||
}
|
||||
|
||||
func newSystemDevice(options DeviceOptions) (*systemDevice, error) {
|
||||
@@ -54,10 +55,11 @@ func newSystemDevice(options DeviceOptions) (*systemDevice, error) {
|
||||
}
|
||||
inet4Address, inet6Address := firstAddresses(options.Configuration.Address)
|
||||
return &systemDevice{
|
||||
options: options,
|
||||
dialer: interfaceDialer,
|
||||
inet4Address: inet4Address,
|
||||
inet6Address: inet6Address,
|
||||
options: options,
|
||||
dialer: interfaceDialer,
|
||||
inet4Address: inet4Address,
|
||||
inet6Address: inet6Address,
|
||||
logRouteOptions: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -191,7 +193,7 @@ func (d *systemDevice) readLoop(tunInterface tun.Tun, mtu int) {
|
||||
return
|
||||
}
|
||||
d.options.Logger.Error(E.Cause(err, "read packet"))
|
||||
continue
|
||||
return
|
||||
}
|
||||
if readN <= tun.PacketOffset {
|
||||
continue
|
||||
@@ -206,6 +208,7 @@ func (d *systemDevice) readLoop(tunInterface tun.Tun, mtu int) {
|
||||
packetBuffer.DecRef()
|
||||
if err != nil {
|
||||
d.options.Logger.Error(E.Cause(err, "write packet"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,6 +246,7 @@ func (d *systemDevice) readLoopLinux(tunInterface tun.LinuxTUN, batchSize int, m
|
||||
}
|
||||
if writeErr != nil {
|
||||
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if readErr != nil {
|
||||
@@ -250,6 +254,7 @@ func (d *systemDevice) readLoopLinux(tunInterface tun.LinuxTUN, batchSize int, m
|
||||
return
|
||||
}
|
||||
d.options.Logger.Error(E.Cause(readErr, "batch read packet"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,6 +279,7 @@ func (d *systemDevice) readLoopDarwin(tunInterface tun.DarwinTUN) {
|
||||
writeErr := d.writeOutbound(outboundBuffers)
|
||||
if writeErr != nil {
|
||||
d.options.Logger.Error(E.Cause(writeErr, "write packet batch"))
|
||||
return
|
||||
}
|
||||
}
|
||||
if readErr != nil {
|
||||
@@ -281,6 +287,7 @@ func (d *systemDevice) readLoopDarwin(tunInterface tun.DarwinTUN) {
|
||||
return
|
||||
}
|
||||
d.options.Logger.Error(E.Cause(readErr, "batch read packet"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,8 +298,9 @@ func (d *systemDevice) UpdateConfiguration(configuration Configuration) error {
|
||||
routes := routesWithBlockIPv6(configuration)
|
||||
_, hasUnrepresentableInet4RouteOptions := systemRouteGateway(routes, true)
|
||||
_, hasUnrepresentableInet6RouteOptions := systemRouteGateway(routes, false)
|
||||
if hasUnrepresentableInet4RouteOptions || hasUnrepresentableInet6RouteOptions {
|
||||
if d.logRouteOptions && (hasUnrepresentableInet4RouteOptions || hasUnrepresentableInet6RouteOptions) {
|
||||
d.options.Logger.Debug("some OpenVPN route gateway or metric options are not representable by the system device; routes are installed by prefix")
|
||||
d.logRouteOptions = false
|
||||
}
|
||||
previousConfiguration := d.options.Configuration
|
||||
previousMTU := d.options.MTU
|
||||
|
||||
Reference in New Issue
Block a user