]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add ability to provide rtmp listening hostname
authorChocobozzz <me@florianbigard.com>
Mon, 2 May 2022 12:32:12 +0000 (14:32 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 2 May 2022 12:32:12 +0000 (14:32 +0200)
config/default.yaml
config/production.yaml.example
server/initializers/config.ts
server/initializers/constants.ts
server/lib/live/live-manager.ts

index 017b63e498efc59b4c1c9845045142e948d18ec9..7af9c929f4961f9cf1951e1be244a8471dcd6a29 100644 (file)
@@ -411,17 +411,27 @@ live:
   # Your firewall should accept traffic from this port in TCP if you enable live
   rtmp:
     enabled: true
-    port: 1935
+
     hostname: 'localhost'
+    port: 1935
+
+    # Public endpoint of your RTMP server
+    # Use null to use the same value than `webserver.hostname`
+    public_hostname: null
 
   rtmps:
     enabled: false
+
+    hostname: 'localhost'
     port: 1936
-    # Absolute path
+
+    # Absolute paths
     key_file: ''
-    # Absolute path
     cert_file: ''
-    hostname: 'localhost'
+
+    # Public endpoint of your RTMPS server
+    # Use null to use the same value than `webserver.hostname`
+    public_hostname: null
 
   # Allow to transcode the live streaming in multiple live resolutions
   transcoding:
index 8bdd30e2d48de91a53e4ee3bd7f39397893c75d3..048cb37e87449c12f4687c69ae1617a88bf6cac3 100644 (file)
@@ -419,17 +419,27 @@ live:
   # Your firewall should accept traffic from this port in TCP if you enable live
   rtmp:
     enabled: true
-    port: 1935
+
     hostname: 'localhost'
+    port: 1935
+
+    # Public endpoint of your RTMP server
+    # Use null to use the same value than `webserver.hostname`
+    public_hostname: null
 
   rtmps:
     enabled: false
+
+    hostname: 'localhost'
     port: 1936
-    # Absolute path
+
+    # Absolute paths
     key_file: ''
-    # Absolute path
     cert_file: ''
-    hostname: 'localhost'
+
+    # Public endpoint of your RTMPS server
+    # Use null to use the same value than `webserver.hostname`
+    public_hostname: null
 
   # Allow to transcode the live streaming in multiple live resolutions
   transcoding:
index d8f5f3496c05589d820e690f6d6c7496a1789077..59a65d6a56cd6ef33583e2cd7684670b5090cb0c 100644 (file)
@@ -313,13 +313,15 @@ const CONFIG = {
     RTMP: {
       get ENABLED () { return config.get<boolean>('live.rtmp.enabled') },
       get PORT () { return config.get<number>('live.rtmp.port') },
-      get HOSTNAME () { return config.get<number>('live.rtmp.hostname') }
+      get HOSTNAME () { return config.get<number>('live.rtmp.hostname') },
+      get PUBLIC_HOSTNAME () { return config.get<number>('live.rtmp.public_hostname') }
     },
 
     RTMPS: {
       get ENABLED () { return config.get<boolean>('live.rtmps.enabled') },
       get PORT () { return config.get<number>('live.rtmps.port') },
       get HOSTNAME () { return config.get<number>('live.rtmps.hostname') },
+      get PUBLIC_HOSTNAME () { return config.get<number>('live.rtmps.public_hostname') },
       get KEY_FILE () { return config.get<string>('live.rtmps.key_file') },
       get CERT_FILE () { return config.get<string>('live.rtmps.cert_file') }
     },
index 4656ccdbcdf661f86c7d3e2d0defad3a616d5750..9986dbf890c8f6c5a278906b8a3c8def1589f41f 100644 (file)
@@ -1074,8 +1074,11 @@ function updateWebserverUrls () {
   WEBSERVER.HOSTNAME = CONFIG.WEBSERVER.HOSTNAME
   WEBSERVER.PORT = CONFIG.WEBSERVER.PORT
 
-  WEBSERVER.RTMP_URL = 'rtmp://' + CONFIG.LIVE.RTMP.HOSTNAME + ':' + CONFIG.LIVE.RTMP.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
-  WEBSERVER.RTMPS_URL = 'rtmps://' + CONFIG.LIVE.RTMPS.HOSTNAME + ':' + CONFIG.LIVE.RTMPS.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
+  const rtmpHostname = CONFIG.LIVE.RTMP.PUBLIC_HOSTNAME || CONFIG.WEBSERVER.HOSTNAME
+  const rtmpsHostname = CONFIG.LIVE.RTMPS.PUBLIC_HOSTNAME || CONFIG.WEBSERVER.HOSTNAME
+
+  WEBSERVER.RTMP_URL = 'rtmp://' + rtmpHostname + ':' + CONFIG.LIVE.RTMP.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
+  WEBSERVER.RTMPS_URL = 'rtmps://' + rtmpsHostname + ':' + CONFIG.LIVE.RTMPS.PORT + '/' + VIDEO_LIVE.RTMP.BASE_PATH
 }
 
 function updateWebserverConfig () {
index 5ffe41ee33d7b17d82e487bc796b0742f13d8223..da09aa05c4b74d5d969065cfa836333072fef9bb 100644 (file)
@@ -118,7 +118,7 @@ class LiveManager {
         logger.error('Cannot run RTMP server.', { err, ...lTags() })
       })
 
-      this.rtmpServer.listen(CONFIG.LIVE.RTMP.PORT)
+      this.rtmpServer.listen(CONFIG.LIVE.RTMP.PORT, CONFIG.LIVE.RTMP.HOSTNAME)
     }
 
     if (CONFIG.LIVE.RTMPS.ENABLED) {
@@ -141,7 +141,7 @@ class LiveManager {
         logger.error('Cannot run RTMPS server.', { err, ...lTags() })
       })
 
-      this.rtmpsServer.listen(CONFIG.LIVE.RTMPS.PORT)
+      this.rtmpsServer.listen(CONFIG.LIVE.RTMPS.PORT, CONFIG.LIVE.RTMPS.HOSTNAME)
     }
   }