mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 05:13:11 -06:00
add -peer switch
This commit is contained in:
parent
512377d45b
commit
263fea7aed
|
|
@ -45,6 +45,7 @@ import (
|
|||
var (
|
||||
instanceName = flag.String("name", "dendrite-p2p-ygg", "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", "", "an internet Yggdrasil peer to connect to")
|
||||
)
|
||||
|
||||
type yggroundtripper struct {
|
||||
|
|
@ -95,7 +96,7 @@ func main() {
|
|||
},
|
||||
}
|
||||
|
||||
ygg, err := yggconn.Setup(*instanceName)
|
||||
ygg, err := yggconn.Setup(*instanceName, *instancePeer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type Node struct {
|
|||
incoming chan *yamux.Stream
|
||||
}
|
||||
|
||||
func Setup(instanceName string) (*Node, error) {
|
||||
func Setup(instanceName, instancePeer string) (*Node, error) {
|
||||
n := &Node{
|
||||
core: &yggdrasil.Core{},
|
||||
config: yggdrasilconfig.GenerateConfig(),
|
||||
|
|
@ -71,6 +71,11 @@ func Setup(instanceName string) (*Node, error) {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if instancePeer != "" {
|
||||
if err = n.core.AddPeer(instancePeer, ""); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if err = n.admin.Init(n.core, n.state, n.log, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue