debug.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2023, Psiphon Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. package inproxy
  20. import (
  21. "sync/atomic"
  22. )
  23. var allowCommonASNMatching int32
  24. func GetAllowCommonASNMatching() bool {
  25. return atomic.LoadInt32(&allowCommonASNMatching) == 1
  26. }
  27. // SetAllowCommonASNMatching configures whether to allow matching proxies and
  28. // clients with the same GeoIP country and ASN. This matching is always
  29. // permitted for matching personal compartment IDs, but for common
  30. // compartment IDs, these matches are not allowed as they are not expected to
  31. // be useful. SetAllowCommonASNMatching is for end-to-end testing on a single
  32. // host, and should be used only for testing purposes.
  33. func SetAllowCommonASNMatching(allow bool) {
  34. value := int32(0)
  35. if allow {
  36. value = 1
  37. }
  38. atomic.StoreInt32(&allowCommonASNMatching, value)
  39. }
  40. var allowBogonWebRTCConnections int32
  41. func GetAllowBogonWebRTCConnections() bool {
  42. return atomic.LoadInt32(&allowBogonWebRTCConnections) == 1
  43. }
  44. // SetAllowBogonWebRTCConnections configures whether to allow bogon ICE
  45. // candidates in WebRTC session descriptions. This included loopback and
  46. // private network candidates. By default, bogon addresses are exclude as
  47. // they are not expected to be useful and may expose private network
  48. // information. SetAllowBogonWebRTCConnections is for end-to-end testing on a
  49. // single host, and should be used only for testing purposes.
  50. func SetAllowBogonWebRTCConnections(allow bool) {
  51. value := int32(0)
  52. if allow {
  53. value = 1
  54. }
  55. atomic.StoreInt32(&allowBogonWebRTCConnections, value)
  56. }