<commit_before>package conf

import (
	"errors"

	"v2ray.com/core/common/loader"
	"v2ray.com/core/transport/internet/authenticators/http"
	"v2ray.com/core/transport/internet/authenticators/noop"
	"v2ray.com/core/transport/internet/authenticators/srtp"
	"v2ray.com/core/transport/internet/authenticators/utp"
)

type NoOpAuthenticator struct{}

func (NoOpAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(noop.Config)), nil
}

type NoOpConnectionAuthenticator struct{}

func (NoOpConnectionAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(noop.Config)), nil
}

type SRTPAuthenticator struct{}

func (SRTPAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(srtp.Config)), nil
}

type UTPAuthenticator struct{}

func (UTPAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(utp.Config)), nil
}

type HTTPAuthenticatorRequest struct {
	Version *string                `json:"version"`
	Method  *string                `json:"method"`
	Path    *StringList            `json:"path"`
	Headers map[string]*StringList `json:"headers"`
}

func (this *HTTPAuthenticatorRequest) Build() (*http.RequestConfig, error) {
	config := &http.RequestConfig{
		Uri: []string{"/"},
		Header: []*http.Header{
			{
				Name:  "Host",
				Value: []string{"www.baidu.com", "www.bing.com"},
			},
		},
	}

	if this.Version != nil {
		config.Version = &http.Version{Value: *this.Version}
	}

	if this.Method != nil {
		config.Method = &http.Method{Value: *this.Method}
	}

	if this.Path != nil && this.Path.Len() > 0 {
		config.Uri = append([]string(nil), (*this.Path)...)
	}

	if len(this.Headers) > 0 {
		config.Header = make([]*http.Header, 0, len(this.Headers))
		for key, value := range this.Headers {
			config.Header = append(config.Header, &http.Header{
				Name:  key,
				Value: append([]string(nil), (*value)...),
			})
		}
	}

	return config, nil
}

type HTTPAuthenticatorResponse struct {
	Version *string                `json:"version"`
	Status  *string                `json:"status"`
	Reason  *string                `json:"reason"`
	Headers map[string]*StringList `json:"headers"`
}

func (this *HTTPAuthenticatorResponse) Build() (*http.ResponseConfig, error) {
	config := &http.ResponseConfig{
		Header: []*http.Header{
			{
				Name:  "Content-Type",
				Value: []string{"application/octet-stream", "video/mpeg"},
			},
			{
				Name:  "Transfer-Encoding",
				Value: []string{"chunked"},
			},
		},
	}

	if this.Version != nil {
		config.Version = &http.Version{Value: *this.Version}
	}

	if this.Status != nil || this.Reason != nil {
		config.Status = &http.Status{
			Code:   "200",
			Reason: "OK",
		}
		if this.Status != nil {
			config.Status.Code = *this.Status
		}
		if this.Reason != nil {
			config.Status.Reason = *this.Reason
		}
	}

	if len(this.Headers) > 0 {
		config.Header = make([]*http.Header, 0, len(this.Headers))
		for key, value := range this.Headers {
			config.Header = append(config.Header, &http.Header{
				Name:  key,
				Value: append([]string(nil), (*value)...),
			})
		}
	}

	return config, nil
}

type HTTPAuthenticator struct {
	Request  *HTTPAuthenticatorRequest  `json:"request"`
	Response *HTTPAuthenticatorResponse `json:"response"`
}

func (this *HTTPAuthenticator) Build() (*loader.TypedSettings, error) {
	config := new(http.Config)
	if this.Request == nil {
		return nil, errors.New("HTTP request settings not set.")
	}
	requestConfig, err := this.Request.Build()
	if err != nil {
		return nil, err
	}
	config.Request = requestConfig

	if this.Response != nil {
		responseConfig, err := this.Response.Build()
		if err != nil {
			return nil, err
		}
		config.Response = responseConfig
	}

	return loader.NewTypedSettings(config), nil
}
<commit_msg>default user agent strings<commit_after>package conf

import (
	"errors"

	"v2ray.com/core/common/loader"
	"v2ray.com/core/transport/internet/authenticators/http"
	"v2ray.com/core/transport/internet/authenticators/noop"
	"v2ray.com/core/transport/internet/authenticators/srtp"
	"v2ray.com/core/transport/internet/authenticators/utp"
)

type NoOpAuthenticator struct{}

func (NoOpAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(noop.Config)), nil
}

type NoOpConnectionAuthenticator struct{}

func (NoOpConnectionAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(noop.Config)), nil
}

type SRTPAuthenticator struct{}

func (SRTPAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(srtp.Config)), nil
}

type UTPAuthenticator struct{}

func (UTPAuthenticator) Build() (*loader.TypedSettings, error) {
	return loader.NewTypedSettings(new(utp.Config)), nil
}

type HTTPAuthenticatorRequest struct {
	Version *string                `json:"version"`
	Method  *string                `json:"method"`
	Path    *StringList            `json:"path"`
	Headers map[string]*StringList `json:"headers"`
}

func (this *HTTPAuthenticatorRequest) Build() (*http.RequestConfig, error) {
	config := &http.RequestConfig{
		Uri: []string{"/"},
		Header: []*http.Header{
			{
				Name:  "Host",
				Value: []string{"www.baidu.com", "www.bing.com"},
			},
			{
				Name: "User-Agent",
				Value: []string{
					"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
					"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46",
				},
			},
		},
	}

	if this.Version != nil {
		config.Version = &http.Version{Value: *this.Version}
	}

	if this.Method != nil {
		config.Method = &http.Method{Value: *this.Method}
	}

	if this.Path != nil && this.Path.Len() > 0 {
		config.Uri = append([]string(nil), (*this.Path)...)
	}

	if len(this.Headers) > 0 {
		config.Header = make([]*http.Header, 0, len(this.Headers))
		for key, value := range this.Headers {
			config.Header = append(config.Header, &http.Header{
				Name:  key,
				Value: append([]string(nil), (*value)...),
			})
		}
	}

	return config, nil
}

type HTTPAuthenticatorResponse struct {
	Version *string                `json:"version"`
	Status  *string                `json:"status"`
	Reason  *string                `json:"reason"`
	Headers map[string]*StringList `json:"headers"`
}

func (this *HTTPAuthenticatorResponse) Build() (*http.ResponseConfig, error) {
	config := &http.ResponseConfig{
		Header: []*http.Header{
			{
				Name:  "Content-Type",
				Value: []string{"application/octet-stream", "video/mpeg"},
			},
			{
				Name:  "Transfer-Encoding",
				Value: []string{"chunked"},
			},
		},
	}

	if this.Version != nil {
		config.Version = &http.Version{Value: *this.Version}
	}

	if this.Status != nil || this.Reason != nil {
		config.Status = &http.Status{
			Code:   "200",
			Reason: "OK",
		}
		if this.Status != nil {
			config.Status.Code = *this.Status
		}
		if this.Reason != nil {
			config.Status.Reason = *this.Reason
		}
	}

	if len(this.Headers) > 0 {
		config.Header = make([]*http.Header, 0, len(this.Headers))
		for key, value := range this.Headers {
			config.Header = append(config.Header, &http.Header{
				Name:  key,
				Value: append([]string(nil), (*value)...),
			})
		}
	}

	return config, nil
}

type HTTPAuthenticator struct {
	Request  *HTTPAuthenticatorRequest  `json:"request"`
	Response *HTTPAuthenticatorResponse `json:"response"`
}

func (this *HTTPAuthenticator) Build() (*loader.TypedSettings, error) {
	config := new(http.Config)
	if this.Request == nil {
		return nil, errors.New("HTTP request settings not set.")
	}
	requestConfig, err := this.Request.Build()
	if err != nil {
		return nil, err
	}
	config.Request = requestConfig

	if this.Response != nil {
		responseConfig, err := this.Response.Build()
		if err != nil {
			return nil, err
		}
		config.Response = responseConfig
	}

	return loader.NewTypedSettings(config), nil
}

{'fraction_non_alphanumeric': 0.15670898680607417, 'fraction_numerical': 0.010455563853622106, 'mean_word_length': 3.7015798712697485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7472407', 'n_tokens_mistral': 2997, 'n_tokens_neox': 2756, 'n_words': 569}