mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
frps: new parameter 'proxy_bind_addr'
This commit is contained in:
parent
c081df40e1
commit
f63a4f0cdd
@ -9,6 +9,9 @@ bind_port = 7000
|
|||||||
# if not set, kcp is disabled in frps
|
# if not set, kcp is disabled in frps
|
||||||
kcp_bind_port = 7000
|
kcp_bind_port = 7000
|
||||||
|
|
||||||
|
# specify which address proxy will listen for, default value is same with bind_addr
|
||||||
|
# proxy_bind_addr = 127.0.0.1
|
||||||
|
|
||||||
# if you want to support virtual host, you must set the http port for listening (optional)
|
# if you want to support virtual host, you must set the http port for listening (optional)
|
||||||
vhost_http_port = 80
|
vhost_http_port = 80
|
||||||
vhost_https_port = 443
|
vhost_https_port = 443
|
||||||
|
@ -31,6 +31,7 @@ type ServerCommonConf struct {
|
|||||||
BindAddr string
|
BindAddr string
|
||||||
BindPort int64
|
BindPort int64
|
||||||
KcpBindPort int64
|
KcpBindPort int64
|
||||||
|
ProxyBindAddr string
|
||||||
|
|
||||||
// If VhostHttpPort equals 0, don't listen a public port for http protocol.
|
// If VhostHttpPort equals 0, don't listen a public port for http protocol.
|
||||||
VhostHttpPort int64
|
VhostHttpPort int64
|
||||||
@ -66,6 +67,7 @@ func GetDefaultServerCommonConf() *ServerCommonConf {
|
|||||||
BindAddr: "0.0.0.0",
|
BindAddr: "0.0.0.0",
|
||||||
BindPort: 7000,
|
BindPort: 7000,
|
||||||
KcpBindPort: 0,
|
KcpBindPort: 0,
|
||||||
|
ProxyBindAddr: "0.0.0.0",
|
||||||
VhostHttpPort: 0,
|
VhostHttpPort: 0,
|
||||||
VhostHttpsPort: 0,
|
VhostHttpsPort: 0,
|
||||||
DashboardPort: 0,
|
DashboardPort: 0,
|
||||||
@ -117,6 +119,13 @@ func LoadServerCommonConf(conf ini.File) (cfg *ServerCommonConf, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmpStr, ok = conf.Get("common", "proxy_bind_addr")
|
||||||
|
if ok {
|
||||||
|
cfg.ProxyBindAddr = tmpStr
|
||||||
|
} else {
|
||||||
|
cfg.ProxyBindAddr = cfg.BindAddr
|
||||||
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "vhost_http_port")
|
tmpStr, ok = conf.Get("common", "vhost_http_port")
|
||||||
if ok {
|
if ok {
|
||||||
cfg.VhostHttpPort, err = strconv.ParseInt(tmpStr, 10, 64)
|
cfg.VhostHttpPort, err = strconv.ParseInt(tmpStr, 10, 64)
|
||||||
|
@ -161,7 +161,7 @@ type TcpProxy struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pxy *TcpProxy) Run() error {
|
func (pxy *TcpProxy) Run() error {
|
||||||
listener, err := frpNet.ListenTcp(config.ServerCommonCfg.BindAddr, pxy.cfg.RemotePort)
|
listener, err := frpNet.ListenTcp(config.ServerCommonCfg.ProxyBindAddr, pxy.cfg.RemotePort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ type UdpProxy struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pxy *UdpProxy) Run() (err error) {
|
func (pxy *UdpProxy) Run() (err error) {
|
||||||
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", config.ServerCommonCfg.BindAddr, pxy.cfg.RemotePort))
|
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", config.ServerCommonCfg.ProxyBindAddr, pxy.cfg.RemotePort))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func NewService() (svr *Service, err error) {
|
|||||||
// Create http vhost muxer.
|
// Create http vhost muxer.
|
||||||
if config.ServerCommonCfg.VhostHttpPort > 0 {
|
if config.ServerCommonCfg.VhostHttpPort > 0 {
|
||||||
var l frpNet.Listener
|
var l frpNet.Listener
|
||||||
l, err = frpNet.ListenTcp(config.ServerCommonCfg.BindAddr, config.ServerCommonCfg.VhostHttpPort)
|
l, err = frpNet.ListenTcp(config.ServerCommonCfg.ProxyBindAddr, config.ServerCommonCfg.VhostHttpPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Create vhost http listener error, %v", err)
|
err = fmt.Errorf("Create vhost http listener error, %v", err)
|
||||||
return
|
return
|
||||||
@ -105,13 +105,13 @@ func NewService() (svr *Service, err error) {
|
|||||||
err = fmt.Errorf("Create vhost httpMuxer error, %v", err)
|
err = fmt.Errorf("Create vhost httpMuxer error, %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("http service listen on %s:%d", config.ServerCommonCfg.BindAddr, config.ServerCommonCfg.VhostHttpPort)
|
log.Info("http service listen on %s:%d", config.ServerCommonCfg.ProxyBindAddr, config.ServerCommonCfg.VhostHttpPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create https vhost muxer.
|
// Create https vhost muxer.
|
||||||
if config.ServerCommonCfg.VhostHttpsPort > 0 {
|
if config.ServerCommonCfg.VhostHttpsPort > 0 {
|
||||||
var l frpNet.Listener
|
var l frpNet.Listener
|
||||||
l, err = frpNet.ListenTcp(config.ServerCommonCfg.BindAddr, config.ServerCommonCfg.VhostHttpsPort)
|
l, err = frpNet.ListenTcp(config.ServerCommonCfg.ProxyBindAddr, config.ServerCommonCfg.VhostHttpsPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Create vhost https listener error, %v", err)
|
err = fmt.Errorf("Create vhost https listener error, %v", err)
|
||||||
return
|
return
|
||||||
@ -121,7 +121,7 @@ func NewService() (svr *Service, err error) {
|
|||||||
err = fmt.Errorf("Create vhost httpsMuxer error, %v", err)
|
err = fmt.Errorf("Create vhost httpsMuxer error, %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("https service listen on %s:%d", config.ServerCommonCfg.BindAddr, config.ServerCommonCfg.VhostHttpsPort)
|
log.Info("https service listen on %s:%d", config.ServerCommonCfg.ProxyBindAddr, config.ServerCommonCfg.VhostHttpsPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create dashboard web server.
|
// Create dashboard web server.
|
||||||
|
Loading…
Reference in New Issue
Block a user