terminate.go 841 B

1234567891011121314151617181920212223242526272829303132
  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. Timeout string `json:"timeout,omitempty"`
  11. Loglevel string `json:"loglevel,omitempty"`
  12. }
  13. // To be simple, kill a client that is connecting to this server. A client is a sa.
  14. //Terminates an SA while streaming control-log events.
  15. func (c *ClientConn) Terminate(r *TerminateRequest) (err error) {
  16. err = handlePanic(func() (err error) {
  17. reqMap := &map[string]interface{}{}
  18. ConvertToGeneral(r, reqMap)
  19. msg, err := c.Request("terminate", *reqMap)
  20. if err != nil {
  21. return
  22. }
  23. if msg["success"] != "yes" {
  24. return fmt.Errorf("[Terminate] %s", msg["errmsg"])
  25. }
  26. return
  27. })
  28. return
  29. }