func (c *client) doCreateAccount() error { _, _, err := parseServer(c.server, c.dev) if err != nil { return err } if !c.dev { // Check that Tor is running. testConn, err := net.Dial("tcp", c.torAddress) if err != nil { return errors.New("Failed to connect to local Tor: " + err.Error()) } testConn.Close() } c.ui.Actions() <- SetText{name: "status", text: "Generating keys..."} c.ui.Signal() c.randBytes(c.identity[:]) curve25519.ScalarBaseMult(&c.identityPublic, &c.identity) c.ui.Actions() <- SetText{name: "status", text: "Connecting..."} c.ui.Signal() conn, err := c.dialServer(c.server, false) if err != nil { return err } defer conn.Close() c.ui.Actions() <- SetText{name: "status", text: "Requesting new account..."} c.ui.Signal() c.generation = uint32(c.randId()) request := new(pond.Request) request.NewAccount = &pond.NewAccount{ Generation: proto.Uint32(c.generation), Group: c.groupPriv.Group.Marshal(), } if err := conn.WriteProto(request); err != nil { return err } reply := new(pond.Reply) if err := conn.ReadProto(reply); err != nil { return err } if err := replyToError(reply); err != nil { return err } c.ui.Actions() <- SetText{name: "status", text: "Done"} c.ui.Signal() return nil }
func (c *client) doCreateAccount(displayMsg func(string)) error { _, _, err := parseServer(c.server, c.dev) if err != nil { return err } if !c.dev { // Check that Tor is running. testConn, err := net.Dial("tcp", c.torAddress) if err != nil { return errors.New("Failed to connect to local Tor: " + err.Error()) } testConn.Close() } displayMsg("Connecting...") conn, err := c.dialServer(c.server, false) if err != nil { return err } defer conn.Close() displayMsg("Requesting new account...") c.generation = uint32(c.randId()) request := new(pond.Request) request.NewAccount = &pond.NewAccount{ Generation: proto.Uint32(c.generation), Group: c.groupPriv.Group.Marshal(), } if err := conn.WriteProto(request); err != nil { return err } reply := new(pond.Reply) if err := conn.ReadProto(reply); err != nil { return err } if err := replyToError(reply); err != nil { return err } displayMsg("Done") return nil }