fieldDetection.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package isapi
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "io/ioutil"
  6. "lcfns/isapi"
  7. )
  8. /*
  9. 监测目标的尺寸-最大尺寸和最小尺寸
  10. */
  11. type FieldDetectionApi struct {
  12. }
  13. // GetFieldDectionCap 获取单个通道区域入侵规则参数配置能力
  14. func (api FieldDetectionApi) GetFieldDectionCap(c *gin.Context) {
  15. host, err := GetHost(c)
  16. if err != nil {
  17. logrus.Errorf("获取host失败:%s", err.Error())
  18. return
  19. }
  20. isapi.TouChuan(host, isapi.GetFieldDetectionCap, nil, c)
  21. }
  22. // GetSizeFd get size for field detection 区域入侵
  23. func (api FieldDetectionApi) GetSizeFd(c *gin.Context) {
  24. host, err := GetHost(c)
  25. if err != nil {
  26. logrus.Errorf("获取host失败:%e\n", err)
  27. return
  28. }
  29. isapi.TouChuan(host, isapi.GetFieldDetectionCal, nil, c)
  30. }
  31. func (api FieldDetectionApi) PutSizeFd(c *gin.Context) {
  32. defer c.Request.Body.Close()
  33. data, err := ioutil.ReadAll(c.Request.Body)
  34. if err != nil {
  35. logrus.Errorf("读取数据失败:%e\n", err)
  36. return
  37. }
  38. host, err := GetHost(c)
  39. if err != nil {
  40. logrus.Errorf("获取host失败:%e\n", err)
  41. return
  42. }
  43. isapi.TouChuan(host, isapi.PutFieldDetectionCal, data, c)
  44. }
  45. func (api FieldDetectionApi) GetFieldDection(c *gin.Context) {
  46. host, err := GetHost(c)
  47. if err != nil {
  48. logrus.Errorf("获取host失败:%e\n", err)
  49. return
  50. }
  51. isapi.TouChuan(host, isapi.GetFieldDetection, nil, c)
  52. }
  53. func (api FieldDetectionApi) PutFieldDection(c *gin.Context) {
  54. defer c.Request.Body.Close()
  55. data, err := ioutil.ReadAll(c.Request.Body)
  56. if err != nil {
  57. logrus.Errorf("读取数据失败:%e\n", err)
  58. return
  59. }
  60. host, err := GetHost(c)
  61. if err != nil {
  62. logrus.Errorf("获取host失败:%e\n", err)
  63. return
  64. }
  65. isapi.TouChuan(host, isapi.PutFieldDetection, data, c)
  66. }