Browse Source

Expose net.UDPConn.File functionality for the Conjure DTLS transport

Rod Hynes 2 years ago
parent
commit
a9d0f0a511
1 changed files with 13 additions and 0 deletions
  1. 13 0
      psiphon/common/refraction/refraction.go

+ 13 - 0
psiphon/common/refraction/refraction.go

@@ -954,6 +954,19 @@ type managedConn struct {
 	manager *dialManager
 }
 
+type fileConn interface {
+	File() (*os.File, error)
+}
+
+// File exposes the net.UDPConn.File() functionality required by the Conjure
+// DTLS transport.
+func (conn *managedConn) File() (*os.File, error) {
+	if f, ok := conn.Conn.(fileConn); ok {
+		return f.File()
+	}
+	return nil, errors.TraceNew("underlying conn is not a fileConn")
+}
+
 // CloseWrite exposes the net.TCPConn.CloseWrite() functionality
 // required by TapDance.
 func (conn *managedConn) CloseWrite() error {