mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 21:12:45 +00:00
unix socket support (#2974)
### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below using a legally identifiable name](https://matrix-org.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately Signed-off-by: `Boris Rybalkin <ribalkin@gmail.com>` I need this for Syncloud project (https://github.com/syncloud/platform) where I run multiple apps behind an nginx on the same RPi like device so unix socket is very convenient to not have port conflicts between apps. Also someone opened this Issue: https://github.com/matrix-org/dendrite/issues/2924 --------- Co-authored-by: kegsay <kegan@matrix.org> Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com>
This commit is contained in:
parent
6c20f8f742
commit
6b1c9eafa9
6 changed files with 171 additions and 29 deletions
|
@ -16,6 +16,7 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"io/fs"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
|
@ -30,6 +31,12 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
unixSocket = flag.String("unix-socket", "",
|
||||
"EXPERIMENTAL(unstable): The HTTP listening unix socket for the server (disables http[s]-bind-address feature)",
|
||||
)
|
||||
unixSocketPermission = flag.Int("unix-socket-permission", 0755,
|
||||
"EXPERIMENTAL(unstable): The HTTP listening unix socket permission for the server",
|
||||
)
|
||||
httpBindAddr = flag.String("http-bind-address", ":8008", "The HTTP listening port for the server")
|
||||
httpsBindAddr = flag.String("https-bind-address", ":8448", "The HTTPS listening port for the server")
|
||||
certFile = flag.String("tls-cert", "", "The PEM formatted X509 certificate to use for TLS")
|
||||
|
@ -38,8 +45,23 @@ var (
|
|||
|
||||
func main() {
|
||||
cfg := setup.ParseFlags(true)
|
||||
httpAddr := config.HTTPAddress("http://" + *httpBindAddr)
|
||||
httpsAddr := config.HTTPAddress("https://" + *httpsBindAddr)
|
||||
httpAddr := config.ServerAddress{}
|
||||
httpsAddr := config.ServerAddress{}
|
||||
if *unixSocket == "" {
|
||||
http, err := config.HTTPAddress("http://" + *httpBindAddr)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Fatalf("Failed to parse http address")
|
||||
}
|
||||
httpAddr = http
|
||||
https, err := config.HTTPAddress("https://" + *httpsBindAddr)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Fatalf("Failed to parse https address")
|
||||
}
|
||||
httpsAddr = https
|
||||
} else {
|
||||
httpAddr = config.UnixSocketAddress(*unixSocket, fs.FileMode(*unixSocketPermission))
|
||||
}
|
||||
|
||||
options := []basepkg.BaseDendriteOptions{}
|
||||
|
||||
base := basepkg.NewBaseDendrite(cfg, options...)
|
||||
|
@ -92,7 +114,7 @@ func main() {
|
|||
base.SetupAndServeHTTP(httpAddr, nil, nil)
|
||||
}()
|
||||
// Handle HTTPS if certificate and key are provided
|
||||
if *certFile != "" && *keyFile != "" {
|
||||
if *unixSocket == "" && *certFile != "" && *keyFile != "" {
|
||||
go func() {
|
||||
base.SetupAndServeHTTP(httpsAddr, certFile, keyFile)
|
||||
}()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue