mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 21:33:19 -06:00
Tweaks
This commit is contained in:
parent
563b946e34
commit
de09f4c759
|
|
@ -87,9 +87,9 @@ func main() {
|
||||||
httpServer := &http.Server{
|
httpServer := &http.Server{
|
||||||
Addr: ":0",
|
Addr: ":0",
|
||||||
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
|
TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
|
||||||
ReadTimeout: 5 * time.Second,
|
ReadTimeout: 30 * time.Second,
|
||||||
WriteTimeout: 10 * time.Second,
|
WriteTimeout: 30 * time.Second,
|
||||||
IdleTimeout: 15 * time.Second,
|
IdleTimeout: 60 * time.Second,
|
||||||
BaseContext: func(_ net.Listener) context.Context {
|
BaseContext: func(_ net.Listener) context.Context {
|
||||||
return context.Background()
|
return context.Background()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ func Setup(instanceName string) (*Node, error) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if e := ioutil.WriteFile(yggfile, j, 0600); e != nil {
|
if e := ioutil.WriteFile(yggfile, j, 0600); e != nil {
|
||||||
fmt.Printf("Couldn't write private key to file '%s': %s\n", yggfile, e)
|
n.log.Printf("Couldn't write private key to file '%s': %s\n", yggfile, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package yggconn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -12,7 +11,9 @@ import (
|
||||||
func (n *Node) yamuxConfig() *yamux.Config {
|
func (n *Node) yamuxConfig() *yamux.Config {
|
||||||
cfg := yamux.DefaultConfig()
|
cfg := yamux.DefaultConfig()
|
||||||
cfg.EnableKeepAlive = true
|
cfg.EnableKeepAlive = true
|
||||||
cfg.KeepAliveInterval = time.Second * 5
|
cfg.KeepAliveInterval = time.Second * 30
|
||||||
|
cfg.MaxMessageSize = 65535
|
||||||
|
cfg.ReadBufSize = 655350
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,12 +21,12 @@ func (n *Node) listenFromYgg() {
|
||||||
for {
|
for {
|
||||||
conn, err := n.listener.Accept()
|
conn, err := n.listener.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("n.listener.Accept:", err)
|
n.log.Println("n.listener.Accept:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session, err := yamux.Server(conn, n.yamuxConfig())
|
session, err := yamux.Server(conn, n.yamuxConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("yamux.Server:", err)
|
n.log.Println("yamux.Server:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go n.listenFromYggConn(session)
|
go n.listenFromYggConn(session)
|
||||||
|
|
@ -39,7 +40,7 @@ func (n *Node) listenFromYggConn(session *yamux.Session) {
|
||||||
for {
|
for {
|
||||||
st, err := session.AcceptStream()
|
st, err := session.AcceptStream()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("session.AcceptStream:", err)
|
n.log.Println("session.AcceptStream:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n.incoming <- st
|
n.incoming <- st
|
||||||
|
|
@ -73,12 +74,12 @@ func (n *Node) DialContext(ctx context.Context, network, address string) (net.Co
|
||||||
if !ok1 || !ok2 {
|
if !ok1 || !ok2 {
|
||||||
conn, err := n.dialer.DialContext(ctx, network, address)
|
conn, err := n.dialer.DialContext(ctx, network, address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("n.dialer.DialContext:", err)
|
n.log.Println("n.dialer.DialContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
session, err = yamux.Client(conn, n.yamuxConfig())
|
session, err = yamux.Client(conn, n.yamuxConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("yamux.Client.AcceptStream:", err)
|
n.log.Println("yamux.Client.AcceptStream:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
go n.listenFromYggConn(session)
|
go n.listenFromYggConn(session)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue