mirror of
https://github.com/VaalaCat/frp-panel.git
synced 2024-07-16 17:41:16 +08:00
fix: thread leak
This commit is contained in:
parent
e2513dfef0
commit
17ebb42451
@ -6,19 +6,30 @@ import (
|
||||
"github.com/VaalaCat/frp-panel/conf"
|
||||
"github.com/VaalaCat/frp-panel/pb"
|
||||
"github.com/imroc/req/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func MasterCli(c context.Context) (pb.MasterClient, error) {
|
||||
var (
|
||||
masterCli pb.MasterClient
|
||||
)
|
||||
|
||||
func newMasterCli() {
|
||||
conn, err := grpc.Dial(conf.RPCCallAddr(),
|
||||
grpc.WithTransportCredentials(conf.ClientCred))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
logrus.Fatalf("did not connect: %v", err)
|
||||
}
|
||||
|
||||
client := pb.NewMasterClient(conn)
|
||||
return client, nil
|
||||
masterCli = pb.NewMasterClient(conn)
|
||||
}
|
||||
|
||||
func MasterCli(c context.Context) (pb.MasterClient, error) {
|
||||
if masterCli == nil {
|
||||
newMasterCli()
|
||||
}
|
||||
return masterCli, nil
|
||||
}
|
||||
|
||||
func GetClientCert(clientID, clientSecret string, clientType pb.ClientType) []byte {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package watcher
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/go-co-op/gocron/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Client interface {
|
||||
|
Loading…
Reference in New Issue
Block a user