<commit_before>// Copyright 2015 Reborndb Org. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.

package router

import (
	"strings"

	"github.com/reborndb/reborn/pkg/proxy/router/topology"
	"github.com/reborndb/reborn/pkg/utils"

	log "github.com/ngaut/logging"
)

type Conf struct {
	ProductName     string
	NetTimeout      int    //seconds
	Proto           string //tcp or tcp4
	CoordinatorAddr string
	Coordinator     string

	Addr     string
	HTTPAddr string
	ProxyID  string
	PidFile  string

	// for client <-> proxy
	ProxyPassword string

	// for proxy <-> server(redis/qdb)
	// if you want to use password, you must be sure that
	// all the backend servers have the same password
	ServerPassword string

	// unexport
	f topology.CoordFactory
}

func LoadConf(configFile string) (*Conf, error) {
	srvConf := &Conf{}
	conf, err := utils.InitConfigFromFile(configFile)
	if err != nil {
		log.Fatal(err)
	}

	srvConf.ProductName, _ = conf.ReadString("product", "test")
	if len(srvConf.ProductName) == 0 {
		log.Fatalf("invalid config: product entry is missing in %s", configFile)
	}
	srvConf.CoordinatorAddr, _ = conf.ReadString("coordinator_addr", "")
	if len(srvConf.CoordinatorAddr) == 0 {
		log.Fatalf("invalid config: need coordinator addr entry is missing in %s", configFile)
	}
	srvConf.CoordinatorAddr = strings.TrimSpace(srvConf.CoordinatorAddr)

	srvConf.NetTimeout, _ = conf.ReadInt("net_timeout", 5)
	srvConf.Proto, _ = conf.ReadString("proto", "tcp")
	srvConf.Coordinator, _ = conf.ReadString("coordinator", "zookeeper")

	srvConf.Addr, _ = conf.ReadString("addr", "")
	srvConf.HTTPAddr, _ = conf.ReadString("http_addr", "")
	srvConf.ProxyID, _ = conf.ReadString("proxy_id", "")
	srvConf.PidFile, _ = conf.ReadString("pidfile", "")

	srvConf.ProxyPassword, _ = conf.ReadString("proxy_pass", "")
	srvConf.ServerPassword, _ = conf.ReadString("server_pass", "")

	return srvConf, nil
}<commit_msg>config use auth instead of pass<commit_after>// Copyright 2015 Reborndb Org. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.

package router

import (
	"strings"

	"github.com/reborndb/reborn/pkg/proxy/router/topology"
	"github.com/reborndb/reborn/pkg/utils"

	log "github.com/ngaut/logging"
)

type Conf struct {
	ProductName     string
	NetTimeout      int    //seconds
	Proto           string //tcp or tcp4
	CoordinatorAddr string
	Coordinator     string

	Addr     string
	HTTPAddr string
	ProxyID  string
	PidFile  string

	// for client <-> proxy
	ProxyPassword string

	// for proxy <-> server(redis/qdb)
	// if you want to use password, you must be sure that
	// all the backend servers have the same password
	ServerPassword string

	// unexport
	f topology.CoordFactory
}

func LoadConf(configFile string) (*Conf, error) {
	srvConf := &Conf{}
	conf, err := utils.InitConfigFromFile(configFile)
	if err != nil {
		log.Fatal(err)
	}

	srvConf.ProductName, _ = conf.ReadString("product", "test")
	if len(srvConf.ProductName) == 0 {
		log.Fatalf("invalid config: product entry is missing in %s", configFile)
	}
	srvConf.CoordinatorAddr, _ = conf.ReadString("coordinator_addr", "")
	if len(srvConf.CoordinatorAddr) == 0 {
		log.Fatalf("invalid config: need coordinator addr entry is missing in %s", configFile)
	}
	srvConf.CoordinatorAddr = strings.TrimSpace(srvConf.CoordinatorAddr)

	srvConf.NetTimeout, _ = conf.ReadInt("net_timeout", 5)
	srvConf.Proto, _ = conf.ReadString("proto", "tcp")
	srvConf.Coordinator, _ = conf.ReadString("coordinator", "zookeeper")

	srvConf.Addr, _ = conf.ReadString("addr", "")
	srvConf.HTTPAddr, _ = conf.ReadString("http_addr", "")
	srvConf.ProxyID, _ = conf.ReadString("proxy_id", "")
	srvConf.PidFile, _ = conf.ReadString("pidfile", "")

	srvConf.ProxyPassword, _ = conf.ReadString("proxy_auth", "")
	srvConf.ServerPassword, _ = conf.ReadString("server_auth", "")

	return srvConf, nil
}
{'fraction_non_alphanumeric': 0.12744090441932168, 'fraction_numerical': 0.0041109969167523125, 'mean_word_length': 4.190666666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7527175', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1306, 'n_words': 305}