mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-10 16:33:11 -06:00
Add a method for getting RoomServerURL
This moves the hardcoding of HTTPs into one place.
This commit is contained in:
parent
c205b14c92
commit
5c21bf5781
|
|
@ -61,11 +61,7 @@ func main() {
|
|||
cfg.Matrix.ServerName, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey,
|
||||
)
|
||||
|
||||
// Hard code the roomserver to talk HTTP for now.
|
||||
// If we support HTTPS we need to think of a practical way to do certificate validation.
|
||||
// People setting up servers shouldn't need to get a certificate valid for the public
|
||||
// internet for an internal API.
|
||||
queryAPI := api.NewRoomserverQueryAPIHTTP("http://"+string(cfg.Listen.RoomServer), nil)
|
||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
||||
accountDB, err := accounts.NewDatabase(string(cfg.Database.Account), cfg.Matrix.ServerName)
|
||||
if err != nil {
|
||||
log.Panicf("Failed to setup account database(%q): %s", cfg.Database.Account, err.Error())
|
||||
|
|
|
|||
|
|
@ -63,11 +63,7 @@ func main() {
|
|||
KeyDatabase: keyDB,
|
||||
}
|
||||
|
||||
// Hard code the roomserver to talk HTTP for now.
|
||||
// If we support HTTPS we need to think of a practical way to do certificate validation.
|
||||
// People setting up servers shouldn't need to get a certificate valid for the public
|
||||
// internet for an internal API.
|
||||
queryAPI := api.NewRoomserverQueryAPIHTTP("http://"+string(cfg.Listen.RoomServer), nil)
|
||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
||||
|
||||
roomserverProducer, err := producers.NewRoomserverProducer(
|
||||
cfg.Kafka.Addresses, string(cfg.Kafka.Topics.InputRoomEvent),
|
||||
|
|
|
|||
|
|
@ -358,3 +358,12 @@ func fingerprintPEM(data []byte) *gomatrixserverlib.TLSFingerprint {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RoomServerURL returns an HTTP URL for where the roomserver is listening.
|
||||
func (config *Dendrite) RoomServerURL() string {
|
||||
// Hard code the roomserver to talk HTTP for now.
|
||||
// If we support HTTPS we need to think of a practical way to do certificate validation.
|
||||
// People setting up servers shouldn't need to get a certificate valid for the public
|
||||
// internet for an internal API.
|
||||
return "http://" + string(config.Listen.RoomServer)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func NewOutputRoomEvent(cfg *config.Dendrite, n *sync.Notifier, store *storage.S
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
roomserverURL := "http://" + string(cfg.Listen.RoomServer)
|
||||
roomServerURL := cfg.RoomServerURL()
|
||||
|
||||
consumer := common.ContinualConsumer{
|
||||
Topic: string(cfg.Kafka.Topics.OutputRoomEvent),
|
||||
|
|
@ -54,7 +54,7 @@ func NewOutputRoomEvent(cfg *config.Dendrite, n *sync.Notifier, store *storage.S
|
|||
roomServerConsumer: &consumer,
|
||||
db: store,
|
||||
notifier: n,
|
||||
query: api.NewRoomserverQueryAPIHTTP(roomserverURL, nil),
|
||||
query: api.NewRoomserverQueryAPIHTTP(roomServerURL, nil),
|
||||
}
|
||||
consumer.ProcessMessage = s.onMessage
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue