From 699fb9d4f0433be03ff25a3b5ecc3ed95dc0c723 Mon Sep 17 00:00:00 2001 From: Byron Williams Date: Wed, 17 May 2017 17:03:19 +0100 Subject: [PATCH 1/2] Load children in order --- loadConn.go | 10 +++++----- msg.go | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/loadConn.go b/loadConn.go index 88f49b4..ea7b3b7 100644 --- a/loadConn.go +++ b/loadConn.go @@ -16,11 +16,11 @@ type IKEConf struct { Encap string `json:"encap"` //yes,no KeyingTries string `json:"keyingtries"` // RekyTime string `json:"rekey_time"` - DPDDelay string `json:"dpd_delay,omitempty"` - LocalAuth AuthConf `json:"local"` - RemoteAuth AuthConf `json:"remote"` - Pools []string `json:"pools,omitempty"` - Children map[string]ChildSAConf `json:"children"` + DPDDelay string `json:"dpd_delay,omitempty"` + LocalAuth AuthConf `json:"local"` + RemoteAuth AuthConf `json:"remote"` + Pools []string `json:"pools,omitempty"` + Children []map[string]ChildSAConf `json:"children"` } type AuthConf struct { diff --git a/msg.go b/msg.go index 06e5a16..25df54c 100644 --- a/msg.go +++ b/msg.go @@ -237,11 +237,30 @@ func writeMap(w *bytes.Buffer, msg map[string]interface{}) (err error) { case string: writeKeyString(w, k, t) case []interface{}: - str := make([]string, len(t)) - for i := range t { - str[i] = t[i].(string) + if len(t) == 0 { + continue + } + + switch t[0].(type) { + case string: + + str := make([]string, len(t)) + for i := range t { + str[i] = t[i].(string) + } + writeKeyList(w, k, str) + case map[string]interface{}: + // If the interface{} is actually a nested map[string]interface{} + // then we want to write the keyMap in the order that they are + // in the slice. This is necessary for the ordering of `children` + for _, nested := range t { + nestedVal := nested.(map[string]interface{}) + + for _ = range nestedVal { + writeKeyMap(w, k, nestedVal) + } + } } - writeKeyList(w, k, str) default: return fmt.Errorf("[writeMap] can not write type %T right now", msg) } From b4f32da3c0fc57e3393e82a5c520947b0fa5bd27 Mon Sep 17 00:00:00 2001 From: Byron Williams Date: Thu, 15 Jun 2017 16:18:13 +0100 Subject: [PATCH 2/2] Add RekeyTime and ReauthTime --- loadConn.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/loadConn.go b/loadConn.go index ea7b3b7..b4d010f 100644 --- a/loadConn.go +++ b/loadConn.go @@ -9,18 +9,19 @@ type Connection struct { } type IKEConf struct { - LocalAddrs []string `json:"local_addrs"` - RemoteAddrs []string `json:"remote_addrs,omitempty"` - Proposals []string `json:"proposals,omitempty"` - Version string `json:"version"` //1 for ikev1, 0 for ikev1 & ikev2 - Encap string `json:"encap"` //yes,no - KeyingTries string `json:"keyingtries"` - // RekyTime string `json:"rekey_time"` - DPDDelay string `json:"dpd_delay,omitempty"` - LocalAuth AuthConf `json:"local"` - RemoteAuth AuthConf `json:"remote"` - Pools []string `json:"pools,omitempty"` - Children []map[string]ChildSAConf `json:"children"` + LocalAddrs []string `json:"local_addrs"` + RemoteAddrs []string `json:"remote_addrs,omitempty"` + Proposals []string `json:"proposals,omitempty"` + Version string `json:"version"` //1 for ikev1, 0 for ikev1 & ikev2 + Encap string `json:"encap"` //yes,no + KeyingTries string `json:"keyingtries"` + RekeyTime string `json:"rekey_time"` + ReauthTime string `json:"reauth_time"` + DPDDelay string `json:"dpd_delay,omitempty"` + LocalAuth AuthConf `json:"local"` + RemoteAuth AuthConf `json:"remote"` + Pools []string `json:"pools,omitempty"` + Children []map[string]ChildSAConf `json:"children"` } type AuthConf struct {