Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load children in order #1

Open
wants to merge 2 commits into
base: BW/certs-pools-keys
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions loadConn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
27 changes: 23 additions & 4 deletions msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down