Skip to content

Commit f731037

Browse files
committed
update
1 parent eece208 commit f731037

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/OpenIoTHub/utils/models"
77
"gopkg.in/yaml.v2"
88
"io"
9-
"io/ioutil"
109
"log"
1110
"os"
1211
"path/filepath"
@@ -32,7 +31,8 @@ func LoadConfig() (err error) {
3231
writers = append(writers, os.Stdout)
3332
}
3433
if ConfigMode.LogConfig != nil && ConfigMode.LogConfig.LogFilePath != "" {
35-
f, err := os.OpenFile(ConfigMode.LogConfig.LogFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
34+
var f *os.File
35+
f, err = os.OpenFile(ConfigMode.LogConfig.LogFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
3636
if err != nil {
3737
log.Fatal(err)
3838
}
@@ -111,6 +111,6 @@ func writeConfigFile(configMode models.ServerConfig, path string) (err error) {
111111
if err != nil {
112112
return
113113
}
114-
err = ioutil.WriteFile(path, configByte, 0644)
114+
err = os.WriteFile(path, configByte, 0644)
115115
return
116116
}

manager/grpc.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ import (
1818
// grpc
1919
func (sm *SessionsManager) StartgRpcListenAndServ() {
2020
go func() {
21-
s := grpc.NewServer(grpc.Creds(credentials.NewTLS(autocertManager.TLSConfig())))
21+
//TODO 如果是IP则使用不安全的连接,如果是域名则使用安全的连接
22+
var s *grpc.Server
23+
if net.ParseIP(config.ConfigMode.PublicIp) == nil {
24+
s = grpc.NewServer(grpc.Creds(credentials.NewTLS(autocertManager.TLSConfig())))
25+
} else {
26+
s = grpc.NewServer()
27+
}
2228
pb.RegisterHttpManagerServer(s, sm)
2329
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", config.ConfigMode.Common.GrpcPort))
2430
if err != nil {

0 commit comments

Comments
 (0)