lineDetection.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. type LineDetectionApi struct {
  10. }
  11. // GetLineDetectionCap 获取单个通道越界侦测规则参数配置能力
  12. func (api LineDetectionApi) GetLineDetectionCap(c *gin.Context) {
  13. host, err := GetHost(c)
  14. if err != nil {
  15. logrus.Errorf("获取host失败:%e\n", err)
  16. return
  17. }
  18. isapi.TouChuan(host, isapi.GetLineDetectionCap, nil, c)
  19. }
  20. // GetSizeLd 区域入侵
  21. func (api LineDetectionApi) GetSizeLd(c *gin.Context) {
  22. host, err := GetHost(c)
  23. if err != nil {
  24. logrus.Errorf("获取host失败:%e\n", err)
  25. return
  26. }
  27. isapi.TouChuan(host, isapi.GetLineDetectionCal, nil, c)
  28. }
  29. func (api LineDetectionApi) PutSizeLd(c *gin.Context) {
  30. defer c.Request.Body.Close()
  31. data, err := ioutil.ReadAll(c.Request.Body)
  32. if err != nil {
  33. logrus.Errorf("读取数据失败:%e\n", err)
  34. return
  35. }
  36. host, err := GetHost(c)
  37. if err != nil {
  38. logrus.Errorf("获取host失败:%e\n", err)
  39. return
  40. }
  41. isapi.TouChuan(host, isapi.PutLineDetectionCal, data, c)
  42. }
  43. func (api LineDetectionApi) GetLineDetection(c *gin.Context) {
  44. host, err := GetHost(c)
  45. if err != nil {
  46. logrus.Errorf("获取host失败:%e\n", err)
  47. return
  48. }
  49. isapi.TouChuan(host, isapi.GetLineDetection, nil, c)
  50. }
  51. func (api LineDetectionApi) PutLineDetection(c *gin.Context) {
  52. defer c.Request.Body.Close()
  53. data, err := ioutil.ReadAll(c.Request.Body)
  54. if err != nil {
  55. logrus.Errorf("读取数据失败:%e\n", err)
  56. return
  57. }
  58. host, err := GetHost(c)
  59. if err != nil {
  60. logrus.Errorf("获取host失败:%e\n", err)
  61. return
  62. }
  63. isapi.TouChuan(host, isapi.PutLineDetection, data, c)
  64. }