update group ci

This commit is contained in:
fatedier
2018-05-23 14:39:12 +08:00
parent f56b49ad3b
commit 495b577819
7 changed files with 124 additions and 21 deletions

25
server/group/group.go Normal file
View File

@@ -0,0 +1,25 @@
// Copyright 2018 fatedier, fatedier@gmail.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package group
import (
"errors"
)
var (
ErrGroupAuthFailed = errors.New("group auth failed")
ErrGroupParamsInvalid = errors.New("group params invalid")
ErrListenerClosed = errors.New("group listener closed")
)

View File

@@ -12,21 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package server
package group
import (
"errors"
"fmt"
"net"
"sync"
gerr "github.com/fatedier/golib/errors"
)
"github.com/fatedier/frp/server/ports"
var (
ErrGroupAuthFailed = errors.New("group auth failed")
ErrGroupParamsInvalid = errors.New("group params invalid")
ErrListenerClosed = errors.New("group listener closed")
gerr "github.com/fatedier/golib/errors"
)
type TcpGroupListener struct {
@@ -173,11 +168,11 @@ func (tg *TcpGroup) CloseListener(ln *TcpGroupListener) {
type TcpGroupCtl struct {
groups map[string]*TcpGroup
portManager *PortManager
portManager *ports.PortManager
mu sync.Mutex
}
func NewTcpGroupCtl(portManager *PortManager) *TcpGroupCtl {
func NewTcpGroupCtl(portManager *ports.PortManager) *TcpGroupCtl {
return &TcpGroupCtl{
groups: make(map[string]*TcpGroup),
portManager: portManager,

View File

@@ -1,4 +1,4 @@
package server
package ports
import (
"errors"

View File

@@ -24,6 +24,8 @@ import (
"github.com/fatedier/frp/assets"
"github.com/fatedier/frp/g"
"github.com/fatedier/frp/models/msg"
"github.com/fatedier/frp/server/group"
"github.com/fatedier/frp/server/ports"
"github.com/fatedier/frp/utils/log"
frpNet "github.com/fatedier/frp/utils/net"
"github.com/fatedier/frp/utils/util"
@@ -66,13 +68,13 @@ type Service struct {
visitorManager *VisitorManager
// Manage all tcp ports
tcpPortManager *PortManager
tcpPortManager *ports.PortManager
// Manage all udp ports
udpPortManager *PortManager
udpPortManager *ports.PortManager
// Tcp Group Controller
tcpGroupCtl *TcpGroupCtl
tcpGroupCtl *group.TcpGroupCtl
// Controller for nat hole connections
natHoleController *NatHoleController
@@ -84,10 +86,10 @@ func NewService() (svr *Service, err error) {
ctlManager: NewControlManager(),
pxyManager: NewProxyManager(),
visitorManager: NewVisitorManager(),
tcpPortManager: NewPortManager("tcp", cfg.ProxyBindAddr, cfg.AllowPorts),
udpPortManager: NewPortManager("udp", cfg.ProxyBindAddr, cfg.AllowPorts),
tcpPortManager: ports.NewPortManager("tcp", cfg.ProxyBindAddr, cfg.AllowPorts),
udpPortManager: ports.NewPortManager("udp", cfg.ProxyBindAddr, cfg.AllowPorts),
}
svr.tcpGroupCtl = NewTcpGroupCtl(svr.tcpPortManager)
svr.tcpGroupCtl = group.NewTcpGroupCtl(svr.tcpPortManager)
// Init assets.
err = assets.Load(cfg.AssetsDir)