pools.go 796 B

123456789101112131415161718192021222324252627282930313233343536
  1. package goStrongswanVici
  2. import (
  3. "fmt"
  4. )
  5. type Pool struct {
  6. PoolMapping map[string]interface{} `json:"pools"`
  7. }
  8. type PoolMapping struct {
  9. Addrs string `json:"addrs"`
  10. DNS []string `json:"dns,omitempty"`
  11. NBNS []string `json:"nbns,omitempty"`
  12. ApplicationVersion []string `json:"7,omitempty"`
  13. InternalIPv6Prefix []string `json:"18,omitempty"`
  14. }
  15. func (c *ClientConn) LoadPool(ph Pool) error {
  16. requestMap := map[string]interface{}{}
  17. err := ConvertToGeneral(ph.PoolMapping, &requestMap)
  18. if err != nil {
  19. fmt.Println(err)
  20. return fmt.Errorf("error creating request: %v", err)
  21. }
  22. msg, err := c.Request("load-pool", requestMap)
  23. if msg["success"] != "yes" {
  24. return fmt.Errorf("unsuccessful LoadPool: %v", msg["errmsg"])
  25. }
  26. return nil
  27. }