Skip to content

Possibility for plugins to get the listening host and port #5416

@JohnXLivingston

Description

@JohnXLivingston

Describe the problem to be solved

For the livechat plugin, I need to make API Calls from a XMPP server running on the Peertube server, to the Peertube instance.

For now, I use the public Peertube url to make these requests.

But this has 2 drawbacks:

  • requests go through nginx, but they could bypass nginx to directly hit Peertube, as it is on the same server (and use http instead of https for better perf)
  • in Docker installations, this can be a problem (the public url is not correctly resolved)

To fix the second point, I added a settings to change the API endpoint url, and you can for example set http://127.0.0.1:9000

I want to make this simpler, and I'd like to automatically compute this endpoint.

But for now, plugin manager provide no way to get the local host and port (the values listen.hostname and listen.port in the config file).

Describe the solution you would like

I'd like to have listen.host and listen.port somewhere in the helpers provided by Peertube.

For example, by adding it in the result of the backend getServerConfig helper.

Or by adding a new helper here:

function buildConfigHelpers () {
return {
getWebserverUrl () {
return WEBSERVER.URL
},
getServerConfig () {
return ServerConfigManager.Instance.getServerConfig()
}
}
}
. Could be something like that:

function buildConfigHelpers () {
  return {
    getWebserverUrl () {
      return WEBSERVER.URL
    },
    getServerListeningOptions {
        return { hostname: WEBSERVER.HOSTNAME, port: WEBSERVER.PORT }
    },
    getServerConfig () {
      return ServerConfigManager.Instance.getServerConfig()
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions