Esempio n. 1
0
// Initialize sets up the application's configuration directory.
func Initialize() error {
	path := filepath.Join(config.DataDir(), "mud.db")

	var err error
	db, err = bolt.Open(path, 0644, nil)
	if err != nil {
		return fmt.Errorf("Error opening database file %q: %s", path, err)
	}
	return nil
}
Esempio n. 2
0
// Initialize loads the gender configuration file from the data directory.
func Initialize() error {
	filename := filepath.Join(config.DataDir(), "gender.toml")

	f, err := os.Open(filename)
	if err != nil {
		return fmt.Errorf("Error reading gender config file: %s", err)
	}
	defer f.Close()
	names, err = decode(f)
	if err != nil {
		return err
	}
	log.Printf("Loaded gender config from %q", filename)
	return nil
}
Esempio n. 3
0
func loadLocTempl() error {
	path := filepath.Join(config.DataDir(), "location.template")
	log.Printf("Loading location template from %s", path)

	b, err := ioutil.ReadFile(path)
	if err != nil {
		return fmt.Errorf("error reading location template file: %s", err)
	}

	locTemplate, err = template.New("location.template").Parse(preprocess(b))
	if err != nil {
		return fmt.Errorf("can't parse location template: %s", err)
	}
	return nil
}
Esempio n. 4
0
// Initialize creates the emoteTemplate map and loads emotes into it.
func Initialize() error {
	filename := filepath.Join(config.DataDir(), templFile)

	f, err := os.Open(filename)
	if err != nil {
		return fmt.Errorf("Error reading emote config file: %s", err)
	}
	defer f.Close()
	em, err := decodeEmotes(f)
	if err != nil {
		return err
	}

	if err := loadEmotes(em); err != nil {
		return err
	}

	log.Printf("Loaded emotes: %v", Names)
	return nil
}
Esempio n. 5
0
func Initialize() error {
	filename := filepath.Join(config.DataDir(), "auth.toml")

	cfg := struct {
		BcryptCost int
	}{}

	res, err := toml.DecodeFile(filename, &cfg)
	if err != nil {
		return fmt.Errorf("Error parsing auth config file %q: %s", filename, err)
	}

	bcryptCost = cfg.BcryptCost

	log.Printf("Auth config loaded.  Using bcrypt cost %d", bcryptCost)

	if und := res.Undecoded(); len(und) > 0 {
		log.Printf("WARNING: Unknown values in auth config file: %v", und)
	}

	fakehash, err = bcrypt.GenerateFromPassword([]byte("password"), bcryptCost)
	return err
}