MiddleFilter.lua 799 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ----------------------------------------------
  2. -- 跨服协议白名单
  3. ----------------------------------------------
  4. local ProtoId = require("common.ProtoID")
  5. local t = {
  6. "CG_AA_DISCONNECT",
  7. "CG_ASK_LOGIN",
  8. "CG_CHAT",
  9. "CG_HEART_BEAT",
  10. "CG_HEART_BEAT_M",
  11. "CG_MIDDLE_LOGIN",
  12. "CG_MIDDLE_LOGOUT",
  13. "CG_MIDDLE_PLAYING_STATUS",
  14. }
  15. local hash = {}
  16. for k, v in pairs(ProtoId) do
  17. if type(k) == "number" and string.sub(v, 1, 1) == "C" then
  18. if hash[v] then
  19. assert()
  20. end
  21. hash[v] = k
  22. end
  23. end
  24. local permit = {}
  25. for k, v in ipairs(t) do
  26. local id = hash[v]
  27. if not id then
  28. assert(nil, v)
  29. end
  30. if permit[id] then
  31. assert(nil, v .. " not unique")
  32. end
  33. permit[id] = true
  34. end
  35. function isPermit(protoID)
  36. if permit[protoID] then
  37. return true
  38. end
  39. end