| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | package configimport (	"errors")type ConfigObjectCreator func(data []byte) (interface{}, error)var (	configCache map[string]ConfigObjectCreator)func getConfigKey(protocol string, proxyType string) string {	return protocol + "_" + proxyType}func registerConfigType(protocol string, proxyType string, creator ConfigObjectCreator) error {	// TODO: check name	configCache[getConfigKey(protocol, proxyType)] = creator	return nil}func RegisterInboundConfig(protocol string, creator ConfigObjectCreator) error {	return registerConfigType(protocol, "inbound", creator)}func RegisterOutboundConfig(protocol string, creator ConfigObjectCreator) error {	return registerConfigType(protocol, "outbound", creator)}func CreateInboundConfig(protocol string, data []byte) (interface{}, error) {	creator, found := configCache[getConfigKey(protocol, "inbound")]	if !found {		return nil, errors.New(protocol + " not found.")	}	return creator(data)}func CreateOutboundConfig(protocol string, data []byte) (interface{}, error) {	creator, found := configCache[getConfigKey(protocol, "outbound")]	if !found {		return nil, errors.New(protocol + " not found.")	}	return creator(data)}func initializeConfigCache() {	configCache = make(map[string]ConfigObjectCreator)}func init() {	initializeConfigCache()}
 |