|
|
@@ -64,27 +64,6 @@ type KeyShareMsg struct {
|
|
64
|
64
|
key string
|
|
65
|
65
|
}
|
|
66
|
66
|
|
|
67
|
|
-func NewKeyShareMsg(message Message,key string) *KeyShareMsg {
|
|
68
|
|
- addrs,err:=net.InterfaceAddrs()
|
|
69
|
|
- var ipaddr string
|
|
70
|
|
- if err !=nil{
|
|
71
|
|
- os.Stderr.WriteString("Oops: "+err.Error()+"\n")
|
|
72
|
|
- os.Exit(1)
|
|
73
|
|
- }
|
|
74
|
|
- for _,a:=range addrs{
|
|
75
|
|
- if ipnet, ok:=a.(*net.IPNet); ok && !ipnet.IP.IsLoopback(){
|
|
76
|
|
- ipaddr=ipnet.IP.String()
|
|
77
|
|
- }
|
|
78
|
|
- }
|
|
79
|
|
- t := time.Now().String()
|
|
80
|
|
- return &KeyShareMsg{Message{
|
|
81
|
|
- from: ipaddr,
|
|
82
|
|
- version: "1",
|
|
83
|
|
- time: t,
|
|
84
|
|
- kind: KSM,
|
|
85
|
|
- },key}
|
|
86
|
|
-}
|
|
87
|
|
-
|
|
88
|
67
|
//전달할 내용을 담은 메세지
|
|
89
|
68
|
type PublishMsg struct {
|
|
90
|
69
|
Message
|
|
|
@@ -99,7 +78,6 @@ type SubscriptionMsg struct {
|
|
99
|
78
|
topic string //대주제
|
|
100
|
79
|
value string //피연산자
|
|
101
|
80
|
operator []string //연산자
|
|
102
|
|
- isAlpha bool // 범위연산인지 단순비교연산인지 구분 가능하게 함
|
|
103
|
81
|
}
|
|
104
|
82
|
|
|
105
|
83
|
//Microservice 등록 메세지
|
|
|
@@ -115,6 +93,29 @@ type WithdrawMsg struct {
|
|
115
|
93
|
}
|
|
116
|
94
|
|
|
117
|
95
|
//생성자
|
|
|
96
|
+
|
|
|
97
|
+func NewKeyShareMsg(message Message,key string) *KeyShareMsg {
|
|
|
98
|
+ addrs,err:=net.InterfaceAddrs()
|
|
|
99
|
+ var ipaddr string
|
|
|
100
|
+ if err !=nil{
|
|
|
101
|
+ os.Stderr.WriteString("Oops: "+err.Error()+"\n")
|
|
|
102
|
+ os.Exit(1)
|
|
|
103
|
+ }
|
|
|
104
|
+ for _,a:=range addrs{
|
|
|
105
|
+ if ipnet, ok:=a.(*net.IPNet); ok && !ipnet.IP.IsLoopback(){
|
|
|
106
|
+ ipaddr=ipnet.IP.String()
|
|
|
107
|
+ }
|
|
|
108
|
+ }
|
|
|
109
|
+ var tmpt = time.Now().Format("2006-03-15 15:04:05")
|
|
|
110
|
+ t:=string(tmpt)
|
|
|
111
|
+ return &KeyShareMsg{Message{
|
|
|
112
|
+ from: ipaddr,
|
|
|
113
|
+ version: "1",
|
|
|
114
|
+ time: t,
|
|
|
115
|
+ kind: KSM,
|
|
|
116
|
+ },key}
|
|
|
117
|
+}+
|
|
|
118
|
+
|
|
118
|
119
|
func NewPublishMsg(message Message, topic string, value string, content string) *PublishMsg {
|
|
119
|
120
|
addrs,err:=net.InterfaceAddrs()
|
|
120
|
121
|
var ipaddr string
|
|
|
@@ -127,7 +128,8 @@ func NewPublishMsg(message Message, topic string, value string, content string)
|
|
127
|
128
|
ipaddr=ipnet.IP.String()
|
|
128
|
129
|
}
|
|
129
|
130
|
}
|
|
130
|
|
- t := time.Now().String()
|
|
|
131
|
+ var tmpt = time.Now().Format("2006-03-15 15:04:05")
|
|
|
132
|
+ t:=string(tmpt)
|
|
131
|
133
|
return &PublishMsg{Message{
|
|
132
|
134
|
from: ipaddr,
|
|
133
|
135
|
version: "1",
|
|
|
@@ -148,13 +150,14 @@ func NewSubscriptionMsg(message Message,topic string, value string, operator []s
|
|
148
|
150
|
ipaddr=ipnet.IP.String()
|
|
149
|
151
|
}
|
|
150
|
152
|
}
|
|
151
|
|
- t := time.Now().String()
|
|
|
153
|
+ var tmpt = time.Now().Format("2006-03-15 15:04:05")
|
|
|
154
|
+ t:=string(tmpt)
|
|
152
|
155
|
return &SubscriptionMsg{Message{
|
|
153
|
156
|
from: ipaddr,
|
|
154
|
157
|
version: "1",
|
|
155
|
158
|
time: t,
|
|
156
|
159
|
kind: SM,
|
|
157
|
|
- },topic,value,operator,isAlpha}
|
|
|
160
|
+ },topic,value,operator}
|
|
158
|
161
|
|
|
159
|
162
|
}
|
|
160
|
163
|
|
|
|
@@ -170,7 +173,8 @@ func NewRegisterMsg(message Message) *RegisterMsg {
|
|
170
|
173
|
ipaddr=ipnet.IP.String()
|
|
171
|
174
|
}
|
|
172
|
175
|
}
|
|
173
|
|
- t := time.Now().String()
|
|
|
176
|
+ var tmpt = time.Now().Format("2006-03-15 15:04:05")
|
|
|
177
|
+ t:=string(tmpt)
|
|
174
|
178
|
return &RegisterMsg{Message{
|
|
175
|
179
|
from: ipaddr,
|
|
176
|
180
|
version: "1",
|
|
|
@@ -191,7 +195,8 @@ func NewWithdrawMsg(message Message) *WithdrawMsg {
|
|
191
|
195
|
ipaddr=ipnet.IP.String()
|
|
192
|
196
|
}
|
|
193
|
197
|
}
|
|
194
|
|
- t := time.Now().String()
|
|
|
198
|
+ var tmpt = time.Now().Format("2006-03-15 15:04:05")
|
|
|
199
|
+ t:=string(tmpt)
|
|
195
|
200
|
return &WithdrawMsg{Message{
|
|
196
|
201
|
from: ipaddr,
|
|
197
|
202
|
version: "1",
|