forked from ljmict/feiQ
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConfig.go
62 lines (54 loc) · 1.39 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
54
55
56
57
58
59
60
61
62
package main
import (
"errors"
"net"
"github.com/larspensjo/config"
)
const (
FeiQPort = "2425"
FeiQVersion = "1"
// FeiQVersion = "1_lbt6_0#128#305A3A52C610#0#0#0#4001#9"
FeiQUserName = "robot"
FeiQHostName = "ESAP"
Broadcast = "255.255.255.255"
IPMSGBrEntry = 0x00000001 //上线提醒消息命令
IPMSGBrEXIT = 0x00000002 //下线提醒消息命令
IPMSGSendMsg = 0x00000020 //表示发送消息
IPMSGAnsentry = 0x00000003 //对方也在线
IPMSGRecvMsg = 0x00000021 //确认收到消息
IPMSGFileAttachOpt = 0x00200000
IPMSGFileRegular = 0x00000001 //普通文件
)
var (
//保存在线用户列表
UserSlice []map[string]string
UDPConn *net.UDPConn = nil
Port = "19090"
Local = "192.168.99.10"
Remote = "http://192.168.99.10:9090/robot/"
)
func GetConfig(sec string) (map[string]string, error) {
targetConfig := make(map[string]string)
cfg, err := config.ReadDefault("config.ini")
if err != nil {
return targetConfig, err
}
sections := cfg.Sections()
if len(sections) == 0 {
return targetConfig, errors.New("no " + sec + " config")
}
for _, section := range sections {
if section != sec {
continue
}
sectionData, _ := cfg.SectionOptions(section)
for _, key := range sectionData {
value, err := cfg.String(section, key)
if err == nil {
targetConfig[key] = value
}
}
break
}
return targetConfig, nil
}