Procházet zdrojové kódy

[misc] optionally expose the hostname in the 'debug.getHostname' rpc

Jakob Ackermann před 6 roky
rodič
revize
9fff03bca5

+ 15 - 0
services/real-time/app/js/Router.js

@@ -21,6 +21,8 @@ const httpAuth = basicAuth(function (user, pass) {
   return isValid
 })
 
+const HOSTNAME = require('os').hostname()
+
 let Router
 module.exports = Router = {
   _handleError(callback, error, client, method, attrs) {
@@ -157,6 +159,19 @@ module.exports = Router = {
         user = { _id: 'anonymous-user' }
       }
 
+      if (settings.exposeHostname) {
+        client.on('debug.getHostname', function (callback) {
+          if (typeof callback !== 'function') {
+            return Router._handleInvalidArguments(
+              client,
+              'debug.getHostname',
+              arguments
+            )
+          }
+          callback(HOSTNAME)
+        })
+      }
+
       client.on('joinProject', function (data, callback) {
         data = data || {}
         if (typeof callback !== 'function') {

+ 3 - 0
services/real-time/config/settings.defaults.js

@@ -109,6 +109,9 @@ const settings = {
 
   cookieName: process.env.COOKIE_NAME || 'sharelatex.sid',
 
+  // Expose the hostname in the `debug.getHostname` rpc
+  exposeHostname: process.env.EXPOSE_HOSTNAME === 'true',
+
   max_doc_length: 2 * 1024 * 1024, // 2mb
 
   // combine