示例#1
0
文件: main.go 项目: sethjback/gobl
// Init sets up the environement to run
func Init(c *config.Config) error {
	gDb = &sqlite.SQLite{}
	err := gDb.Init(c.DB)

	//err = db.Init()
	if err != nil {
		return err
	}

	keyManager = &keys.Manager{PublicKeys: make(map[string]*rsa.PublicKey)}
	key, err := keys.OpenPrivateKey(c.Host.PrivateKeyPath)
	if err != nil {
		return err
	}

	keyManager.PrivateKey = key

	agents, err := gDb.AgentList()
	if err != nil {
		return err
	}

	for _, a := range agents {
		key, err := keys.DecodePublicKeyString(a.PublicKey)
		if err != nil {
			fmt.Println("Error decoding key for agent: ", a)
		} else {
			ip := strings.Split(a.Address, ":")
			keyManager.PublicKeys[ip[0]] = key
		}

	}

	conf = c

	//init existing schedules
	if err = initCron(); err != nil {
		return err
	}

	return nil
}
示例#2
0
文件: main.go 项目: sethjback/gobl
// Init configures the manager
func Init(c *config.Config) error {

	keyManager = &keys.Manager{PublicKeys: make(map[string]*rsa.PublicKey)}
	key, err := keys.OpenPrivateKey(c.Host.PrivateKeyPath)
	if err != nil {
		return err
	}

	keyManager.PrivateKey = key

	cKey, err := keys.OpenPublicKey(c.Coordinator.PublicKeyPath)
	if err != nil {
		return err
	}

	keyManager.PublicKeys[c.Coordinator.Address] = cKey

	conf = c

	return nil
}