<commit_before>package shadowsocks

import (
	"encoding/json"
	"errors"
	"io/ioutil"
)

var (
	defaultLocalAddr = "0.0.0.0:6009"
	defaultTimeout   = 300
	defaultMethod    = "aes-128-cfb"
	defaultPassword  = "<PASSWORD>"

	config = new(Config)
)

type Config struct {
	// local addr, default is ":6009"
	LocalAddr string `json:"local_addr"`
	// server addr, default is ":7008"
	ServerAddr string `json:"server_addr"`
	// password, default is "<PASSWORD>"
	Password string `json:"password"`
	// cipher method, default is "ase-128-cfb"
	Method string `json:"method"`
	// connection timeout, default is 300
	Timeout int `json:"timeout"`
}

func ParseConfig(configPath string) (*Config, error) {
	data, err := ioutil.ReadFile(configPath)
	if err != nil {
		return nil, err
	}
	if err := json.Unmarshal(data, config); err != nil {
		return nil, err
	}

	if config.ServerAddr == "" {
		return nil, errors.New("server addr can not be empty")
	}

	if config.LocalAddr == "" {
		config.LocalAddr = defaultLocalAddr
	}

	if config.Password == "" {
		config.Password = <PASSWORD>
	}

	if config.Timeout == 0 {
		config.Timeout = defaultTimeout
	}

	if config.Method == "" {
		config.Method = defaultMethod
	}

	return config, nil
}
<commit_msg>feat: change default behavior<commit_after>package shadowsocks

import (
	"encoding/json"
	"io/ioutil"
)

var (
	defaultServerAddr = "0.0.0.0:8089"
	defaultLocalAddr  = "0.0.0.0:6009"
	defaultTimeout    = 300
	defaultMethod     = "aes-128-cfb"
	defaultPassword   = "<PASSWORD>"

	config = new(Config)
)

type Config struct {
	// local addr, default is ":6009"
	LocalAddr string `json:"local_addr"`
	// server addr, default is ":7008"
	ServerAddr string `json:"server_addr"`
	// password, default is "<PASSWORD>"
	Password string `json:"password"`
	// cipher method, default is "ase-128-cfb"
	Method string `json:"method"`
	// connection timeout, default is 300
	Timeout int `json:"timeout"`
}

func ParseConfig(configPath string) (*Config, error) {
	data, err := ioutil.ReadFile(configPath)
	if err == nil {
		if err := json.Unmarshal(data, config); err != nil {
			return nil, err
		}
	}

	if config.ServerAddr == "" {
		config.ServerAddr = defaultServerAddr
	}

	if config.LocalAddr == "" {
		config.LocalAddr = defaultLocalAddr
	}

	if config.Password == "" {
		config.Password = <PASSWORD>
	}

	if config.Timeout == 0 {
		config.Timeout = defaultTimeout
	}

	if config.Method == "" {
		config.Method = defaultMethod
	}

	return config, nil
}

{'fraction_non_alphanumeric': 0.1400322841000807, 'fraction_numerical': 0.026634382566585957, 'mean_word_length': 3.7673076923076922, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '7091355', 'n_tokens_mistral': 913, 'n_tokens_neox': 840, 'n_words': 219}