<commit_before>package main

import (
	"net/http"
	"flag"
	"encoding/json"
	"io/ioutil"
	"log"
	ph "github.com/advptr/reverse-proxy/proxyhandler"
	"crypto/x509"
)

// Main config
type Config struct {
	TrustFiles []string `json:"trust-files"`
	Routes []ph.Route `json:"routes""`
}


// Program  Options
type Options struct {
	ServerAddress string
	ConfigFile    string
}


// Main Bootstrap
func main() {
	args := args()
	config := config(args.ConfigFile)

	for _, r := range config.Routes {
		handler := ph.NewWSHandler(r, config.trustedCertPool())
		http.HandleFunc(handler.Path(), handler.Handle)
	}
	log.Printf("reverse-proxy on %v\n", args.ServerAddress)

	err := http.ListenAndServe(args.ServerAddress, nil)
	if err != nil {
		panic(err)
	}
}


// Parse command args
func args() Options {
	const (
		defaultServerAddress = ":80"
		serverAddressUsage   = "server address: ':80', '0.0.0.0:8080'..."
		defaultRouteConfig   = "config.json"
		routeConfigUsage     = "configuration file: 'config.json'"
	)
	address := flag.String("address", defaultServerAddress, serverAddressUsage)
	config := flag.String("config", defaultRouteConfig, routeConfigUsage)
	flag.Parse()<commit_msg>one cert pool is good enough.<commit_after>package main

import (
	"net/http"
	"flag"
	"encoding/json"
	"io/ioutil"
	"log"
	ph "github.com/advptr/reverse-proxy/proxyhandler"
	"crypto/x509"
)

// Main config
type Config struct {
	TrustFiles []string `json:"trust-files"`
	Routes []ph.Route `json:"routes""`
}


// Program  Options
type Options struct {
	ServerAddress string
	ConfigFile    string
}


// Main Bootstrap
func main() {
	args := args()
	config := config(args.ConfigFile)
	trustedCertPool := config.trustedCertPool()
	for _, r := range config.Routes {
		handler := ph.NewWSHandler(r, trustedCertPool)
		http.HandleFunc(handler.Path(), handler.Handle)
	}
	log.Printf("reverse-proxy on %v\n", args.ServerAddress)

	err := http.ListenAndServe(args.ServerAddress, nil)
	if err != nil {
		panic(err)
	}
}


// Parse command args
func args() Options {
	const (
		defaultServerAddress = ":80"
		serverAddressUsage   = "server address: ':80', '0.0.0.0:8080'..."
		defaultRouteConfig   = "config.json"
		routeConfigUsage     = "configuration file: 'config.json'"
	)
	address := flag.String("address", defaultServerAddress, serverAddressUsage)
	config := flag.String("config", defaultRouteConfig, routeConfigUsage)
	flag.Parse()
{'fraction_non_alphanumeric': 0.14582467802243457, 'fraction_numerical': 0.012463647694225177, 'mean_word_length': 4.3039647577092515, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5239538', 'n_tokens_mistral': 850, 'n_tokens_neox': 812, 'n_words': 182}