filter.go 470 B

1234567891011121314151617181920212223242526272829
  1. package common
  2. import (
  3. "os"
  4. "strconv"
  5. )
  6. var FILTER_PID_KEY = "FILTER_PID"
  7. var INT_FILTER_PID = 0
  8. func init() {
  9. filterPid, err := strconv.ParseInt(os.Getenv(FILTER_PID_KEY), 10, 64)
  10. if err == nil {
  11. INT_FILTER_PID = int(filterPid)
  12. }
  13. }
  14. func IsOpenFilter() bool {
  15. return INT_FILTER_PID != 0
  16. }
  17. func GetFilterPid() (int, bool) {
  18. return INT_FILTER_PID, INT_FILTER_PID == 0
  19. }
  20. func IsFilterPid(filterPid uint32) bool {
  21. return int(filterPid) == INT_FILTER_PID
  22. }