<commit_before>package utils

import (
	"io"
	"net"
	"net/http"
	"os"
	"strings"
)

func Proxy(ip string) error {
	_, err := os.Stat("/var/run/docker.sock")
	if err == nil {
		err = os.Remove("/var/run/docker.sock")
		if err != nil {
			return err
		}
	}

	listener, err := net.Listen("unix", "/var/run/docker.sock")
	if err != nil {
		return err
	}

	err = os.Chmod("/var/run/docker.sock", 0777)
	if err != nil {
		return err
	}

	handler := http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
		r.URL.Scheme = "http"
		r.URL.Host = ip+":2375"

		if len(r.Header["Upgrade"]) > 0 && strings.ToLower(r.Header["Upgrade"][0]) == "tcp" {<commit_msg>upgrade misbehaving requests from docker-compose, for #105<commit_after>package utils

import (
	"io"
	"net"
	"net/http"
	"os"
	"strings"
)

func Proxy(ip string) error {
	_, err := os.Stat("/var/run/docker.sock")
	if err == nil {
		err = os.Remove("/var/run/docker.sock")
		if err != nil {
			return err
		}
	}

	listener, err := net.Listen("unix", "/var/run/docker.sock")
	if err != nil {
		return err
	}

	err = os.Chmod("/var/run/docker.sock", 0777)
	if err != nil {
		return err
	}

	handler := http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
		r.URL.Scheme = "http"
		r.URL.Host = ip+":2375"

		upgrade := false
		if strings.HasSuffix(r.URL.Path, "/attach") {
			upgrade = true
		} else if len(r.Header["Upgrade"]) > 0 {
			upgrade_header := strings.ToLower(r.Header["Upgrade"][0])
			upgrade = upgrade_header == "tcp" || upgrade_header == "websocket"
		}

		if upgrade {
{'fraction_non_alphanumeric': 0.18556701030927836, 'fraction_numerical': 0.014819587628865979, 'mean_word_length': 3.2900552486187844, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '4499616', 'n_tokens_mistral': 673, 'n_tokens_neox': 605, 'n_words': 133}