Ejemplo n.º 1
0
/*
 * Commands related to the key/value storage and retrieval
 */
func kvList(c *cli.Context) error {
	cfg := loadConfigOrFail(c)
	log.Infof("config for id %x", cfg.ID)
	for k, v := range cfg.Config.Data {
		log.Infof("%s: %s", k, v)
	}
	return nil
}
Ejemplo n.º 2
0
func followList(c *cli.Context) error {
	cfg := loadConfigOrFail(c)
	for _, id := range cfg.Follow {
		log.Infof("SCID: %x", id.ID)
		server := id.DeviceName
		log.Infof("Server %s is asked to accept ssh-keys from %s:",
			server,
			id.Config.GetIntermediateColumn("ssh", server))
	}
	return nil
}
Ejemplo n.º 3
0
// showDifference compares the propose and the config-part
func (cfg *ciscConfig) showDifference() {
	if cfg.Proposed == nil {
		log.Info("No proposed config found")
		return
	}
	for k, v := range cfg.Proposed.Data {
		orig, ok := cfg.Config.Data[k]
		if !ok || v != orig {
			log.Info("New or changed key:", k)
		}
	}
	for k := range cfg.Config.Data {
		_, ok := cfg.Proposed.Data[k]
		if !ok {
			log.Info("Deleted key:", k)
		}
	}
	for dev, pub := range cfg.Proposed.Device {
		if _, exists := cfg.Config.Device[dev]; !exists {
			log.Infof("New device: %s / %s", dev,
				pub.Point.String())
		}
	}
	for dev := range cfg.Config.Device {
		if _, exists := cfg.Proposed.Device[dev]; !exists {
			log.Info("Deleted device:", dev)
		}
	}
}
Ejemplo n.º 4
0
func configList(c *cli.Context) error {
	cfg := loadConfigOrFail(c)
	log.Info("Account name:", cfg.DeviceName)
	log.Infof("Identity-ID: %x", cfg.ID)
	if c.Bool("d") {
		log.Info(cfg.Config.Data)
	} else {
		cfg.showKeys()
	}
	if c.Bool("p") {
		if cfg.Proposed != nil {
			log.Infof("Proposed config: %s", cfg.Proposed)
		} else {
			log.Info("No proposed config")
		}
	}
	return nil
}
Ejemplo n.º 5
0
/*
 * Identity-related commands
 */
func idCreate(c *cli.Context) error {
	log.Info("Creating id")
	if c.NArg() == 0 {
		log.Fatal("Please give at least a group-definition")
	}

	group := getGroup(c)

	name, err := os.Hostname()
	log.ErrFatal(err)
	if c.NArg() > 1 {
		name = c.Args().Get(1)
	}
	log.Info("Creating new blockchain-identity for", name)

	thr := c.Int("threshold")
	cfg := &ciscConfig{Identity: identity.NewIdentity(group.Roster, thr, name)}
	log.ErrFatal(cfg.CreateIdentity())
	log.Infof("IC is %x", cfg.ID)
	log.Infof("Config to be saved: %+v", cfg.Identity.Cothority)
	return cfg.saveConfig(c)
}
Ejemplo n.º 6
0
func idConnect(c *cli.Context) error {
	log.Info("Connecting")
	name, err := os.Hostname()
	log.ErrFatal(err)
	switch c.NArg() {
	case 2:
		// We'll get all arguments after
	case 3:
		name = c.Args().Get(2)
	default:
		log.Fatal("Please give the following arguments: group.toml id [hostname]", c.NArg())
	}
	group := getGroup(c)
	idBytes, err := hex.DecodeString(c.Args().Get(1))
	log.ErrFatal(err)
	id := identity.ID(idBytes)
	cfg := &ciscConfig{Identity: identity.NewIdentity(group.Roster, 0, name)}
	cfg.AttachToIdentity(id)
	log.Infof("Public key: %s",
		cfg.Proposed.Device[cfg.DeviceName].Point.String())
	return cfg.saveConfig(c)
}