-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc_protocol.go
49 lines (37 loc) · 895 Bytes
/
rc_protocol.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
package rc_protocol
import "sync"
var once sync.Once
var proto protocol
type RCProtocol interface {
Message(json string) Message
Response(json string) Response
Auth
}
type protocol struct {
auth Auth
}
func (p protocol) CreateSig(name string, keyDir string) (string, error) {
return p.auth.CreateSig(name, keyDir)
}
func (p protocol) CheckSig(header string, certDir string) (bool, error) {
return p.auth.CheckSig(header, certDir)
}
func (p protocol) GetHeaderName() string {
return p.auth.GetHeaderName()
}
func (p protocol) ParseHeader(header string) []string {
return p.auth.ParseHeader(header)
}
func (p protocol) Message(json string) Message {
return newMessage(json)
}
func (p protocol) Response(json string) Response {
return newResponse(json)
}
func NewRCProtocol() RCProtocol {
once.Do(func () {
proto = protocol{}
proto.auth = newAuth()
})
return proto
}