"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/config/server.go" between
frp-0.36.1.tar.gz and frp-0.36.2.tar.gz

About: frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. As of now, it supports TCP and UDP, as well as HTTP and HTTPS protocols, and it also has a P2P connect mode.

server.go  (frp-0.36.1):server.go  (frp-0.36.2)
skipping to change at line 32 skipping to change at line 32
plugin "github.com/fatedier/frp/pkg/plugin/server" plugin "github.com/fatedier/frp/pkg/plugin/server"
"github.com/fatedier/frp/pkg/util/util" "github.com/fatedier/frp/pkg/util/util"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
) )
// ServerCommonConf contains information for a server service. It is // ServerCommonConf contains information for a server service. It is
// recommended to use GetDefaultServerConf instead of creating this object // recommended to use GetDefaultServerConf instead of creating this object
// directly, so that all unspecified fields have reasonable default values. // directly, so that all unspecified fields have reasonable default values.
type ServerCommonConf struct { type ServerCommonConf struct {
auth.ServerConfig `ini:",extends" json:"inline"` auth.ServerConfig `ini:",extends"`
// BindAddr specifies the address that the server binds to. By default, // BindAddr specifies the address that the server binds to. By default,
// this value is "0.0.0.0". // this value is "0.0.0.0".
BindAddr string `ini:"bind_addr" json:"bind_addr"` BindAddr string `ini:"bind_addr" json:"bind_addr"`
// BindPort specifies the port that the server listens on. By default, th is // BindPort specifies the port that the server listens on. By default, th is
// value is 7000. // value is 7000.
BindPort int `ini:"bind_port" json:"bind_port"` BindPort int `ini:"bind_port" json:"bind_port"`
// BindUDPPort specifies the UDP port that the server listens on. If this // BindUDPPort specifies the UDP port that the server listens on. If this
// value is 0, the server will not listen for UDP connections. By default , // value is 0, the server will not listen for UDP connections. By default ,
// this value is 0 // this value is 0
BindUDPPort int `ini:"bind_udp_port" json:"bind_udp_port"` BindUDPPort int `ini:"bind_udp_port" json:"bind_udp_port"`
// KCPBindPort specifies the KCP port that the server listens on. If this // KCPBindPort specifies the KCP port that the server listens on. If this
// value is 0, the server will not listen for KCP connections. By default , // value is 0, the server will not listen for KCP connections. By default ,
// this value is 0. // this value is 0.
KCPBindPort int `ini:"kcp_bind_port" json:"kcp_bind_port"` KCPBindPort int `ini:"kcp_bind_port" json:"kcp_bind_port"`
// ProxyBindAddr specifies the address that the proxy binds to. This valu e // ProxyBindAddr specifies the address that the proxy binds to. This valu e
// may be the same as BindAddr. By default, this value is "0.0.0.0". // may be the same as BindAddr.
ProxyBindAddr string `ini:"proxy_bind_addr" json:"proxy_bind_addr"` ProxyBindAddr string `ini:"proxy_bind_addr" json:"proxy_bind_addr"`
// VhostHTTPPort specifies the port that the server listens for HTTP Vhos t // VhostHTTPPort specifies the port that the server listens for HTTP Vhos t
// requests. If this value is 0, the server will not listen for HTTP // requests. If this value is 0, the server will not listen for HTTP
// requests. By default, this value is 0. // requests. By default, this value is 0.
VhostHTTPPort int `ini:"vhost_http_port" json:"vhost_http_port"` VhostHTTPPort int `ini:"vhost_http_port" json:"vhost_http_port"`
// VhostHTTPSPort specifies the port that the server listens for HTTPS // VhostHTTPSPort specifies the port that the server listens for HTTPS
// Vhost requests. If this value is 0, the server will not listen for HTT PS // Vhost requests. If this value is 0, the server will not listen for HTT PS
// requests. By default, this value is 0. // requests. By default, this value is 0.
VhostHTTPSPort int `ini:"vhost_https_port" json:"vhost_https_port"` VhostHTTPSPort int `ini:"vhost_https_port" json:"vhost_https_port"`
// TCPMuxHTTPConnectPort specifies the port that the server listens for T CP // TCPMuxHTTPConnectPort specifies the port that the server listens for T CP
skipping to change at line 177 skipping to change at line 177
// GetDefaultServerConf returns a server configuration with reasonable // GetDefaultServerConf returns a server configuration with reasonable
// defaults. // defaults.
func GetDefaultServerConf() ServerCommonConf { func GetDefaultServerConf() ServerCommonConf {
return ServerCommonConf{ return ServerCommonConf{
ServerConfig: auth.GetDefaultServerConf(), ServerConfig: auth.GetDefaultServerConf(),
BindAddr: "0.0.0.0", BindAddr: "0.0.0.0",
BindPort: 7000, BindPort: 7000,
BindUDPPort: 0, BindUDPPort: 0,
KCPBindPort: 0, KCPBindPort: 0,
ProxyBindAddr: "0.0.0.0", ProxyBindAddr: "",
VhostHTTPPort: 0, VhostHTTPPort: 0,
VhostHTTPSPort: 0, VhostHTTPSPort: 0,
TCPMuxHTTPConnectPort: 0, TCPMuxHTTPConnectPort: 0,
VhostHTTPTimeout: 60, VhostHTTPTimeout: 60,
DashboardAddr: "0.0.0.0", DashboardAddr: "0.0.0.0",
DashboardPort: 0, DashboardPort: 0,
DashboardUser: "admin", DashboardUser: "admin",
DashboardPwd: "admin", DashboardPwd: "admin",
EnablePrometheus: false, EnablePrometheus: false,
AssetsDir: "", AssetsDir: "",
skipping to change at line 211 skipping to change at line 211
TLSKeyFile: "", TLSKeyFile: "",
TLSTrustedCaFile: "", TLSTrustedCaFile: "",
HeartbeatTimeout: 90, HeartbeatTimeout: 90,
UserConnTimeout: 10, UserConnTimeout: 10,
Custom404Page: "", Custom404Page: "",
HTTPPlugins: make(map[string]plugin.HTTPPluginOptions) , HTTPPlugins: make(map[string]plugin.HTTPPluginOptions) ,
UDPPacketSize: 1500, UDPPacketSize: 1500,
} }
} }
func (cfg *ServerCommonConf) Check() error {
return nil
}
func UnmarshalServerConfFromIni(source interface{}) (ServerCommonConf, error) { func UnmarshalServerConfFromIni(source interface{}) (ServerCommonConf, error) {
f, err := ini.LoadSources(ini.LoadOptions{ f, err := ini.LoadSources(ini.LoadOptions{
Insensitive: false, Insensitive: false,
InsensitiveSections: false, InsensitiveSections: false,
InsensitiveKeys: false, InsensitiveKeys: false,
IgnoreInlineComment: true, IgnoreInlineComment: true,
AllowBooleanKeys: true, AllowBooleanKeys: true,
}, source) }, source)
if err != nil { if err != nil {
skipping to change at line 245 skipping to change at line 241
err = s.MapTo(&common) err = s.MapTo(&common)
if err != nil { if err != nil {
return ServerCommonConf{}, err return ServerCommonConf{}, err
} }
// allow_ports // allow_ports
allowPortStr := s.Key("allow_ports").String() allowPortStr := s.Key("allow_ports").String()
if allowPortStr != "" { if allowPortStr != "" {
allowPorts, err := util.ParseRangeNumbers(allowPortStr) allowPorts, err := util.ParseRangeNumbers(allowPortStr)
if err != nil { if err != nil {
return ServerCommonConf{}, fmt.Errorf("Parse conf error: allow_ports: %v", err) return ServerCommonConf{}, fmt.Errorf("invalid allow_port s: %v", err)
} }
for _, port := range allowPorts { for _, port := range allowPorts {
common.AllowPorts[int(port)] = struct{}{} common.AllowPorts[int(port)] = struct{}{}
} }
} }
// plugin.xxx // plugin.xxx
pluginOpts := make(map[string]plugin.HTTPPluginOptions) pluginOpts := make(map[string]plugin.HTTPPluginOptions)
for _, section := range f.Sections() { for _, section := range f.Sections() {
name := section.Name() name := section.Name()
skipping to change at line 272 skipping to change at line 268
return ServerCommonConf{}, err return ServerCommonConf{}, err
} }
pluginOpts[opt.Name] = *opt pluginOpts[opt.Name] = *opt
} }
common.HTTPPlugins = pluginOpts common.HTTPPlugins = pluginOpts
return common, nil return common, nil
} }
func (cfg *ServerCommonConf) Complete() {
if cfg.LogFile == "console" {
cfg.LogWay = "console"
} else {
cfg.LogWay = "file"
}
if cfg.ProxyBindAddr == "" {
cfg.ProxyBindAddr = cfg.BindAddr
}
if cfg.TLSTrustedCaFile != "" {
cfg.TLSOnly = true
}
}
func (cfg *ServerCommonConf) Validate() error {
return nil
}
func loadHTTPPluginOpt(section *ini.Section) (*plugin.HTTPPluginOptions, error) { func loadHTTPPluginOpt(section *ini.Section) (*plugin.HTTPPluginOptions, error) {
name := strings.TrimSpace(strings.TrimPrefix(section.Name(), "plugin.")) name := strings.TrimSpace(strings.TrimPrefix(section.Name(), "plugin."))
opt := new(plugin.HTTPPluginOptions) opt := new(plugin.HTTPPluginOptions)
err := section.MapTo(opt) err := section.MapTo(opt)
if err != nil { if err != nil {
return nil, err return nil, err
} }
opt.Name = name opt.Name = name
 End of changes. 6 change blocks. 
8 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)