Browse Source

Merge pull request #30 from rod-hynes/master

Fix: don't count EOF conditions as port forward failures
Rod Hynes 11 years ago
parent
commit
ac84d0ba75
2 changed files with 5 additions and 4 deletions
  1. 4 3
      psiphon/controller.go
  2. 1 1
      psiphon/tunnel.go

+ 4 - 3
psiphon/controller.go

@@ -26,6 +26,7 @@ package psiphon
 import (
 	"errors"
 	"fmt"
+	"io"
 	"log"
 	"net"
 	"os"
@@ -417,7 +418,7 @@ type TunneledConn struct {
 
 func (conn *TunneledConn) Read(buffer []byte) (n int, err error) {
 	n, err = conn.Conn.Read(buffer)
-	if err != nil {
+	if err != nil && err != io.EOF {
 		// Report 1 new failure. Won't block; assumes the receiver
 		// has a sufficient buffer for the threshold number of reports.
 		// TODO: conditional on type of error or error message?
@@ -431,7 +432,7 @@ func (conn *TunneledConn) Read(buffer []byte) (n int, err error) {
 
 func (conn *TunneledConn) Write(buffer []byte) (n int, err error) {
 	n, err = conn.Conn.Write(buffer)
-	if err != nil {
+	if err != nil && err != io.EOF {
 		// Same as TunneledConn.Read()
 		select {
 		case conn.tunnel.portForwardFailures <- 1:
@@ -441,7 +442,7 @@ func (conn *TunneledConn) Write(buffer []byte) (n int, err error) {
 	return
 }
 
-// DialWithTunnel selects an active tunnel and establishes a port forward
+// Dial selects an active tunnel and establishes a port forward
 // connection through the selected tunnel. Failure to connect is considered
 // a port foward failure, for the purpose of monitoring tunnel health.
 func (controller *Controller) Dial(remoteAddr string) (conn net.Conn, err error) {

+ 1 - 1
psiphon/tunnel.go

@@ -32,7 +32,7 @@ import (
 )
 
 // Tunneler specifies the interface required by components that use a tunnel.
-// Components which use this interface may be services by a single Tunnel instance,
+// Components which use this interface may be serviced by a single Tunnel instance,
 // or a Controller which manages a pool of tunnels, or any other object which
 // implements Tunneler.
 type Tunneler interface {