-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathpools.go
36 lines (27 loc) · 796 Bytes
/
pools.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
package goStrongswanVici
import (
"fmt"
)
type Pool struct {
PoolMapping map[string]interface{} `json:"pools"`
}
type PoolMapping struct {
Addrs string `json:"addrs"`
DNS []string `json:"dns,omitempty"`
NBNS []string `json:"nbns,omitempty"`
ApplicationVersion []string `json:"7,omitempty"`
InternalIPv6Prefix []string `json:"18,omitempty"`
}
func (c *ClientConn) LoadPool(ph Pool) error {
requestMap := map[string]interface{}{}
err := ConvertToGeneral(ph.PoolMapping, &requestMap)
if err != nil {
fmt.Println(err)
return fmt.Errorf("error creating request: %v", err)
}
msg, err := c.Request("load-pool", requestMap)
if msg["success"] != "yes" {
return fmt.Errorf("unsuccessful LoadPool: %v", msg["errmsg"])
}
return nil
}