Просмотр исходного кода

Introduce ICE_SERVERS variable

Replaces `SALTYRTC_STUN` and `SALTYRTC_TURN` config variables.

Additionally, remove redundant STUN server (TURN servers are also used
as STUN servers).
Lennart Grahl 8 лет назад
Родитель
Сommit
e4ee08643b
6 измененных файлов с 8 добавлено и 14 удалено
  1. 1 2
      README.md
  2. 1 2
      docs/self_hosting.md
  3. 2 5
      src/config.ts
  4. 2 2
      src/services/peerconnection.ts
  5. 1 1
      src/services/webclient.ts
  6. 1 2
      src/threema.d.ts

+ 1 - 2
README.md

@@ -80,8 +80,7 @@ The configuration of Threema Web can be tweaked in `src/config.ts`:
 
 **ICE**
 
-- `SALTYRTC_STUN`: Configuration object for the WebRTC STUN server.
-- `SALTYRTC_TURN`: Configuration object for the WebRTC TURN server.
+- `ICE_SERVERS`: Configuration object for the WebRTC STUN and ICE servers.
 
 **Push**
 

+ 1 - 2
docs/self_hosting.md

@@ -30,8 +30,7 @@ First, adjust the configuration in `src/config.ts`:
 
 - Set `SELF_HOSTED` to `true`
 - If you host your own SaltyRTC server, adjust the `SALTYRTC_*` variables
-- If you host your own STUN / TURN server, adjust the `SALTYRTC_STUN` and
-  `SALTYRTC_TURN` variables
+- If you host your own STUN / TURN server, adjust the `ICE_SERVERS` variable
 
 Then, build the release version of Threema Web:
 

+ 2 - 5
src/config.ts

@@ -16,14 +16,11 @@ export default {
     SALTYRTC_SERVER_KEY: 'b1337fc8402f7db8ea639e05ed05d65463e24809792f91eca29e88101b4a2171',
 
     // ICE
-    SALTYRTC_STUN: {
-        urls: 'stun:stun.threema.ch:443',
-    },
-    SALTYRTC_TURN: {
+    ICE_SERVERS: [{
         urls: 'turn:turn.threema.ch:443',
         username: 'threema-angular',
         credential: 'Uv0LcCq3kyx6EiRwQW5jVigkhzbp70CjN2CJqzmRxG3UGIdJHSJV6tpo7Gj7YnGB',
-    },
+    }],
 
     // Push
     PUSH_URL: 'https://push-web.threema.ch/push',

+ 2 - 2
src/services/peerconnection.ts

@@ -46,7 +46,7 @@ export class PeerConnectionHelper {
     constructor($log: ng.ILogService, $q: ng.IQService,
                 $timeout: ng.ITimeoutService, $rootScope: ng.IRootScopeService,
                 webrtcTask: saltyrtc.tasks.webrtc.WebRTCTask,
-                stunServer: RTCIceServer, turnServer: RTCIceServer) {
+                iceServers: RTCIceServer[]) {
         this.$log = $log;
         this.$log.info('Initialize WebRTC PeerConnection');
         this.$q = $q;
@@ -56,7 +56,7 @@ export class PeerConnectionHelper {
         this.webrtcTask = webrtcTask;
 
         // Set up peer connection
-        this.pc = new RTCPeerConnection({iceServers: [stunServer, turnServer]});
+        this.pc = new RTCPeerConnection({iceServers: iceServers});
         this.pc.onnegotiationneeded = (e: Event) => {
             this.$log.debug(this.logTag, 'RTCPeerConnection: negotiation needed');
             this.initiatorFlow().then(

+ 1 - 1
src/services/webclient.ts

@@ -368,7 +368,7 @@ export class WebClientService implements threema.WebClientService {
         this.salty.once('state-change:task', () => {
             this.pcHelper = new PeerConnectionHelper(this.$log, this.$q, this.$timeout,
                                                      this.$rootScope, this.webrtcTask,
-                                                     this.config.SALTYRTC_STUN, this.config.SALTYRTC_TURN);
+                                                     this.config.ICE_SERVERS);
 
             // On state changes in the PeerConnectionHelper class, let state service know about it
             this.pcHelper.onConnectionStateChange = (state: threema.RTCConnectionState) => {

+ 1 - 2
src/threema.d.ts

@@ -469,8 +469,7 @@ declare namespace threema {
         SALTYRTC_HOST: string | null;
         SALTYRTC_HOST_PREFIX: string | null;
         SALTYRTC_HOST_SUFFIX: string | null;
-        SALTYRTC_STUN: RTCIceServer;
-        SALTYRTC_TURN: RTCIceServer;
+        ICE_SERVERS: RTCIceServer[];
         PUSH_URL: string;
     }