debug.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2024, 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 psiphon
  20. import (
  21. "sync/atomic"
  22. )
  23. var allowOverlappingPersonalCompartmentIDs int32
  24. func GetAllowOverlappingPersonalCompartmentIDs() bool {
  25. return atomic.LoadInt32(&allowOverlappingPersonalCompartmentIDs) == 1
  26. }
  27. // SetAllowOverlappingPersonalCompartmentIDs configures whether to allow
  28. // overlapping personal compartment IDs in InproxyProxyPersonalCompartmentIDs
  29. // and InproxyClientPersonalCompartmentIDs. Overlapping IDs are not allowed
  30. // in order to prevent a client matching its own proxy.
  31. // SetAllowOverlappingPersonalCompartmentIDs is for end-to-end testing on a
  32. // single host, and should be used only for testing purposes.
  33. func SetAllowOverlappingPersonalCompartmentIDs(allow bool) {
  34. value := int32(0)
  35. if allow {
  36. value = 1
  37. }
  38. atomic.StoreInt32(&allowOverlappingPersonalCompartmentIDs, 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. }