mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Bind build support, further Yggdrasil demo updates (#1152)
* Add gobind builds for Yggdrasil demo * Massage client API a bit * Fix build * Fix gobind build * Fix gobind client API setup * Tweaks * Tweaks * Update sytest-whitelist, add comment * Default to sending push rules on initial sync
This commit is contained in:
parent
72444e4a4f
commit
7f26b0cd13
15 changed files with 336 additions and 65 deletions
|
@ -47,52 +47,11 @@ var (
|
|||
instancePeer = flag.String("peer", "", "an internet Yggdrasil peer to connect to")
|
||||
)
|
||||
|
||||
type yggroundtripper struct {
|
||||
inner *http.Transport
|
||||
}
|
||||
|
||||
func (y *yggroundtripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
req.URL.Scheme = "http"
|
||||
return y.inner.RoundTrip(req)
|
||||
}
|
||||
|
||||
func createFederationClient(
|
||||
base *setup.BaseDendrite, n *yggconn.Node,
|
||||
) *gomatrixserverlib.FederationClient {
|
||||
tr := &http.Transport{}
|
||||
tr.RegisterProtocol(
|
||||
"matrix", &yggroundtripper{
|
||||
inner: &http.Transport{
|
||||
ResponseHeaderTimeout: 15 * time.Second,
|
||||
IdleConnTimeout: 60 * time.Second,
|
||||
DialContext: n.DialerContext,
|
||||
},
|
||||
},
|
||||
)
|
||||
return gomatrixserverlib.NewFederationClientWithTransport(
|
||||
base.Cfg.Matrix.ServerName, base.Cfg.Matrix.KeyID, base.Cfg.Matrix.PrivateKey, tr,
|
||||
)
|
||||
}
|
||||
|
||||
func createClient(n *yggconn.Node) *gomatrixserverlib.Client {
|
||||
tr := &http.Transport{}
|
||||
tr.RegisterProtocol(
|
||||
"matrix", &yggroundtripper{
|
||||
inner: &http.Transport{
|
||||
ResponseHeaderTimeout: 15 * time.Second,
|
||||
IdleConnTimeout: 60 * time.Second,
|
||||
DialContext: n.DialerContext,
|
||||
},
|
||||
},
|
||||
)
|
||||
return gomatrixserverlib.NewClientWithTransport(tr)
|
||||
}
|
||||
|
||||
// nolint:gocyclo
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
ygg, err := yggconn.Setup(*instanceName, *instancePeer)
|
||||
ygg, err := yggconn.Setup(*instanceName, *instancePeer, ".")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -125,7 +84,7 @@ func main() {
|
|||
|
||||
accountDB := base.CreateAccountsDB()
|
||||
deviceDB := base.CreateDeviceDB()
|
||||
federation := createFederationClient(base, ygg)
|
||||
federation := ygg.CreateFederationClient(base)
|
||||
|
||||
serverKeyAPI := &signing.YggdrasilKeys{}
|
||||
keyRing := serverKeyAPI.KeyRing()
|
||||
|
@ -160,7 +119,7 @@ func main() {
|
|||
Config: base.Cfg,
|
||||
AccountDB: accountDB,
|
||||
DeviceDB: deviceDB,
|
||||
Client: createClient(ygg),
|
||||
Client: ygg.CreateClient(base),
|
||||
FedClient: federation,
|
||||
KeyRing: keyRing,
|
||||
KafkaConsumer: base.KafkaConsumer,
|
||||
|
@ -203,7 +162,7 @@ func main() {
|
|||
logrus.Fatal(httpServer.Serve(ygg))
|
||||
}()
|
||||
go func() {
|
||||
httpBindAddr := fmt.Sprintf("localhost:%d", *instancePort)
|
||||
httpBindAddr := fmt.Sprintf(":%d", *instancePort)
|
||||
logrus.Info("Listening on ", httpBindAddr)
|
||||
logrus.Fatal(http.ListenAndServe(httpBindAddr, base.BaseMux))
|
||||
}()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue