diff --git a/internal/vpn/client.go b/internal/vpn/client.go index f18f53514..243a602aa 100644 --- a/internal/vpn/client.go +++ b/internal/vpn/client.go @@ -710,7 +710,7 @@ func (c *Client) dialServer(appCl *app.Client, pk cipher.PubKey) (net.Conn, erro } if c.isClosed() { - // we need to signal outer code that connection object is inalid + // we need to signal outer code that connection object is invalid // in this case return nil, errors.New("client got closed") } diff --git a/internal/vpn/server.go b/internal/vpn/server.go index f0d7de6f2..d2047a9ee 100644 --- a/internal/vpn/server.go +++ b/internal/vpn/server.go @@ -41,7 +41,7 @@ func NewServer(cfg ServerConfig, appCl *app.Client) (*Server, error) { if err != nil { return nil, fmt.Errorf("error getting default network interface: %w", err) } - ifcs, hasMultiple := s.hasMutipleNetworkInterfaces(defaultNetworkIfcs) + ifcs, hasMultiple := s.hasMultipleNetworkInterfaces(defaultNetworkIfcs) if hasMultiple { if cfg.NetworkInterface == "" { return nil, fmt.Errorf("multiple default network interfaces detected...set a default one for VPN server or remove one: %v", ifcs) @@ -74,18 +74,18 @@ func NewServer(cfg ServerConfig, appCl *app.Client) (*Server, error) { fmt.Println("Old IP forwarding values:") fmt.Printf("IPv4: %s, IPv6: %s\n", ipv4ForwardingVal, ipv6ForwardingVal) - iptablesForwarPolicy, err := GetIPTablesForwardPolicy() + iptablesForwardPolicy, err := GetIPTablesForwardPolicy() if err != nil { return nil, fmt.Errorf("error getting iptables forward policy: %w", err) } - fmt.Printf("Old iptables forward policy: %s\n", iptablesForwarPolicy) + fmt.Printf("Old iptables forward policy: %s\n", iptablesForwardPolicy) s.defaultNetworkInterface = defaultNetworkIfc s.defaultNetworkInterfaceIPs = defaultNetworkIfcIPs s.ipv4ForwardingVal = ipv4ForwardingVal s.ipv6ForwardingVal = ipv6ForwardingVal - s.iptablesForwardPolicy = iptablesForwarPolicy + s.iptablesForwardPolicy = iptablesForwardPolicy return s, nil } @@ -245,14 +245,20 @@ func (s *Server) serveConn(conn net.Conn) { defer close(connToTunDoneCh) if _, err := io.Copy(tun, conn); err != nil { - print(fmt.Sprintf("Error resending traffic from VPN client to TUN %s: %v\n", tun.Name(), err)) + // when the vpn-client is closed we get the error "EOF" + if err.Error() != io.EOF.Error() { + print(fmt.Sprintf("Error resending traffic from VPN client to TUN %s: %v\n", tun.Name(), err)) + } } }() go func() { defer close(tunToConnCh) if _, err := io.Copy(conn, tun); err != nil { - print(fmt.Sprintf("Error resending traffic from TUN %s to VPN client: %v\n", tun.Name(), err)) + // when the vpn-client is closed we get the error "read tun: file already closed" + if err.Error() != "read tun: file already closed" { + print(fmt.Sprintf("Error resending traffic from TUN %s to VPN client: %v\n", tun.Name(), err)) + } } }() @@ -335,7 +341,7 @@ func (s *Server) shakeHands(conn net.Conn) (tunIP, tunGateway net.IP, unsecureVP if err := WriteJSON(conn, &sHello); err != nil { unsecureVPN() - return nil, nil, nil, fmt.Errorf("error finishing hadnshake: error sending server hello: %w", err) + return nil, nil, nil, fmt.Errorf("error finishing handshake: error sending server hello: %w", err) } return sTUNIP, sTUNGateway, unsecureVPN, nil @@ -363,7 +369,7 @@ func (s *Server) sendServerErrHello(conn net.Conn, status HandshakeStatus) { } } -func (s *Server) hasMutipleNetworkInterfaces(defaultNetworkInterface string) ([]string, bool) { +func (s *Server) hasMultipleNetworkInterfaces(defaultNetworkInterface string) ([]string, bool) { networkInterfaces := strings.Split(defaultNetworkInterface, "\n") if len(networkInterfaces) > 1 { return networkInterfaces, true diff --git a/pkg/app/appserver/rpc_ingress_gateway.go b/pkg/app/appserver/rpc_ingress_gateway.go index 515705af7..01510472b 100644 --- a/pkg/app/appserver/rpc_ingress_gateway.go +++ b/pkg/app/appserver/rpc_ingress_gateway.go @@ -276,10 +276,12 @@ func (r *RPCIngressGateway) Read(req *ReadReq, resp *ReadResp) error { copy(resp.B, buf[:resp.N]) } if err != nil { - // we don't print warning if the conn is already closed - _, ok := r.cm.Get(req.ConnID) - if ok { - r.log.WithError(err).Warn("Received unexpected error when reading from server.") + if err.Error() != io.EOF.Error() { + // we don't print warning if the conn is already closed + _, ok := r.cm.Get(req.ConnID) + if ok { + r.log.WithError(err).Warn("Received unexpected error when reading from server.") + } } }