working on rpc xml types
This commit is contained in:
parent
b60aa935ce
commit
d736c76fe4
2 changed files with 54 additions and 5 deletions
|
|
@ -2,6 +2,26 @@ package rpc
|
|||
|
||||
import "encoding/xml"
|
||||
|
||||
type LuxRpcWAN struct {
|
||||
XMLName xml.Name `xml:"wan"`
|
||||
Addr4 string `xml:"addr4"`
|
||||
Addr6 string `xml:"addr6"`
|
||||
}
|
||||
|
||||
type LuxRpcOption struct {
|
||||
XMLName xml.Name `xml:"option"`
|
||||
Type int `xml:"type,attr"`
|
||||
Blob string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
type LuxRpcState struct {
|
||||
XMLName xml.Name `xml:"state"`
|
||||
|
||||
WAN LuxRpcWAN `xml:"wan"`
|
||||
|
||||
Options []LuxRpcOption `xml:"option"`
|
||||
}
|
||||
|
||||
type LuxRpcHost struct {
|
||||
XMLName xml.Name `xml:"host"`
|
||||
HostID string `xml:"id,attr"`
|
||||
|
|
@ -19,6 +39,28 @@ type LuxRpcRequest struct {
|
|||
Hosts []LuxRpcHost `xml:"host"`
|
||||
}
|
||||
|
||||
type LuxRpcKeyNode struct {
|
||||
XMLName xml.Name `xml:"node"`
|
||||
ID string `xml:"id,attr"`
|
||||
|
||||
KeyBlob string `xml:"key"`
|
||||
IVBlob string `xml:"iv"`
|
||||
}
|
||||
|
||||
type LuxRpcKeyHost struct {
|
||||
XMLName xml.Name `xml:"host"`
|
||||
ID string `xml:"id,attr"`
|
||||
|
||||
KeyBlob string `xml:"key"`
|
||||
IVBlob string `xml:"iv"`
|
||||
}
|
||||
|
||||
type LuxRpcKeyStore struct {
|
||||
XMLName xml.Name `xml:"keystore"`
|
||||
Nodes []LuxRpcKeyNode `xml:"node"`
|
||||
Hosts []LuxRpcKeyHost `xml:"host"`
|
||||
}
|
||||
|
||||
type LuxRpcRoute struct {
|
||||
XMLName xml.Name `xml:"route"`
|
||||
Type int `xml:"type,attr"`
|
||||
|
|
@ -32,7 +74,7 @@ type LuxRpcResponse struct {
|
|||
RequestID int `xml:"id,attr"`
|
||||
|
||||
// Command-specific fields
|
||||
KeyStoreBlob string `xml:"keystore"`
|
||||
Keystore LuxRpcKeyStore `xml:"keystore"`
|
||||
Routes []LuxRpcRoute `xml:"route"`
|
||||
Hosts []LuxRpcHost `xml:"host"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,14 @@ func TestRequestDecoding(t *testing.T) {
|
|||
func TestResponseEncoding(t *testing.T) {
|
||||
xmlBytes, err := xml.Marshal(rpc.LuxRpcResponse{
|
||||
RequestID: 1,
|
||||
KeyStoreBlob: "*base64 keystore*",
|
||||
Keystore: rpc.LuxRpcKeyStore{
|
||||
Nodes: []rpc.LuxRpcKeyNode{
|
||||
{ID: "1111", KeyBlob: "base64 key", IVBlob: "base64 iv"},
|
||||
},
|
||||
Hosts: []rpc.LuxRpcKeyHost{
|
||||
{ID: "0002", KeyBlob: "base64 key", IVBlob: "base64 iv"},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue