diff --git a/rpc/lux_rpc.go b/rpc/lux_rpc.go index 27e96c6..110137d 100644 --- a/rpc/lux_rpc.go +++ b/rpc/lux_rpc.go @@ -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,9 +74,9 @@ type LuxRpcResponse struct { RequestID int `xml:"id,attr"` // Command-specific fields - KeyStoreBlob string `xml:"keystore"` - Routes []LuxRpcRoute `xml:"route"` - Hosts []LuxRpcHost `xml:"host"` + Keystore LuxRpcKeyStore `xml:"keystore"` + Routes []LuxRpcRoute `xml:"route"` + Hosts []LuxRpcHost `xml:"host"` } type LuxRpcError struct { diff --git a/tests/lux_rpc_test.go b/tests/lux_rpc_test.go index ca709e1..46bb853 100644 --- a/tests/lux_rpc_test.go +++ b/tests/lux_rpc_test.go @@ -43,8 +43,15 @@ func TestRequestDecoding(t *testing.T) { func TestResponseEncoding(t *testing.T) { xmlBytes, err := xml.Marshal(rpc.LuxRpcResponse{ - RequestID: 1, - KeyStoreBlob: "*base64 keystore*", + RequestID: 1, + 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)