Add pinecone listener

This commit is contained in:
Neil Alexander 2020-11-26 16:35:23 +00:00
parent 5ed6c2be87
commit 39da41c3ba
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -59,6 +59,7 @@ var (
instanceName = flag.String("name", "dendrite-p2p-pinecone", "the name of this P2P demo instance")
instancePort = flag.Int("port", 8008, "the port that the client API will listen on")
instancePeer = flag.String("peer", "", "the static Pinecone peer to connect to")
instanceListen = flag.String("listen", ":0", "the port Pinecone peers can connect to")
)
// nolint:gocyclo
@ -110,6 +111,29 @@ func main() {
}(*instancePeer)
}
go func() {
listener, err := net.Listen("tcp", *instanceListen)
if err != nil {
panic(err)
}
fmt.Println("Listening on", listener.Addr())
for {
conn, err := listener.Accept()
if err != nil {
panic(err)
}
port, err := pSwitch.AuthenticatedConnect(conn, "")
if err != nil {
panic(err)
}
fmt.Println("Inbound connection", conn.RemoteAddr(), "is connected to port", port)
}
}()
pQUIC := pineconeSessions.NewQUIC(logger, pRouter)
_ = pineconeMulticast.NewMulticast(logger, pSwitch)