| 1 |  | -From e5968e71e3ce40e24a5108d2dea7a9bc1d050559 Mon Sep 17 00:00:00 2001
 | 
| 2 |  | -From: Rod Hynes <rod-hynes@users.noreply.github.com>
 | 
| 3 |  | -Date: Mon, 29 Jan 2024 13:34:44 -0500
 | 
| 4 |  | -Subject: [PATCH] Fix Windows build
 | 
| 5 |  | -
 | 
| 6 |  | ----
 | 
| 7 |  | - pkg/transports/connecting/dtls/nat.go                |  5 ++---
 | 
| 8 |  | - pkg/transports/connecting/dtls/setsockopt_other.go   | 12 ++++++++++++
 | 
| 9 |  | - pkg/transports/connecting/dtls/setsockopt_windows.go | 12 ++++++++++++
 | 
| 10 |  | - 3 files changed, 26 insertions(+), 3 deletions(-)
 | 
| 11 |  | - create mode 100644 pkg/transports/connecting/dtls/setsockopt_other.go
 | 
| 12 |  | - create mode 100644 pkg/transports/connecting/dtls/setsockopt_windows.go
 | 
| 13 |  | -
 | 
| 14 |  | -diff --git a/pkg/transports/connecting/dtls/nat.go b/pkg/transports/connecting/dtls/nat.go
 | 
| 15 |  | -index 8860316b..ab3716b9 100644
 | 
| 16 |  | ---- a/pkg/transports/connecting/dtls/nat.go
 | 
| 17 |  | -+++ b/pkg/transports/connecting/dtls/nat.go
 | 
| 18 |  | -@@ -5,7 +5,6 @@ import (
 | 
| 19 |  | - 	"fmt"
 | 
| 20 |  | - 	"net"
 | 
| 21 |  | - 	"os"
 | 
| 22 |  | --	"syscall"
 | 
| 23 |  | - 	"time"
 | 
| 24 |  | - 
 | 
| 25 |  | - 	"github.com/pion/stun"
 | 
| 26 |  | -@@ -58,7 +57,7 @@ func openUDPLimitTTL(ctx context.Context, laddr, addr string, dialer dialFunc) e
 | 
| 27 |  | - 	defer fd.Close()
 | 
| 28 |  | - 
 | 
| 29 |  | - 	// Set the TTL
 | 
| 30 |  | --	err = syscall.SetsockoptInt(int(fd.Fd()), syscall.IPPROTO_IP, syscall.IP_TTL, ttl)
 | 
| 31 |  | -+	err = setSocketTTL(fd, ttl)
 | 
| 32 |  | - 	if err != nil {
 | 
| 33 |  | - 		return err
 | 
| 34 |  | - 	}
 | 
| 35 |  | -@@ -70,7 +69,7 @@ func openUDPLimitTTL(ctx context.Context, laddr, addr string, dialer dialFunc) e
 | 
| 36 |  | - 	}
 | 
| 37 |  | - 
 | 
| 38 |  | - 	// reset TTL
 | 
| 39 |  | --	err = syscall.SetsockoptInt(int(fd.Fd()), syscall.IPPROTO_IP, syscall.IP_TTL, defaultTTL)
 | 
| 40 |  | -+	err = setSocketTTL(fd, defaultTTL)
 | 
| 41 |  | - 	if err != nil {
 | 
| 42 |  | - 		return err
 | 
| 43 |  | - 	}
 | 
| 44 |  | -diff --git a/pkg/transports/connecting/dtls/setsockopt_other.go b/pkg/transports/connecting/dtls/setsockopt_other.go
 | 
| 45 |  | -new file mode 100644
 | 
| 46 |  | -index 00000000..eeba1ed6
 | 
| 47 |  | ---- /dev/null
 | 
| 48 |  | -+++ b/pkg/transports/connecting/dtls/setsockopt_other.go
 | 
| 49 |  | -@@ -0,0 +1,12 @@
 | 
| 50 |  | -+//go:build !windows
 | 
| 51 |  | -+
 | 
| 52 |  | -+package dtls
 | 
| 53 |  | -+
 | 
| 54 |  | -+import (
 | 
| 55 |  | -+	"os"
 | 
| 56 |  | -+	"syscall"
 | 
| 57 |  | -+)
 | 
| 58 |  | -+
 | 
| 59 |  | -+func setSocketTTL(f *os.File, ttl int) error {
 | 
| 60 |  | -+	return syscall.SetsockoptInt(int(f.Fd()), syscall.IPPROTO_IP, syscall.IP_TTL, ttl)
 | 
| 61 |  | -+}
 | 
| 62 |  | -diff --git a/pkg/transports/connecting/dtls/setsockopt_windows.go b/pkg/transports/connecting/dtls/setsockopt_windows.go
 | 
| 63 |  | -new file mode 100644
 | 
| 64 |  | -index 00000000..6ab835ea
 | 
| 65 |  | ---- /dev/null
 | 
| 66 |  | -+++ b/pkg/transports/connecting/dtls/setsockopt_windows.go
 | 
| 67 |  | -@@ -0,0 +1,12 @@
 | 
| 68 |  | -+//go:build windows
 | 
| 69 |  | -+
 | 
| 70 |  | -+package dtls
 | 
| 71 |  | -+
 | 
| 72 |  | -+import (
 | 
| 73 |  | -+	"os"
 | 
| 74 |  | -+	"syscall"
 | 
| 75 |  | -+)
 | 
| 76 |  | -+
 | 
| 77 |  | -+func setSocketTTL(f *os.File, ttl int) error {
 | 
| 78 |  | -+	return syscall.SetsockoptInt(syscall.Handle(f.Fd()), syscall.IPPROTO_IP, syscall.IP_TTL, ttl)
 | 
| 79 |  | -+} |