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