Skip to content

Commit f0315f9

Browse files
committed
Remove non-WHIP/WHEP compliant ICE Server Configuration
1 parent ce0815c commit f0315f9

9 files changed

Lines changed: 13 additions & 192 deletions

File tree

.env.development

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@
3535
# FRONTEND_PATH="./web/build"
3636

3737
# ################
38-
# TURN/STUN
38+
# STUN
3939
# ################
4040

4141
# STUN_SERVERS="192.168.1.101:3478|192.168.1.101:3478"
42-
# TURN_SERVERS="192.168.1.123:3478|192.168.1.321:3478"
43-
# TURN_SERVERS_INTERNAL="10.100.0.10:3478"
44-
# STUN_SERVERS_INTERNAL="10.100.0.10:3478"
45-
# TURN_SERVER_AUTH_SECRET="YouSecret"
4642

4743
# ################
4844
# DEBUGGING

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,13 @@ The frontend can be configured by passing these URL Parameters.
258258
| `TCP_MUX_FORCE` | Forces WebRTC traffic to use TCP only. |
259259
| `APPEND_CANDIDATE` | Appends ICE candidates not generated by the agent. |
260260

261-
### STUN/TURN Servers
262-
263-
| Variable | Description |
264-
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
265-
| `STUN_SERVERS` | List of public STUN servers separated by `\|`. |
266-
| `STUN_SERVERS_INTERNAL` | List of internal STUN servers used by the backend in case it has trouble connecting to the public STUN server. Separated by `\|`. |
267-
| `TURN_SERVERS` | List of public TURN servers separated by `\|`. |
268-
| `TURN_SERVERS_INTERNAL` | List of internal TURN servers used by the backend in case it has trouble connecting to the public TURN server. Separated by `\|`. |
269-
| `TURN_SERVER_AUTH_SECRET` | Shared secret for TURN server authentication. |
261+
### STUN Servers
262+
263+
| Variable | Description |
264+
| -------------- | ------------------------------------------------------ |
265+
| `STUN_SERVERS` | List of STUN servers separated by `\|`. |
266+
267+
These values are parsed by the Go backend and applied to WHIP/WHEP `PeerConnection` configuration server-side. Clients do not fetch ICE server configuration from an API endpoint.
270268

271269
### Debugging
272270

internal/environment/variables.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ const (
3838
NAT1To1IP = "NAT_1_TO_1_IP"
3939
NATICECandidateType = "NAT_ICE_CANDIDATE_TYPE"
4040

41-
// TURN/STUN
42-
STUNServers = "STUN_SERVERS"
43-
TURNServers = "TURN_SERVERS"
44-
TURNServersInternal = "TURN_SERVERS_INTERNAL"
45-
STUNServersInternal = "STUN_SERVERS_INTERNAL"
46-
TURNServerAuthSecret = "TURN_SERVER_AUTH_SECRET"
41+
// STUN
42+
STUNServers = "STUN_SERVERS"
4743

4844
// PEERCONNECTION
4945
AppendCandidate = "APPEND_CANDIDATE"

internal/server/authorization/ice_connection_helpers.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

internal/server/handlers/client_ice.go

Lines changed: 0 additions & 85 deletions
This file was deleted.

internal/server/handlers/routes.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func GetServeMuxHandler() http.HandlerFunc {
2424
serverMux.HandleFunc("/api/whep", corsHandler(WHEPHandler))
2525
serverMux.HandleFunc("/api/whep/", corsHandler(WHEPHandler))
2626
serverMux.HandleFunc("/api/sse/", corsHandler(sseHandler))
27-
serverMux.HandleFunc("/api/ice-servers", corsHandler(clientICEHandler))
2827

2928
// WHIP session endpoints
3029
serverMux.HandleFunc("/api/whip", corsHandler(whipHandlers.WHIPHandler))

internal/webrtc/peerconnection/get_configuration.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,17 @@ import (
55
"strings"
66

77
"github.com/glimesh/broadcast-box/internal/environment"
8-
"github.com/glimesh/broadcast-box/internal/server/authorization"
98
"github.com/pion/webrtc/v4"
109
)
1110

1211
func GetPeerConnectionConfig() webrtc.Configuration {
1312
config := webrtc.Configuration{}
14-
if stunServers := os.Getenv(environment.STUNServersInternal); stunServers != "" {
13+
if stunServers := os.Getenv(environment.STUNServers); stunServers != "" {
1514
for stunServer := range strings.SplitSeq(stunServers, "|") {
1615
config.ICEServers = append(config.ICEServers, webrtc.ICEServer{
1716
URLs: []string{"stun:" + stunServer},
1817
})
1918
}
20-
} else if stunServers := os.Getenv(environment.STUNServers); stunServers != "" {
21-
for stunServer := range strings.SplitSeq(stunServers, "|") {
22-
config.ICEServers = append(config.ICEServers, webrtc.ICEServer{
23-
URLs: []string{"stun:" + stunServer},
24-
})
25-
}
26-
}
27-
28-
username, credential := authorization.GetTURNCredentials()
29-
30-
if turnServers := os.Getenv(environment.TURNServersInternal); turnServers != "" {
31-
for turnServer := range strings.SplitSeq(turnServers, "|") {
32-
config.ICEServers = append(config.ICEServers, webrtc.ICEServer{
33-
URLs: []string{"turn:" + turnServer},
34-
Username: username,
35-
Credential: credential,
36-
})
37-
}
38-
} else if turnServers := os.Getenv(environment.TURNServers); turnServers != "" {
39-
for turnServer := range strings.SplitSeq(turnServers, "|") {
40-
config.ICEServers = append(config.ICEServers, webrtc.ICEServer{
41-
URLs: []string{"turn:" + turnServer},
42-
Username: username,
43-
Credential: credential,
44-
})
45-
}
4619
}
4720

4821
return config

web/src/components/broadcast/Broadcast.tsx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,8 @@ function BrowserBroadcaster() {
4040

4141
const endStream = () => navigate('/')
4242

43-
interface ICEComponentServer {
44-
urls: string;
45-
username?: string;
46-
credential?: string
47-
}
48-
4943
useEffect(() => {
50-
// Fetch ICE-Servers
51-
fetch(`/api/ice-servers`, {
52-
method: 'GET',
53-
}).then(r => r.json())
54-
.then((result: ICEComponentServer[]) => {
55-
peerConnectionRef.current = new RTCPeerConnection({
56-
iceServers: result.map(r => ({
57-
urls: r.urls,
58-
username: r.username,
59-
credential: r.credential,
60-
}))
61-
});
62-
})
44+
peerConnectionRef.current = new RTCPeerConnection();
6345

6446
return () => peerConnectionRef.current?.close()
6547
}, [])

web/src/components/player/functions/peerconnection.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,7 @@ export async function PeerConnectionSetup(props: SetupPeerConnectionProps): Prom
166166
}
167167

168168
async function createPeerConnection(): Promise<RTCPeerConnection> {
169-
return await fetch(`/api/ice-servers`, {
170-
method: 'GET',
171-
}).then(r => r.json())
172-
.then((result) => {
173-
return new RTCPeerConnection({
174-
iceServers: result
175-
});
176-
}).catch(() => {
177-
console.error("Error calling Ice-Servers endpoint. Ignoring STUN/TURN configuration")
178-
return new RTCPeerConnection();
179-
})
169+
return new RTCPeerConnection();
180170
}
181171

182172
export function waitForIceGatheringComplete(peerConnection: RTCPeerConnection) {

0 commit comments

Comments
 (0)