fix build failed problem after merge
This commit is contained in:
parent
7b5d6913f9
commit
05e71a13f2
@ -117,7 +117,7 @@ func NewProxyStatusResp(status *proxy.WorkingStatus, serverAddr string) ProxySta
|
|||||||
switch cfg := status.Cfg.(type) {
|
switch cfg := status.Cfg.(type) {
|
||||||
case *config.TCPProxyConf:
|
case *config.TCPProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
psr.Plugin = cfg.Plugin
|
psr.Plugin = cfg.Plugin
|
||||||
if status.Err != "" {
|
if status.Err != "" {
|
||||||
@ -127,7 +127,7 @@ func NewProxyStatusResp(status *proxy.WorkingStatus, serverAddr string) ProxySta
|
|||||||
}
|
}
|
||||||
case *config.UDPProxyConf:
|
case *config.UDPProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
if status.Err != "" {
|
if status.Err != "" {
|
||||||
psr.RemoteAddr = newAddress(serverAddr, cfg.RemotePort)
|
psr.RemoteAddr = newAddress(serverAddr, cfg.RemotePort)
|
||||||
@ -136,29 +136,29 @@ func NewProxyStatusResp(status *proxy.WorkingStatus, serverAddr string) ProxySta
|
|||||||
}
|
}
|
||||||
case *config.HTTPProxyConf:
|
case *config.HTTPProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
psr.Plugin = cfg.Plugin
|
psr.Plugin = cfg.Plugin
|
||||||
psr.RemoteAddr = status.RemoteAddr
|
psr.RemoteAddr = status.RemoteAddr
|
||||||
case *config.HTTPSProxyConf:
|
case *config.HTTPSProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
psr.Plugin = cfg.Plugin
|
psr.Plugin = cfg.Plugin
|
||||||
psr.RemoteAddr = status.RemoteAddr
|
psr.RemoteAddr = status.RemoteAddr
|
||||||
case *config.STCPProxyConf:
|
case *config.STCPProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
psr.Plugin = cfg.Plugin
|
psr.Plugin = cfg.Plugin
|
||||||
case *config.XTCPProxyConf:
|
case *config.XTCPProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
psr.Plugin = cfg.Plugin
|
psr.Plugin = cfg.Plugin
|
||||||
case *config.SUDPProxyConf:
|
case *config.SUDPProxyConf:
|
||||||
if cfg.LocalPort != 0 {
|
if cfg.LocalPort != 0 {
|
||||||
psr.LocalAddr = newAddress(cfg.LocalIp, cfg.LocalPort)
|
psr.LocalAddr = newAddress(cfg.LocalIP, cfg.LocalPort)
|
||||||
}
|
}
|
||||||
psr.Plugin = cfg.Plugin
|
psr.Plugin = cfg.Plugin
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ package client
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"github.com/fatedier/frp/utils/log"
|
"github.com/fatedier/frp/pkg/util/log"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
@ -17,7 +17,7 @@ package frp
|
|||||||
import (
|
import (
|
||||||
"github.com/fatedier/frp/cmd/frpc/sub"
|
"github.com/fatedier/frp/cmd/frpc/sub"
|
||||||
"github.com/fatedier/frp/cmd/frps/frps"
|
"github.com/fatedier/frp/cmd/frps/frps"
|
||||||
"github.com/fatedier/frp/utils/version"
|
"github.com/fatedier/frp/pkg/util/version"
|
||||||
"github.com/fatedier/golib/crypto"
|
"github.com/fatedier/golib/crypto"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package frp
|
package frp
|
||||||
|
|
||||||
import "github.com/fatedier/frp/utils/log"
|
import "github.com/fatedier/frp/pkg/util/log"
|
||||||
|
|
||||||
type FrpLogListener interface {
|
type FrpLogListener interface {
|
||||||
Log(log string)
|
Log(log string)
|
||||||
|
@ -310,8 +310,8 @@ func startService(
|
|||||||
|
|
||||||
func returnService(cfg config.ClientCommonConf, pxyCfgs map[string]config.ProxyConf, visitorCfgs map[string]config.VisitorConf, cfgFile string) (svr *client.Service, err error) {
|
func returnService(cfg config.ClientCommonConf, pxyCfgs map[string]config.ProxyConf, visitorCfgs map[string]config.VisitorConf, cfgFile string) (svr *client.Service, err error) {
|
||||||
log.InitLog(cfg.LogWay, cfg.LogFile, cfg.LogLevel, cfg.LogMaxDays, cfg.DisableLogColor)
|
log.InitLog(cfg.LogWay, cfg.LogFile, cfg.LogLevel, cfg.LogMaxDays, cfg.DisableLogColor)
|
||||||
if cfg.DnsServer != "" {
|
if cfg.DNSServer != "" {
|
||||||
s := cfg.DnsServer
|
s := cfg.DNSServer
|
||||||
if !strings.Contains(s, ":") {
|
if !strings.Contains(s, ":") {
|
||||||
s += ":53"
|
s += ":53"
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,12 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/fatedier/frp/models/config"
|
"github.com/fatedier/frp/pkg/auth"
|
||||||
|
"github.com/fatedier/frp/pkg/config"
|
||||||
|
"github.com/fatedier/frp/pkg/util/log"
|
||||||
|
"github.com/fatedier/frp/pkg/util/util"
|
||||||
|
"github.com/fatedier/frp/pkg/util/version"
|
||||||
"github.com/fatedier/frp/server"
|
"github.com/fatedier/frp/server"
|
||||||
"github.com/fatedier/frp/utils/log"
|
|
||||||
"github.com/fatedier/frp/utils/util"
|
|
||||||
"github.com/fatedier/frp/utils/version"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -38,12 +39,12 @@ var (
|
|||||||
|
|
||||||
bindAddr string
|
bindAddr string
|
||||||
bindPort int
|
bindPort int
|
||||||
bindUdpPort int
|
bindUDPPort int
|
||||||
kcpBindPort int
|
kcpBindPort int
|
||||||
proxyBindAddr string
|
proxyBindAddr string
|
||||||
vhostHttpPort int
|
vhostHTTPPort int
|
||||||
vhostHttpsPort int
|
vhostHTTPSPort int
|
||||||
vhostHttpTimeout int64
|
vhostHTTPTimeout int64
|
||||||
dashboardAddr string
|
dashboardAddr string
|
||||||
dashboardPort int
|
dashboardPort int
|
||||||
dashboardUser string
|
dashboardUser string
|
||||||
@ -59,20 +60,21 @@ var (
|
|||||||
allowPorts string
|
allowPorts string
|
||||||
maxPoolCount int64
|
maxPoolCount int64
|
||||||
maxPortsPerClient int64
|
maxPortsPerClient int64
|
||||||
|
tlsOnly bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file of frps")
|
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file of frps")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frpc")
|
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frps")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "0.0.0.0", "bind address")
|
rootCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "0.0.0.0", "bind address")
|
||||||
rootCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "p", 7000, "bind port")
|
rootCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "p", 7000, "bind port")
|
||||||
rootCmd.PersistentFlags().IntVarP(&bindUdpPort, "bind_udp_port", "", 0, "bind udp port")
|
rootCmd.PersistentFlags().IntVarP(&bindUDPPort, "bind_udp_port", "", 0, "bind udp port")
|
||||||
rootCmd.PersistentFlags().IntVarP(&kcpBindPort, "kcp_bind_port", "", 0, "kcp bind udp port")
|
rootCmd.PersistentFlags().IntVarP(&kcpBindPort, "kcp_bind_port", "", 0, "kcp bind udp port")
|
||||||
rootCmd.PersistentFlags().StringVarP(&proxyBindAddr, "proxy_bind_addr", "", "0.0.0.0", "proxy bind address")
|
rootCmd.PersistentFlags().StringVarP(&proxyBindAddr, "proxy_bind_addr", "", "0.0.0.0", "proxy bind address")
|
||||||
rootCmd.PersistentFlags().IntVarP(&vhostHttpPort, "vhost_http_port", "", 0, "vhost http port")
|
rootCmd.PersistentFlags().IntVarP(&vhostHTTPPort, "vhost_http_port", "", 0, "vhost http port")
|
||||||
rootCmd.PersistentFlags().IntVarP(&vhostHttpsPort, "vhost_https_port", "", 0, "vhost https port")
|
rootCmd.PersistentFlags().IntVarP(&vhostHTTPSPort, "vhost_https_port", "", 0, "vhost https port")
|
||||||
rootCmd.PersistentFlags().Int64VarP(&vhostHttpTimeout, "vhost_http_timeout", "", 60, "vhost http response header timeout")
|
rootCmd.PersistentFlags().Int64VarP(&vhostHTTPTimeout, "vhost_http_timeout", "", 60, "vhost http response header timeout")
|
||||||
rootCmd.PersistentFlags().StringVarP(&dashboardAddr, "dashboard_addr", "", "0.0.0.0", "dasboard address")
|
rootCmd.PersistentFlags().StringVarP(&dashboardAddr, "dashboard_addr", "", "0.0.0.0", "dasboard address")
|
||||||
rootCmd.PersistentFlags().IntVarP(&dashboardPort, "dashboard_port", "", 0, "dashboard port")
|
rootCmd.PersistentFlags().IntVarP(&dashboardPort, "dashboard_port", "", 0, "dashboard port")
|
||||||
rootCmd.PersistentFlags().StringVarP(&dashboardUser, "dashboard_user", "", "admin", "dashboard user")
|
rootCmd.PersistentFlags().StringVarP(&dashboardUser, "dashboard_user", "", "admin", "dashboard user")
|
||||||
@ -86,6 +88,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&subDomainHost, "subdomain_host", "", "", "subdomain host")
|
rootCmd.PersistentFlags().StringVarP(&subDomainHost, "subdomain_host", "", "", "subdomain host")
|
||||||
rootCmd.PersistentFlags().StringVarP(&allowPorts, "allow_ports", "", "", "allow ports")
|
rootCmd.PersistentFlags().StringVarP(&allowPorts, "allow_ports", "", "", "allow ports")
|
||||||
rootCmd.PersistentFlags().Int64VarP(&maxPortsPerClient, "max_ports_per_client", "", 0, "max ports per client")
|
rootCmd.PersistentFlags().Int64VarP(&maxPortsPerClient, "max_ports_per_client", "", 0, "max ports per client")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&tlsOnly, "tls_only", "", false, "frps tls only")
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
@ -158,12 +161,12 @@ func parseServerCommonCfgFromCmd() (cfg config.ServerCommonConf, err error) {
|
|||||||
|
|
||||||
cfg.BindAddr = bindAddr
|
cfg.BindAddr = bindAddr
|
||||||
cfg.BindPort = bindPort
|
cfg.BindPort = bindPort
|
||||||
cfg.BindUdpPort = bindUdpPort
|
cfg.BindUDPPort = bindUDPPort
|
||||||
cfg.KcpBindPort = kcpBindPort
|
cfg.KCPBindPort = kcpBindPort
|
||||||
cfg.ProxyBindAddr = proxyBindAddr
|
cfg.ProxyBindAddr = proxyBindAddr
|
||||||
cfg.VhostHttpPort = vhostHttpPort
|
cfg.VhostHTTPPort = vhostHTTPPort
|
||||||
cfg.VhostHttpsPort = vhostHttpsPort
|
cfg.VhostHTTPSPort = vhostHTTPSPort
|
||||||
cfg.VhostHttpTimeout = vhostHttpTimeout
|
cfg.VhostHTTPTimeout = vhostHTTPTimeout
|
||||||
cfg.DashboardAddr = dashboardAddr
|
cfg.DashboardAddr = dashboardAddr
|
||||||
cfg.DashboardPort = dashboardPort
|
cfg.DashboardPort = dashboardPort
|
||||||
cfg.DashboardUser = dashboardUser
|
cfg.DashboardUser = dashboardUser
|
||||||
@ -171,8 +174,12 @@ func parseServerCommonCfgFromCmd() (cfg config.ServerCommonConf, err error) {
|
|||||||
cfg.LogFile = logFile
|
cfg.LogFile = logFile
|
||||||
cfg.LogLevel = logLevel
|
cfg.LogLevel = logLevel
|
||||||
cfg.LogMaxDays = logMaxDays
|
cfg.LogMaxDays = logMaxDays
|
||||||
cfg.Token = token
|
|
||||||
cfg.SubDomainHost = subDomainHost
|
cfg.SubDomainHost = subDomainHost
|
||||||
|
cfg.TLSOnly = tlsOnly
|
||||||
|
|
||||||
|
// Only token authentication is supported in cmd mode
|
||||||
|
cfg.ServerConfig = auth.GetDefaultServerConf()
|
||||||
|
cfg.Token = token
|
||||||
if len(allowPorts) > 0 {
|
if len(allowPorts) > 0 {
|
||||||
// e.g. 1000-2000,2001,2002,3000-4000
|
// e.g. 1000-2000,2001,2002,3000-4000
|
||||||
ports, errRet := util.ParseRangeNumbers(allowPorts)
|
ports, errRet := util.ParseRangeNumbers(allowPorts)
|
||||||
@ -202,11 +209,12 @@ func runServer(cfg config.ServerCommonConf) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Info("Start frps success")
|
log.Info("start frps success")
|
||||||
svr.Run()
|
svr.Run()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var service *server.Service
|
var service *server.Service
|
||||||
|
|
||||||
func RunFrps(cfgFile string) error {
|
func RunFrps(cfgFile string) error {
|
||||||
@ -232,7 +240,6 @@ func RunFrps(cfgFile string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = runBackgroundServer(cfg)
|
err = runBackgroundServer(cfg)
|
||||||
fmt.Println(err)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/fatedier/frp/cmd/frpc/sub"
|
"github.com/fatedier/frp/cmd/frpc/sub"
|
||||||
"github.com/fatedier/frp/cmd/frps/frps"
|
"github.com/fatedier/frp/cmd/frps/frps"
|
||||||
"github.com/fatedier/frp/utils/version"
|
"github.com/fatedier/frp/pkg/util/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
//export StopFrpc
|
//export StopFrpc
|
||||||
|
@ -28,7 +28,7 @@ import "C"
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/fatedier/frp/utils/log"
|
"github.com/fatedier/frp/pkg/util/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var l logForMacListener
|
var l logForMacListener
|
||||||
|
@ -201,6 +201,6 @@ FOR:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop Stop
|
// Stop Stop
|
||||||
func (pm *PortManager) Stop() {
|
func (pm *Manager) Stop() {
|
||||||
pm.stop <- true
|
pm.stop <- true
|
||||||
}
|
}
|
||||||
|
@ -353,8 +353,8 @@ func (svr *Service) Stop() error {
|
|||||||
}
|
}
|
||||||
close(svr.closedCh)
|
close(svr.closedCh)
|
||||||
svr.Closed = true
|
svr.Closed = true
|
||||||
svr.rc.TcpPortManager.Stop()
|
svr.rc.TCPPortManager.Stop()
|
||||||
svr.rc.UdpPortManager.Stop()
|
svr.rc.UDPPortManager.Stop()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user