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
}
Proxy loaded from ini
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
}