Merge pull request #1069 from fatedier/vet

go vet & golint
This commit is contained in:
fatedier 2019-01-31 16:59:03 +08:00 committed by GitHub
commit 1de8c3fc87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 34 additions and 31 deletions

View File

@ -53,32 +53,32 @@ func NewProxy(pxyConf config.ProxyConf) (pxy Proxy) {
switch cfg := pxyConf.(type) { switch cfg := pxyConf.(type) {
case *config.TcpProxyConf: case *config.TcpProxyConf:
pxy = &TcpProxy{ pxy = &TcpProxy{
BaseProxy: baseProxy, BaseProxy: &baseProxy,
cfg: cfg, cfg: cfg,
} }
case *config.UdpProxyConf: case *config.UdpProxyConf:
pxy = &UdpProxy{ pxy = &UdpProxy{
BaseProxy: baseProxy, BaseProxy: &baseProxy,
cfg: cfg, cfg: cfg,
} }
case *config.HttpProxyConf: case *config.HttpProxyConf:
pxy = &HttpProxy{ pxy = &HttpProxy{
BaseProxy: baseProxy, BaseProxy: &baseProxy,
cfg: cfg, cfg: cfg,
} }
case *config.HttpsProxyConf: case *config.HttpsProxyConf:
pxy = &HttpsProxy{ pxy = &HttpsProxy{
BaseProxy: baseProxy, BaseProxy: &baseProxy,
cfg: cfg, cfg: cfg,
} }
case *config.StcpProxyConf: case *config.StcpProxyConf:
pxy = &StcpProxy{ pxy = &StcpProxy{
BaseProxy: baseProxy, BaseProxy: &baseProxy,
cfg: cfg, cfg: cfg,
} }
case *config.XtcpProxyConf: case *config.XtcpProxyConf:
pxy = &XtcpProxy{ pxy = &XtcpProxy{
BaseProxy: baseProxy, BaseProxy: &baseProxy,
cfg: cfg, cfg: cfg,
} }
} }
@ -93,7 +93,7 @@ type BaseProxy struct {
// TCP // TCP
type TcpProxy struct { type TcpProxy struct {
BaseProxy *BaseProxy
cfg *config.TcpProxyConf cfg *config.TcpProxyConf
proxyPlugin plugin.Plugin proxyPlugin plugin.Plugin
@ -122,7 +122,7 @@ func (pxy *TcpProxy) InWorkConn(conn frpNet.Conn) {
// HTTP // HTTP
type HttpProxy struct { type HttpProxy struct {
BaseProxy *BaseProxy
cfg *config.HttpProxyConf cfg *config.HttpProxyConf
proxyPlugin plugin.Plugin proxyPlugin plugin.Plugin
@ -151,7 +151,7 @@ func (pxy *HttpProxy) InWorkConn(conn frpNet.Conn) {
// HTTPS // HTTPS
type HttpsProxy struct { type HttpsProxy struct {
BaseProxy *BaseProxy
cfg *config.HttpsProxyConf cfg *config.HttpsProxyConf
proxyPlugin plugin.Plugin proxyPlugin plugin.Plugin
@ -180,7 +180,7 @@ func (pxy *HttpsProxy) InWorkConn(conn frpNet.Conn) {
// STCP // STCP
type StcpProxy struct { type StcpProxy struct {
BaseProxy *BaseProxy
cfg *config.StcpProxyConf cfg *config.StcpProxyConf
proxyPlugin plugin.Plugin proxyPlugin plugin.Plugin
@ -209,7 +209,7 @@ func (pxy *StcpProxy) InWorkConn(conn frpNet.Conn) {
// XTCP // XTCP
type XtcpProxy struct { type XtcpProxy struct {
BaseProxy *BaseProxy
cfg *config.XtcpProxyConf cfg *config.XtcpProxyConf
proxyPlugin plugin.Plugin proxyPlugin plugin.Plugin
@ -308,7 +308,7 @@ func (pxy *XtcpProxy) InWorkConn(conn frpNet.Conn) {
// UDP // UDP
type UdpProxy struct { type UdpProxy struct {
BaseProxy *BaseProxy
cfg *config.UdpProxyConf cfg *config.UdpProxyConf

View File

@ -52,12 +52,12 @@ func NewVisitor(ctl *Control, cfg config.VisitorConf) (visitor Visitor) {
switch cfg := cfg.(type) { switch cfg := cfg.(type) {
case *config.StcpVisitorConf: case *config.StcpVisitorConf:
visitor = &StcpVisitor{ visitor = &StcpVisitor{
BaseVisitor: baseVisitor, BaseVisitor: &baseVisitor,
cfg: cfg, cfg: cfg,
} }
case *config.XtcpVisitorConf: case *config.XtcpVisitorConf:
visitor = &XtcpVisitor{ visitor = &XtcpVisitor{
BaseVisitor: baseVisitor, BaseVisitor: &baseVisitor,
cfg: cfg, cfg: cfg,
} }
} }
@ -73,7 +73,7 @@ type BaseVisitor struct {
} }
type StcpVisitor struct { type StcpVisitor struct {
BaseVisitor *BaseVisitor
cfg *config.StcpVisitorConf cfg *config.StcpVisitorConf
} }
@ -160,7 +160,7 @@ func (sv *StcpVisitor) handleConn(userConn frpNet.Conn) {
} }
type XtcpVisitor struct { type XtcpVisitor struct {
BaseVisitor *BaseVisitor
cfg *config.XtcpVisitorConf cfg *config.XtcpVisitorConf
} }

View File

@ -51,7 +51,7 @@ type ServerCommonConf struct {
VhostHttpPort int `json:"vhost_http_port"` VhostHttpPort int `json:"vhost_http_port"`
// if VhostHttpsPort equals 0, don't listen a public port for https protocol // if VhostHttpsPort equals 0, don't listen a public port for https protocol
VhostHttpsPort int `json:"vhost_http_port"` VhostHttpsPort int `json:"vhost_https_port"`
VhostHttpTimeout int64 `json:"vhost_http_timeout"` VhostHttpTimeout int64 `json:"vhost_http_timeout"`

View File

@ -67,7 +67,6 @@ func ForwardUserConn(udpConn *net.UDPConn, readCh <-chan *msg.UdpPacket, sendCh
default: default:
} }
} }
return
} }
func Forwarder(dstAddr *net.UDPAddr, readCh <-chan *msg.UdpPacket, sendCh chan<- msg.Message) { func Forwarder(dstAddr *net.UDPAddr, readCh <-chan *msg.UdpPacket, sendCh chan<- msg.Message) {

View File

@ -29,7 +29,7 @@ import (
) )
type HttpProxy struct { type HttpProxy struct {
BaseProxy *BaseProxy
cfg *config.HttpProxyConf cfg *config.HttpProxyConf
closeFuncs []func() closeFuncs []func()

View File

@ -24,7 +24,7 @@ import (
) )
type HttpsProxy struct { type HttpsProxy struct {
BaseProxy *BaseProxy
cfg *config.HttpsProxyConf cfg *config.HttpsProxyConf
} }

View File

@ -135,33 +135,33 @@ func NewProxy(runId string, rc *controller.ResourceController, statsCollector st
case *config.TcpProxyConf: case *config.TcpProxyConf:
basePxy.usedPortsNum = 1 basePxy.usedPortsNum = 1
pxy = &TcpProxy{ pxy = &TcpProxy{
BaseProxy: basePxy, BaseProxy: &basePxy,
cfg: cfg, cfg: cfg,
} }
case *config.HttpProxyConf: case *config.HttpProxyConf:
pxy = &HttpProxy{ pxy = &HttpProxy{
BaseProxy: basePxy, BaseProxy: &basePxy,
cfg: cfg, cfg: cfg,
} }
case *config.HttpsProxyConf: case *config.HttpsProxyConf:
pxy = &HttpsProxy{ pxy = &HttpsProxy{
BaseProxy: basePxy, BaseProxy: &basePxy,
cfg: cfg, cfg: cfg,
} }
case *config.UdpProxyConf: case *config.UdpProxyConf:
basePxy.usedPortsNum = 1 basePxy.usedPortsNum = 1
pxy = &UdpProxy{ pxy = &UdpProxy{
BaseProxy: basePxy, BaseProxy: &basePxy,
cfg: cfg, cfg: cfg,
} }
case *config.StcpProxyConf: case *config.StcpProxyConf:
pxy = &StcpProxy{ pxy = &StcpProxy{
BaseProxy: basePxy, BaseProxy: &basePxy,
cfg: cfg, cfg: cfg,
} }
case *config.XtcpProxyConf: case *config.XtcpProxyConf:
pxy = &XtcpProxy{ pxy = &XtcpProxy{
BaseProxy: basePxy, BaseProxy: &basePxy,
cfg: cfg, cfg: cfg,
} }
default: default:

View File

@ -19,7 +19,7 @@ import (
) )
type StcpProxy struct { type StcpProxy struct {
BaseProxy *BaseProxy
cfg *config.StcpProxyConf cfg *config.StcpProxyConf
} }

View File

@ -23,7 +23,7 @@ import (
) )
type TcpProxy struct { type TcpProxy struct {
BaseProxy *BaseProxy
cfg *config.TcpProxyConf cfg *config.TcpProxyConf
realPort int realPort int

View File

@ -30,7 +30,7 @@ import (
) )
type UdpProxy struct { type UdpProxy struct {
BaseProxy *BaseProxy
cfg *config.UdpProxyConf cfg *config.UdpProxyConf
realPort int realPort int

View File

@ -24,7 +24,7 @@ import (
) )
type XtcpProxy struct { type XtcpProxy struct {
BaseProxy *BaseProxy
cfg *config.XtcpProxyConf cfg *config.XtcpProxyConf
closeCh chan struct{} closeCh chan struct{}

View File

@ -20,6 +20,7 @@ import (
"github.com/fatedier/beego/logs" "github.com/fatedier/beego/logs"
) )
// Log is the under log object
var Log *logs.BeeLogger var Log *logs.BeeLogger
func init() { func init() {
@ -33,6 +34,7 @@ func InitLog(logWay string, logFile string, logLevel string, maxdays int64) {
SetLogLevel(logLevel) SetLogLevel(logLevel)
} }
// SetLogFile to configure log params
// logWay: file or console // logWay: file or console
func SetLogFile(logWay string, logFile string, maxdays int64) { func SetLogFile(logWay string, logFile string, maxdays int64) {
if logWay == "console" { if logWay == "console" {
@ -43,6 +45,7 @@ func SetLogFile(logWay string, logFile string, maxdays int64) {
} }
} }
// SetLogLevel set log level, default is warning
// value: error, warning, info, debug, trace // value: error, warning, info, debug, trace
func SetLogLevel(logLevel string) { func SetLogLevel(logLevel string) {
level := 4 // warning level := 4 // warning
@ -85,7 +88,7 @@ func Trace(format string, v ...interface{}) {
Log.Trace(format, v...) Log.Trace(format, v...)
} }
// Logger // Logger is the log interface
type Logger interface { type Logger interface {
AddLogPrefix(string) AddLogPrefix(string)
GetPrefixStr() string GetPrefixStr() string

View File

@ -31,6 +31,7 @@ type WebsocketListener struct {
httpMutex *http.ServeMux httpMutex *http.ServeMux
} }
// NewWebsocketListener to handle websocket connections
// ln: tcp listener for websocket connections // ln: tcp listener for websocket connections
func NewWebsocketListener(ln net.Listener) (wl *WebsocketListener) { func NewWebsocketListener(ln net.Listener) (wl *WebsocketListener) {
wl = &WebsocketListener{ wl = &WebsocketListener{