|
|
@ -18,9 +18,11 @@ import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
|
|
|
|
"net" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
|
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/fatedier/frp/client/proxy" |
|
|
|
"github.com/fatedier/frp/client/proxy" |
|
|
@ -105,48 +107,48 @@ 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 = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(cfg.LocalPort)) |
|
|
|
} |
|
|
|
} |
|
|
|
psr.Plugin = cfg.Plugin |
|
|
|
psr.Plugin = cfg.Plugin |
|
|
|
if status.Err != "" { |
|
|
|
if status.Err != "" { |
|
|
|
psr.RemoteAddr = fmt.Sprintf("%s:%d", serverAddr, cfg.RemotePort) |
|
|
|
psr.RemoteAddr = net.JoinHostPort(serverAddr, strconv.Itoa(cfg.RemotePort)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
psr.RemoteAddr = serverAddr + status.RemoteAddr |
|
|
|
psr.RemoteAddr = serverAddr + status.RemoteAddr |
|
|
|
} |
|
|
|
} |
|
|
|
case *config.UDPProxyConf: |
|
|
|
case *config.UDPProxyConf: |
|
|
|
if cfg.LocalPort != 0 { |
|
|
|
if cfg.LocalPort != 0 { |
|
|
|
psr.LocalAddr = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(cfg.LocalPort)) |
|
|
|
} |
|
|
|
} |
|
|
|
if status.Err != "" { |
|
|
|
if status.Err != "" { |
|
|
|
psr.RemoteAddr = fmt.Sprintf("%s:%d", serverAddr, cfg.RemotePort) |
|
|
|
psr.RemoteAddr = net.JoinHostPort(serverAddr, strconv.Itoa(cfg.RemotePort)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
psr.RemoteAddr = serverAddr + status.RemoteAddr |
|
|
|
psr.RemoteAddr = serverAddr + status.RemoteAddr |
|
|
|
} |
|
|
|
} |
|
|
|
case *config.HTTPProxyConf: |
|
|
|
case *config.HTTPProxyConf: |
|
|
|
if cfg.LocalPort != 0 { |
|
|
|
if cfg.LocalPort != 0 { |
|
|
|
psr.LocalAddr = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(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 = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(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 = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(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 = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(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 = fmt.Sprintf("%s:%d", cfg.LocalIP, cfg.LocalPort) |
|
|
|
psr.LocalAddr = net.JoinHostPort(cfg.LocalIP, strconv.Itoa(cfg.LocalPort)) |
|
|
|
} |
|
|
|
} |
|
|
|
psr.Plugin = cfg.Plugin |
|
|
|
psr.Plugin = cfg.Plugin |
|
|
|
} |
|
|
|
} |
|
|
|