s2c.go 936 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package gatewayServer
  2. import (
  3. "errors"
  4. )
  5. // 查询
  6. func s2c8003Query(devId string, subCode CmdCode, data string) error {
  7. a := AppDataUnit{
  8. CmdCode: CmdCodeGetParamS2C,
  9. SubCode: subCode,
  10. DevId: devId,
  11. }
  12. a.Debug()
  13. c, ok := ConnMap[devId]
  14. if !ok {
  15. return errors.New("连接不在cMap中")
  16. }
  17. _, err := c.Write(Pack(a))
  18. if err != nil {
  19. return err
  20. }
  21. return nil
  22. }
  23. var add1 = "add=name:test1;proto:tcp;src_dport:8888;dest_ip:192.168.1.61;dest_port:80"
  24. var add2 = "add=name:test2;proto:tcp;src_dport:8889;dest_ip:192.168.1.60;dest_port:80"
  25. var apply = "apply"
  26. // 配置
  27. func s2c8004Set(devId string, subCode CmdCode, data string) error {
  28. a := AppDataUnit{
  29. CmdCode: CmdCodeSetParameterS2C,
  30. SubCode: subCode,
  31. DevId: devId,
  32. Data: data,
  33. }
  34. a.Debug()
  35. c, ok := ConnMap[devId]
  36. if !ok {
  37. return errors.New("连接不在cMap中")
  38. }
  39. _, err := c.Write(Pack(a))
  40. if err != nil {
  41. return err
  42. }
  43. return nil
  44. }