ソースを参照

V2.0版本更新

zhengtao 8 ヶ月 前
コミット
08b06543cb
2 ファイル変更15 行追加13 行削除
  1. 8 7
      components/mongo/component.go
  2. 7 6
      game/game_cluster/internal/mdb/component.go

+ 8 - 7
components/mongo/component.go

@@ -2,6 +2,7 @@ package mhayaMongo
 
 import (
 	"context"
+	"crypto/tls"
 	"fmt"
 	"time"
 
@@ -93,13 +94,13 @@ func CreateDatabase(uri, dbName string, timeout ...time.Duration) (*mongo.Databa
 	if len(timeout) > 0 && timeout[0].Seconds() > 3 {
 		tt = timeout[0]
 	}
-	/*	tlsConfig := &tls.Config{
-			MinVersion:               tls.VersionTLS12,
-			PreferServerCipherSuites: true,
-		}
-		o := options.Client().ApplyURI(uri).SetTLSConfig(tlsConfig)
-	*/
-	o := options.Client().ApplyURI(uri)
+	tlsConfig := &tls.Config{
+		MinVersion:               tls.VersionTLS12,
+		PreferServerCipherSuites: true,
+	}
+	o := options.Client().ApplyURI(uri).SetTLSConfig(tlsConfig)
+
+	//o := options.Client().ApplyURI(uri)
 	if err := o.Validate(); err != nil {
 		return nil, err
 	}

+ 7 - 6
game/game_cluster/internal/mdb/component.go

@@ -1,6 +1,7 @@
 package mdb
 
 import (
+	"crypto/tls"
 	"github.com/go-redis/redis/v8"
 	mhayaMongo "github.com/mhaya/components/mongo"
 	clog "github.com/mhaya/logger"
@@ -36,15 +37,15 @@ func (p *ActorDB) OnInit() {
 		clog.Panic("game_db_id not found")
 	}
 	redisConfig := cprofile.GetConfig("redis")
-	/*	tlsConfig := &tls.Config{
+	tlsConfig := &tls.Config{
 		MinVersion:               tls.VersionTLS12,
 		PreferServerCipherSuites: true,
-	}*/
+	}
 	RDB = redis.NewUniversalClient(&redis.UniversalOptions{
-		Addrs:    []string{redisConfig.GetString("address")},
-		Password: redisConfig.GetString("password"),
-		DB:       redisConfig.GetInt("db"),
-		//	TLSConfig: tlsConfig,
+		Addrs:     []string{redisConfig.GetString("address")},
+		Password:  redisConfig.GetString("password"),
+		DB:        redisConfig.GetInt("db"),
+		TLSConfig: tlsConfig,
 	})
 
 	if p.App().NodeId() == "m-center" {