Exemplo n.º 1
0
func handle_config(cfg *string) {
	config, err := mini.LoadConfiguration(*cfg)
	if err != nil {
		log.Panicf("Failed to load config file %s %s", *config, err.Error())
	}

	blocklistBuckets = config.StringsFromSection("blocklist", "buckets")
	blockBuckets = config.StringsFromSection("block", "buckets")

	aws_key = config.StringFromSection("certs", "key", "")
	aws_sec = config.StringFromSection("certs", "secret", "")

	pool_size = int(config.IntegerFromSection("general", "pool-size", 2))

	host = config.StringFromSection("general", "host", "")
	port = int(config.IntegerFromSection("general", "port", 8598))

	num_expeditions = int(config.IntegerFromSection("general", "expedition-parties", 2))

	regions = config.StringsFromSection("region-mappings", "regions")

	if len(blocklistBuckets) == 0 {
		log.Panicf("No buckets found config file for blocklists, must have at least one\n")
	}

	if len(blockBuckets) == 0 {
		log.Panicf("No buckets found config file for blocks, must have at least one\n")
	}

	if aws_key == "" || aws_sec == "" {
		log.Panicf("Invalid certs, one or more of your keys was empty\n")
	}
}
Exemplo n.º 2
0
func LoadConfig() error {
	var configFile, err = mini.LoadConfiguration("settings.ini")
	if err != nil {
		return err
	}
	ServerConfig.Port = configFile.String("Port", "1234")
	ServerConfig.Port = configFile.String("Debug", "false")
	ServerConfig.SendGridAPI = configFile.String("SendGridAPI", "")
	return nil
}
Exemplo n.º 3
0
func main() {

	var err error

	cfg, err = mini.LoadConfiguration(cfgPath)
	if err != nil {
		syslog.Fatalf("Failed to open configuration file %s!\n", cfgPath)
	}

	dbConnectionAddress = cfg.String("DbConnectionAddress", "localhost:6379")

	log.NewLogger(
		cfg.Integer("LogLevel", 0),
		cfg.String("LogPath", "MoC-pulse-backend.log"))
	defer log.CloseLog()
	defer log.Info.Printf("MoC-pulse-backend server app stopped.\n")
	log.Info.Printf("MoC-pulse-backend server app starting...\n")
	log.Debug.Printf("MoC-pulse-backend server app initialization: start\n")

	log.Debug.Printf("Initializing notification sender...\n")
	notificationSender = notification.NewSender(
		cfg.String("GoogleApiKey", ""),
		cfg.String("AppleCertPath", "pushcert.pem"),
		cfg.String("AppleKeyPath", "pushkey.pem"),
		cfg.String("AppleServer", "gateway.push.apple.com:2195"),
		cfg.String("MandrillKey", ""),
		cfg.String("MandrillTemplate", "vote"),
		cfg.String("MandrillFromEmail", "*****@*****.**"),
		cfg.String("MandrillFromName", "MoC Pulse"),
		cfg.String("MandrillSubject", "New Voting"))

	log.Debug.Printf("Initializing httprouter...\n")
	router := httprouter.New()
	router.GET("/votes", getVotes)
	router.POST("/votes", createVote)
	router.GET("/votes/:id", getVote)
	router.PUT("/votes/:id", doVote)
	router.GET("/vote", emailVote)
	router.POST("/user", registerUser)
	router.POST("/test_ios_notification", testIOSNotificationSending)
	router.POST("/test_android_notification", testAndroidNotificationSending)

	log.Debug.Printf("MoC-pulse-backend server app initialization: end\n")

	routerPort := cfg.Integer("HttpRouterPort", 3001)
	log.Debug.Printf("Starting httprouter on port %d as goroutine...\n", routerPort)
	go http.ListenAndServe(":"+strconv.FormatInt(routerPort, 10), router)

	tcpsocketPort := cfg.Integer("TcpSocketPort", 4242)
	log.Debug.Printf("Starting tcpsocket server on port %d...\n", tcpsocketPort)
	tcpsocket.ListenAndServer(":"+strconv.FormatInt(tcpsocketPort, 10), notificationSender, dbConnectionAddress)
}
Exemplo n.º 4
0
func LoadConf(confFile string) error {
	c, err := mini.LoadConfiguration(confFile)
	if err != nil {
		return err
	}

	DatabaseDriver = c.String("database_driver", "")
	DatabaseURL = c.String("database_url", "")
	LogDir = c.String("log_dir", "./log/")
	LogFile = c.String("log_file", "readhacker")
	LogLevel = c.String("log_level", "info")
	HttpServerHost = c.String("http_server_host", "127.0.0.1")
	HttpServerPort = c.Integer("http_server_port", 8000)

	return nil
}
Exemplo n.º 5
0
// Handles parsing the config file passed in from the commandline
func handleConfig(configFilename *string) (*FilesystemConfig, error) {
	cfg, err := mini.LoadConfiguration(*configFilename)
	if err != nil {
		log.Error(err.Error())
		log.Fatalf("Failed to parse the config file %s", *configFilename)
	}

	// Get the backend from the config file and panic if no backend is specified
	backendName := cfg.String("backend", "")
	if backendName == "" {
		log.Fatalf("Must specify a \"backend\" in the config file")
	}

	// Get the logging level from the config file and default to info if an invalid value is given.
	ll := cfg.String("log-level", "info")
	log.Infof("Setting log level to %s", ll)
	logLevel, err := log.ParseLevel(ll)
	if err != nil {
		log.Warnf("Invalid log level %s; defaulting to info", ll)
		logLevel = log.InfoLevel
	}

	// Get all the specific driver configuration from the config and populate the appropriate driver config,
	// that's based on the backend name.
	var backendConfig *backend.Config
	switch backendName {
	case "neo":
		backendConfig = &backend.Config{
			"name":     "neo",
			"user":     cfg.StringFromSection(backendName, "user", ""),
			"password": cfg.StringFromSection(backendName, "password", ""),
			"host":     cfg.StringFromSection(backendName, "host", ""),
			"port":     cfg.IntegerFromSection(backendName, "port", 7474),
		}
	case "ddb":
		backendConfig = &backend.Config{
		// where ddb config options would go
		}
	}

	fcfg := &FilesystemConfig{
		BackendConfig: backendConfig,
		LogLevel:      logLevel,
	}

	return fcfg, nil
}
Exemplo n.º 6
0
func LoadConfig() error {
	var err error
	cfg, err = mini.LoadConfiguration(cfgPath)
	if err != nil {
		return err
	}

	stringOptions[STR_DB_USER] = cfg.String("DBUserName", "root")
	stringOptions[STR_DB_PASS] = cfg.String("DBUserPass", "")
	stringOptions[STR_DB_HOST] = cfg.String("DBHost", "127.0.0.1")
	stringOptions[STR_DB_PORT] = cfg.String("DBPort", "3306")
	stringOptions[STR_DB_NAME] = cfg.String("DBName", "lunch")

	stringOptions[STR_KEYS_PATH] = cfg.String("KeysPath", "")

	return nil
}
Exemplo n.º 7
0
func main() {
	cfg, _ = mini.LoadConfiguration(".hghconfigrc")

	notificationSender = notification.NewSender(
		cfg.String("GoogleApiKey", ""),
		cfg.String("AppleCertPath", "cert.pem"),
		cfg.String("AppleKeyPath", "key-noenc.pem"),
		cfg.String("AppleServer", "gateway.sandbox.push.apple.com:2195"),
		cfg.String("MandrillKey", ""),
		cfg.String("MandrillTemplate", "vote"),
		cfg.String("MandrillFromEmail", "*****@*****.**"),
		cfg.String("MandrillFromName", "MoC Pulse"),
		cfg.String("MandrillSubject", "New Voting"))

	go committracker.Serve(notificationSender)

	httpserver.ListenAndServe(":3002")
}
Exemplo n.º 8
0
func LoadConfig() error {
	//read config
	configFile, err := mini.LoadConfiguration("settings.ini")
	if err != nil {
		return err
	}
	ConfigStruct.ProxyListFilepath = configFile.String("proxy_list_path", "proxies.txt")
	ConfigStruct.TargetID = int(configFile.Integer("target_id", 80397))
	ConfigStruct.WorkerCount = int(configFile.Integer("worker_count", 20))
	ConfigStruct.DBCUsername = configFile.String("deathbycaptcha_username", "username")
	ConfigStruct.DBCPassword = configFile.String("deathbycaptcha_password", "password")
	ConfigStruct.ProxyType = configFile.String("proxy_type", "http")
	ConfigStruct.Timeout = int(configFile.Integer("timeout", 20))

	Target = "http://topofgames.com/index.php?do=votes&id=" + strconv.Itoa(ConfigStruct.TargetID)
	return nil

}