terminate.go 883 B

123456789101112131415161718192021222324252627282930313233
  1. package goStrongswanVici
  2. import (
  3. "fmt"
  4. )
  5. type TerminateRequest struct {
  6. Child string `json:"child,omitempty"`
  7. Ike string `json:"ike,omitempty"`
  8. Child_id string `json:"child-id,omitempty"`
  9. Ike_id string `json:"ike-id,omitempty"`
  10. Force string `json:"force,omitempty"`
  11. Timeout string `json:"timeout,omitempty"`
  12. Loglevel string `json:"loglevel,omitempty"`
  13. }
  14. // To be simple, kill a client that is connecting to this server. A client is a sa.
  15. //Terminates an SA while streaming control-log events.
  16. func (c *ClientConn) Terminate(r *TerminateRequest) (err error) {
  17. err = handlePanic(func() (err error) {
  18. reqMap := &map[string]interface{}{}
  19. ConvertToGeneral(r, reqMap)
  20. msg, err := c.Request("terminate", *reqMap)
  21. if err != nil {
  22. return
  23. }
  24. if msg["success"] != "yes" {
  25. return fmt.Errorf("[Terminate] %s", msg["errmsg"])
  26. }
  27. return
  28. })
  29. return
  30. }