|
|
@@ -51,6 +51,7 @@ import (
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/protocol"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/refraction"
|
|
|
+ "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/stacktrace"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tactics"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/transforms"
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/tun"
|
|
|
@@ -553,6 +554,23 @@ type additionalTransportData struct {
|
|
|
steeringIP string
|
|
|
}
|
|
|
|
|
|
+// reportListenerError logs a listener error and sends it the
|
|
|
+// TunnelServer.Run. Callers should wrap the input err in an immediate
|
|
|
+// errors.Trace.
|
|
|
+func reportListenerError(listenerError chan<- error, err error) {
|
|
|
+
|
|
|
+ // Record "caller" just in case the caller fails to wrap err in an
|
|
|
+ // errors.Trace.
|
|
|
+ log.WithTraceFields(
|
|
|
+ LogFields{
|
|
|
+ "error": err,
|
|
|
+ "caller": stacktrace.GetParentFunctionName()}).Error("listener error")
|
|
|
+ select {
|
|
|
+ case listenerError <- err:
|
|
|
+ default:
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// runListener is intended to run an a goroutine; it blocks
|
|
|
// running a particular listener. If an unrecoverable error
|
|
|
// occurs, it will send the error to the listenerError channel.
|
|
|
@@ -624,10 +642,7 @@ func (sshServer *sshServer) runListener(sshListener *sshListener, listenerError
|
|
|
}
|
|
|
|
|
|
if err != nil {
|
|
|
- select {
|
|
|
- case listenerError <- errors.Trace(err):
|
|
|
- default:
|
|
|
- }
|
|
|
+ reportListenerError(listenerError, errors.Trace(err))
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
@@ -673,10 +688,7 @@ func (sshServer *sshServer) runMeekTLSOSSHDemuxListener(
|
|
|
sshListener.tunnelProtocol,
|
|
|
sshListener.port)
|
|
|
if err != nil {
|
|
|
- select {
|
|
|
- case listenerError <- errors.Trace(err):
|
|
|
- default:
|
|
|
- }
|
|
|
+ reportListenerError(listenerError, errors.Trace(err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -713,10 +725,7 @@ func (sshServer *sshServer) runMeekTLSOSSHDemuxListener(
|
|
|
|
|
|
err := mux.run()
|
|
|
if err != nil {
|
|
|
- select {
|
|
|
- case listenerError <- errors.Trace(err):
|
|
|
- default:
|
|
|
- }
|
|
|
+ reportListenerError(listenerError, errors.Trace(err))
|
|
|
return
|
|
|
}
|
|
|
}()
|
|
|
@@ -764,10 +773,7 @@ func (sshServer *sshServer) runMeekTLSOSSHDemuxListener(
|
|
|
}
|
|
|
|
|
|
if err != nil {
|
|
|
- select {
|
|
|
- case listenerError <- errors.Trace(err):
|
|
|
- default:
|
|
|
- }
|
|
|
+ reportListenerError(listenerError, errors.Trace(err))
|
|
|
return
|
|
|
}
|
|
|
}()
|
|
|
@@ -805,10 +811,7 @@ func runListener(
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- select {
|
|
|
- case listenerError <- errors.Trace(err):
|
|
|
- default:
|
|
|
- }
|
|
|
+ reportListenerError(listenerError, errors.Trace(err))
|
|
|
return
|
|
|
}
|
|
|
|