initiate.go 524 B

12345678910111213141516171819202122232425
  1. package goStrongswanVici
  2. import (
  3. "fmt"
  4. )
  5. // Initiate is used to initiate an SA. This is the
  6. // equivalent of `swanctl --initiate -c childname`
  7. func (c *ClientConn) Initiate(child string, ike string) (err error) {
  8. inMap := map[string]interface{}{}
  9. if child != "" {
  10. inMap["child"] = child
  11. }
  12. if ike != "" {
  13. inMap["ike"] = ike
  14. }
  15. msg, err := c.Request("initiate", inMap)
  16. if err != nil {
  17. return err
  18. }
  19. if msg["success"] != "yes" {
  20. return fmt.Errorf("unsuccessful Initiate: %v", msg["errmsg"])
  21. }
  22. return nil
  23. }