<commit_before>package protocol

import (
	"fmt"
	"net/http"
	"time"

	"github.com/mefellows/muxy/log"
	"github.com/mefellows/muxy/muxy"
	"github.com/mefellows/pkigo/pki"
	"github.com/mefellows/plugo/plugo"
)

// HTTPProxy implements the proxy interface for the HTTP protocol
// nolint
type HTTPProxy struct {
	Port          int    `required:"true"`
	Host          string `required:"true" default:"localhost"`
	Protocol      string `default:"http" required:"true"`
	ProxyHost     string `required:"true" mapstructure:"proxy_host"`
	ProxyPort     int    `required:"true" mapstructure:"proxy_port"`
	ProxyProtocol string `required:"true" default:"http" mapstructure:"proxy_protocol"`
	middleware    []muxy.Middleware
}

func init() {
	plugo.PluginFactories.Register(func() (interface{}, error) {
		return &HTTPProxy{}, nil
	}, "http_proxy")
}

// Setup sets up the middleware
func (p *HTTPProxy) Setup(middleware []muxy.Middleware) {
	p.middleware = middleware
}

// Teardown shuts down the middleware
func (p *HTTPProxy) Teardown() {
}

// Proxy performs the proxy event
func (p *HTTPProxy) Proxy() {
	log.Info("HTTP proxy listening on %s", log.Colorize(log.BLUE, fmt.Sprintf("%s://%s:%d", p.Protocol, p.Host, p.Port)))
	pkiMgr, err := pki.New()
	checkHTTPServerError(err)
	config, err := pkiMgr.GetClientTLSConfig()
	checkHTTPServerError(err)
	config.InsecureSkipVerify = false

	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {<commit_msg>feat(ssl): allow invalid / untrusted ssl certs on proxy targets #7<commit_after>package protocol

import (
	"fmt"
	"net/http"
	"time"

	"github.com/mefellows/muxy/log"
	"github.com/mefellows/muxy/muxy"
	"github.com/mefellows/pkigo/pki"
	"github.com/mefellows/plugo/plugo"
)

// HTTPProxy implements the proxy interface for the HTTP protocol
// nolint
type HTTPProxy struct {
	Port          int    `required:"true"`
	Host          string `required:"true" default:"localhost"`
	Protocol      string `default:"http" required:"true"`
	ProxyHost     string `required:"true" mapstructure:"proxy_host"`
	ProxyPort     int    `required:"true" mapstructure:"proxy_port"`
	ProxyProtocol string `required:"true" default:"http" mapstructure:"proxy_protocol"`
	Insecure      bool   `required:"true" default:"false" mapstructure:"insecure"`
	middleware    []muxy.Middleware
}

func init() {
	plugo.PluginFactories.Register(func() (interface{}, error) {
		return &HTTPProxy{}, nil
	}, "http_proxy")
}

// Setup sets up the middleware
func (p *HTTPProxy) Setup(middleware []muxy.Middleware) {
	p.middleware = middleware
}

// Teardown shuts down the middleware
func (p *HTTPProxy) Teardown() {
}

// Proxy performs the proxy event
func (p *HTTPProxy) Proxy() {
	log.Info("HTTP proxy listening on %s", log.Colorize(log.BLUE, fmt.Sprintf("%s://%s:%d", p.Protocol, p.Host, p.Port)))
	pkiMgr, err := pki.New()
	checkHTTPServerError(err)
	config, err := pkiMgr.GetClientTLSConfig()
	checkHTTPServerError(err)
	config.InsecureSkipVerify = p.Insecure

	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
{'fraction_non_alphanumeric': 0.14317889317889318, 'fraction_numerical': 0.00032175032175032174, 'mean_word_length': 4.652727272727272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7413862', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1065, 'n_words': 244}