func (cfg *BaseProxyConf) decorate(prefix string, name string, section *ini.Section) error {
	cfg.ProxyName = prefix + name
	cfg.Metas = GetMapWithoutPrefix(section.KeysHash(), "meta_")
	if bandwidth, err := section.GetKey("bandwidth_limit"); err == nil {
		cfg.BandwidthLimit, err = NewBandwidthQuantity(bandwidth.String())
		if err != nil {
			return err
		}
	}
	cfg.LocalSvrConf.PluginParams = GetMapByPrefix(section.KeysHash(), "plugin_")
	if cfg.HealthCheckType == "tcp" && cfg.Plugin == "" {
		cfg.HealthCheckAddr = cfg.LocalIP + fmt.Sprintf(":%d", cfg.LocalPort)
	}
	if cfg.HealthCheckType == "http" && cfg.Plugin == "" && cfg.HealthCheckURL != "" {
		s := fmt.Sprintf("http://%s:%d", cfg.LocalIP, cfg.LocalPort)
		if !strings.HasPrefix(cfg.HealthCheckURL, "/") {
			s += "/"
		}
		cfg.HealthCheckURL = s + cfg.HealthCheckURL
	}
	return nil
}
BaseProxyConf apply custom logic changes.
package config
import (
	"fmt"
	"reflect"
	"strings"
	"github.com/fatedier/frp/pkg/consts"
	"github.com/fatedier/frp/pkg/msg"
	"gopkg.in/ini.v1"
)
var (
	proxyConfTypeMap = map[string]reflect.Type{
		consts.TCPProxy:    reflect.TypeOf(TCPProxyConf{}),
		consts.TCPMuxProxy: reflect.TypeOf(TCPMuxProxyConf{}),
		consts.UDPProxy:    reflect.TypeOf(UDPProxyConf{}),
		consts.HTTPProxy:   reflect.TypeOf(HTTPProxyConf{}),
		consts.HTTPSProxy:  reflect.TypeOf(HTTPSProxyConf{}),
		consts.STCPProxy:   reflect.TypeOf(STCPProxyConf{}),
		consts.XTCPProxy:   reflect.TypeOf(XTCPProxyConf{}),
		consts.SUDPProxy:   reflect.TypeOf(SUDPProxyConf{}),
	}
)
func NewConfByType(proxyType string) ProxyConf {
	v, ok := proxyConfTypeMap[proxyType]
	if !ok {
		return nil
	}
	cfg := reflect.New(v).Interface().(ProxyConf)
	return cfg
}
type ProxyConf interface {
	GetBaseInfo() *BaseProxyConf
	UnmarshalFromMsg(*msg.NewProxy)
	UnmarshalFromIni(string, string, *ini.Section) error
	MarshalToMsg(*msg.NewProxy)
	CheckForCli() error
	CheckForSvr(ServerCommonConf) error
	Compare(ProxyConf) bool
}
type LocalSvrConf struct {
	LocalIP string `ini:"local_ip" json:"local_ip"`
	LocalPort int `ini:"local_port" json:"local_port"`
	Plugin string `ini:"plugin" json:"plugin"`
	PluginParams map[string]string `ini:"-"`
}
type HealthCheckConf struct {
	HealthCheckType string `ini:"health_check_type" json:"health_check_type"`  
	HealthCheckTimeoutS int `ini:"health_check_timeout_s" json:"health_check_timeout_s"`
	HealthCheckMaxFailed int `ini:"health_check_max_failed" json:"health_check_max_failed"`
	HealthCheckIntervalS int `ini:"health_check_interval_s" json:"health_check_interval_s"`
	HealthCheckURL string `ini:"health_check_url" json:"health_check_url"`
	HealthCheckAddr string `ini:"-"`
}
type BaseProxyConf struct {
	ProxyName string `ini:"name" json:"name"`
	ProxyType string `ini:"type" json:"type"`
	UseEncryption bool `ini:"use_encryption" json:"use_encryption"`
	UseCompression bool `ini:"use_compression" json:"use_compression"`
	Group string `ini:"group" json:"group"`
	GroupKey string `ini:"group_key" json:"group_key"`
	ProxyProtocolVersion string `ini:"proxy_protocol_version" json:"proxy_protocol_version"`
	BandwidthLimit BandwidthQuantity `ini:"bandwidth_limit" json:"bandwidth_limit"`
	Metas map[string]string `ini:"-" json:"metas"`
	LocalSvrConf    `ini:",extends"`
	HealthCheckConf `ini:",extends"`
}
type DomainConf struct {
	CustomDomains []string `ini:"custom_domains" json:"custom_domains"`
	SubDomain     string   `ini:"subdomain" json:"subdomain"`
}
type HTTPProxyConf struct {
	BaseProxyConf `ini:",extends"`
	DomainConf    `ini:",extends"`
	Locations         []string          `ini:"locations" json:"locations"`
	HTTPUser          string            `ini:"http_user" json:"http_user"`
	HTTPPwd           string            `ini:"http_pwd" json:"http_pwd"`
	HostHeaderRewrite string            `ini:"host_header_rewrite" json:"host_header_rewrite"`
	Headers           map[string]string `ini:"-" json:"headers"`
}
type HTTPSProxyConf struct {
	BaseProxyConf `ini:",extends"`
	DomainConf    `ini:",extends"`
}
type TCPProxyConf struct {
	BaseProxyConf `ini:",extends"`
	RemotePort    int `ini:"remote_port" json:"remote_port"`
}
type TCPMuxProxyConf struct {
	BaseProxyConf `ini:",extends"`
	DomainConf    `ini:",extends"`
	Multiplexer string `ini:"multiplexer"`
}
type STCPProxyConf struct {
	BaseProxyConf `ini:",extends"`
	Role string `ini:"role" json:"role"`
	Sk   string `ini:"sk" json:"sk"`
}
type XTCPProxyConf struct {
	BaseProxyConf `ini:",extends"`
	Role string `ini:"role" json:"role"`
	Sk   string `ini:"sk" json:"sk"`
}
type UDPProxyConf struct {
	BaseProxyConf `ini:",extends"`
	RemotePort int `ini:"remote_port" json:"remote_port"`
}
type SUDPProxyConf struct {
	BaseProxyConf `ini:",extends"`
	Role string `ini:"role" json:"role"`
	Sk   string `ini:"sk" json:"sk"`
}
func DefaultProxyConf(proxyType string) ProxyConf {
	var conf ProxyConf
	switch proxyType {
	case consts.TCPProxy:
		conf = &TCPProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
		}
	case consts.TCPMuxProxy:
		conf = &TCPMuxProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
		}
	case consts.UDPProxy:
		conf = &UDPProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
		}
	case consts.HTTPProxy:
		conf = &HTTPProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
		}
	case consts.HTTPSProxy:
		conf = &HTTPSProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
		}
	case consts.STCPProxy:
		conf = &STCPProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
			Role:          "server",
		}
	case consts.XTCPProxy:
		conf = &XTCPProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
			Role:          "server",
		}
	case consts.SUDPProxy:
		conf = &SUDPProxyConf{
			BaseProxyConf: defaultBaseProxyConf(proxyType),
			Role:          "server",
		}
	default:
		return nil
	}
	return conf
}
func NewProxyConfFromIni(prefix, name string, section *ini.Section) (ProxyConf, error) {
	proxyType := section.Key("type").String()
	if proxyType == "" {
		proxyType = consts.TCPProxy
	}
	conf := DefaultProxyConf(proxyType)
	if conf == nil {
		return nil, fmt.Errorf("proxy %s has invalid type [%s]", name, proxyType)
	}
	if err := conf.UnmarshalFromIni(prefix, name, section); err != nil {
		return nil, err
	}
	if err := conf.CheckForCli(); err != nil {
		return nil, err
	}
	return conf, nil
}
func NewProxyConfFromMsg(pMsg *msg.NewProxy, serverCfg ServerCommonConf) (ProxyConf, error) {
	if pMsg.ProxyType == "" {
		pMsg.ProxyType = consts.TCPProxy
	}
	conf := DefaultProxyConf(pMsg.ProxyType)
	if conf == nil {
		return nil, fmt.Errorf("proxy [%s] type [%s] error", pMsg.ProxyName, pMsg.ProxyType)
	}
	conf.UnmarshalFromMsg(pMsg)
	err := conf.CheckForSvr(serverCfg)
	if err != nil {
		return nil, err
	}
	return conf, nil
}
func defaultBaseProxyConf(proxyType string) BaseProxyConf {
	return BaseProxyConf{
		ProxyType: proxyType,
		LocalSvrConf: LocalSvrConf{
			LocalIP: "127.0.0.1",
		},
	}
}
func (cfg *BaseProxyConf) GetBaseInfo() *BaseProxyConf {
	return cfg
}
func (cfg *BaseProxyConf) compare(cmp *BaseProxyConf) bool {
	if cfg.ProxyName != cmp.ProxyName ||
		cfg.ProxyType != cmp.ProxyType ||
		cfg.UseEncryption != cmp.UseEncryption ||
		cfg.UseCompression != cmp.UseCompression ||
		cfg.Group != cmp.Group ||
		cfg.GroupKey != cmp.GroupKey ||
		cfg.ProxyProtocolVersion != cmp.ProxyProtocolVersion ||
		!cfg.BandwidthLimit.Equal(&cmp.BandwidthLimit) ||
		!reflect.DeepEqual(cfg.Metas, cmp.Metas) {
		return false
	}
	if !reflect.DeepEqual(cfg.LocalSvrConf, cmp.LocalSvrConf) {
		return false
	}
	if !reflect.DeepEqual(cfg.HealthCheckConf, cmp.HealthCheckConf) {
		return false
	}
	return true
}