-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconfig.go
53 lines (44 loc) · 1.12 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"encoding/json"
"os"
)
type Config_ struct {
SipPort int `json:"sip_port"`
HttpPort int `json:"http_port"`
ListenIP string `json:"listen_ip"`
PublicIP string `json:"public_ip"`
SipId string `json:"sip_id"`
Password string `json:"password"`
SipContactAddr string
AliveExpires int `json:"alive_expires"`
MobilePositionInterval int `json:"mobile_position_interval"`
MobilePositionExpires int `json:"mobile_position_expires"`
MediaServer string `json:"media_server"`
Port []int `json:"port"` //语音广播/对讲需要的端口
AutoCloseOnIdle bool `json:"auto_close_on_idle"`
Redis struct {
Addr string `json:"addr"`
Password string `json:"password"`
}
}
type LogConfig struct {
Level int
Name string
MaxSize int
MaxBackup int
MaxAge int
Compress bool
}
func ParseConfig(path string) (*Config_, error) {
file, err := os.ReadFile(path)
if err != nil {
return nil, err
}
config := Config_{}
err = json.Unmarshal(file, &config)
if err != nil {
return nil, err
}
return &config, err
}