Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
matteriot committed Aug 24, 2024
1 parent eece208 commit f731037
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OpenIoTHub/utils/models"
"gopkg.in/yaml.v2"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand All @@ -32,7 +31,8 @@ func LoadConfig() (err error) {
writers = append(writers, os.Stdout)
}
if ConfigMode.LogConfig != nil && ConfigMode.LogConfig.LogFilePath != "" {
f, err := os.OpenFile(ConfigMode.LogConfig.LogFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
var f *os.File
f, err = os.OpenFile(ConfigMode.LogConfig.LogFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -111,6 +111,6 @@ func writeConfigFile(configMode models.ServerConfig, path string) (err error) {
if err != nil {
return
}
err = ioutil.WriteFile(path, configByte, 0644)
err = os.WriteFile(path, configByte, 0644)
return
}
8 changes: 7 additions & 1 deletion manager/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import (
// grpc
func (sm *SessionsManager) StartgRpcListenAndServ() {
go func() {
s := grpc.NewServer(grpc.Creds(credentials.NewTLS(autocertManager.TLSConfig())))
//TODO 如果是IP则使用不安全的连接,如果是域名则使用安全的连接
var s *grpc.Server
if net.ParseIP(config.ConfigMode.PublicIp) == nil {
s = grpc.NewServer(grpc.Creds(credentials.NewTLS(autocertManager.TLSConfig())))
} else {
s = grpc.NewServer()
}
pb.RegisterHttpManagerServer(s, sm)
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", config.ConfigMode.Common.GrpcPort))
if err != nil {
Expand Down

0 comments on commit f731037

Please sign in to comment.