forked from cwtch.im/cwtch
Merge branch 'launchPeers' of dan/cwtch into master
This commit is contained in:
commit
746c5397fd
|
@ -74,7 +74,6 @@ func (app *application) CreatePeer(name string, password string) (peer.CwtchPeer
|
|||
return nil, err
|
||||
}
|
||||
p.Init(app.acn)
|
||||
p.Listen()
|
||||
_, exists := app.peers[p.GetProfile().Onion]
|
||||
if exists {
|
||||
p.Shutdown()
|
||||
|
@ -126,17 +125,11 @@ func (app *application) LoadProfiles(password string) error {
|
|||
func (app *application) LaunchPeers() {
|
||||
for _, p := range app.peers {
|
||||
if !p.IsStarted() {
|
||||
app.startPeer(p)
|
||||
p.Listen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (app *application) startPeer(peer peer.CwtchPeer) {
|
||||
go func() {
|
||||
peer.Listen()
|
||||
}()
|
||||
}
|
||||
|
||||
// ListPeers returns a map of onions to their profile's Name
|
||||
func (app *application) ListPeers() map[string]string {
|
||||
keys := map[string]string{}
|
||||
|
|
|
@ -337,6 +337,7 @@ func main() {
|
|||
fmt.Printf("Error creating profile for %v: Your password entries must match!\n", name)
|
||||
} else {
|
||||
p, err := app.CreatePeer(name, password)
|
||||
app.LaunchPeers()
|
||||
if err == nil {
|
||||
stopGroupFollow()
|
||||
fmt.Printf("\nNew profile created for %v\n", name)
|
||||
|
@ -356,6 +357,7 @@ func main() {
|
|||
|
||||
err = app.LoadProfiles(string(bytePassword))
|
||||
if err == nil {
|
||||
app.LaunchPeers()
|
||||
profiles := app.ListPeers()
|
||||
fmt.Printf("\n%v profiles active now\n", len(profiles))
|
||||
fmt.Printf("You should run `select-profile` to use a profile or `list-profiles` to view loaded profiles\n")
|
||||
|
|
Loading…
Reference in New Issue