aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-08-13 18:27:19 +0100
committerGitHub <noreply@github.com>2020-08-13 18:27:19 +0100
commitc1f4faf308169d4008259772d04ce25444996f1e (patch)
tree7a292e8c6a91e9abcccf3f86306a8a551188ea56 /internal
parent20c8f252a7930e07a113e24acc59964e5e19e708 (diff)
Fix Docker builds, polylith components (#1269)
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config_syncapi.go5
-rw-r--r--internal/setup/base.go20
2 files changed, 15 insertions, 10 deletions
diff --git a/internal/config/config_syncapi.go b/internal/config/config_syncapi.go
index fc1bbcf8..0a96e41c 100644
--- a/internal/config/config_syncapi.go
+++ b/internal/config/config_syncapi.go
@@ -4,6 +4,7 @@ type SyncAPI struct {
Matrix *Global `yaml:"-"`
InternalAPI InternalAPIOptions `yaml:"internal_api"`
+ ExternalAPI ExternalAPIOptions `yaml:"external_api"`
Database DatabaseOptions `yaml:"database"`
}
@@ -11,6 +12,7 @@ type SyncAPI struct {
func (c *SyncAPI) Defaults() {
c.InternalAPI.Listen = "http://localhost:7773"
c.InternalAPI.Connect = "http://localhost:7773"
+ c.ExternalAPI.Listen = "http://localhost:8073"
c.Database.Defaults()
c.Database.ConnectionString = "file:syncapi.db"
}
@@ -18,5 +20,8 @@ func (c *SyncAPI) Defaults() {
func (c *SyncAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
checkURL(configErrs, "sync_api.internal_api.bind", string(c.InternalAPI.Connect))
+ if !isMonolith {
+ checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
+ }
checkNotEmpty(configErrs, "sync_api.database", string(c.Database.ConnectionString))
}
diff --git a/internal/setup/base.go b/internal/setup/base.go
index 2cffb4e8..854f39f0 100644
--- a/internal/setup/base.go
+++ b/internal/setup/base.go
@@ -287,7 +287,7 @@ func (b *BaseDendrite) SetupAndServeHTTP(
}
externalServ := internalServ
- if externalAddr != "" && externalAddr != internalAddr {
+ if externalAddr != NoExternalListener && externalAddr != internalAddr {
externalRouter = mux.NewRouter()
externalServ = &http.Server{
Addr: string(externalAddr),
@@ -307,32 +307,32 @@ func (b *BaseDendrite) SetupAndServeHTTP(
externalRouter.PathPrefix(httputil.PublicMediaPathPrefix).Handler(b.PublicMediaAPIMux)
go func() {
- logrus.Infof("Starting %s listener on %s", b.componentName, externalServ.Addr)
+ logrus.Infof("Starting %s listener on %s", b.componentName, internalServ.Addr)
if certFile != nil && keyFile != nil {
- if err := externalServ.ListenAndServeTLS(*certFile, *keyFile); err != nil {
+ if err := internalServ.ListenAndServeTLS(*certFile, *keyFile); err != nil {
logrus.WithError(err).Fatal("failed to serve HTTPS")
}
} else {
- if err := externalServ.ListenAndServe(); err != nil {
+ if err := internalServ.ListenAndServe(); err != nil {
logrus.WithError(err).Fatal("failed to serve HTTP")
}
}
- logrus.Infof("Stopped %s listener on %s", b.componentName, externalServ.Addr)
+ logrus.Infof("Stopped %s listener on %s", b.componentName, internalServ.Addr)
}()
- if internalAddr != "" && internalAddr != externalAddr {
+ if externalAddr != NoExternalListener && internalAddr != externalAddr {
go func() {
- logrus.Infof("Starting %s listener on %s", b.componentName, internalServ.Addr)
+ logrus.Infof("Starting %s listener on %s", b.componentName, externalServ.Addr)
if certFile != nil && keyFile != nil {
- if err := internalServ.ListenAndServeTLS(*certFile, *keyFile); err != nil {
+ if err := externalServ.ListenAndServeTLS(*certFile, *keyFile); err != nil {
logrus.WithError(err).Fatal("failed to serve HTTPS")
}
} else {
- if err := internalServ.ListenAndServe(); err != nil {
+ if err := externalServ.ListenAndServe(); err != nil {
logrus.WithError(err).Fatal("failed to serve HTTP")
}
}
- logrus.Infof("Stopped %s listener on %s", b.componentName, internalServ.Addr)
+ logrus.Infof("Stopped %s listener on %s", b.componentName, externalServ.Addr)
}()
}