config.go 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2021, 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 refraction
  20. import (
  21. "net/http"
  22. "time"
  23. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common"
  24. )
  25. // ConjureConfig specifies the additional configuration for a Conjure dial.
  26. type ConjureConfig struct {
  27. // RegistrationCacheTTL specifies how long to retain a successful Conjure
  28. // registration for reuse in a subsequent dial. This value should be
  29. // synchronized with the Conjure station configuration. When
  30. // RegistrationCacheTTL is 0, registrations are not cached.
  31. RegistrationCacheTTL time.Duration
  32. // RegistrationCacheKey defines a scope or affinity for cached Conjure
  33. // registrations. For example, the key can reflect the target Psiphon server
  34. // as well as the current network ID. This ensures that any replay will
  35. // always use the same cached registration, including its phantom IP(s). And
  36. // ensures that the cache scope is restricted to the current network: when
  37. // the network changes, the client's public IP changes, and previous
  38. // registrations will become invalid. When the client returns to the original
  39. // network, the previous registrations may be valid once again (assuming
  40. // the client reverts back to its original public IP).
  41. RegistrationCacheKey string
  42. // APIRegistrarBidirectionalURL specifies the bidirectional API
  43. // registration endpoint. Setting APIRegistrarBidirectionalURL enables
  44. // API registration. The domain fronting configuration provided by
  45. // APIRegistrarHTTPClient may ignore the host portion of this URL,
  46. // implicitly providing another value; the path portion is always used in
  47. // the request. Only one of API registration or decoy registration can be
  48. // enabled for a single dial.
  49. APIRegistrarBidirectionalURL string
  50. // APIRegistrarHTTPClient specifies a custom HTTP client (and underlying
  51. // dialers) to be used for Conjure API registration. The
  52. // APIRegistrarHTTPClient enables domain fronting of API registration web
  53. // requests. This parameter is required when API registration is enabled.
  54. APIRegistrarHTTPClient *http.Client
  55. // APIRegistrarDelay specifies how long to wait after a successful API
  56. // registration before initiating the phantom dial(s), as required by the
  57. // Conjure protocol. This value depends on Conjure station operations and
  58. // should be synchronized with the Conjure station configuration.
  59. APIRegistrarDelay time.Duration
  60. // DecoyRegistrarDialer specifies a custom dialer to be used for decoy
  61. // registration. Only one of API registration or decoy registration can be
  62. // enabled for a single dial.
  63. DecoyRegistrarDialer common.NetDialer
  64. // DecoyRegistrarWidth specifies how many decoys to use per registration.
  65. DecoyRegistrarWidth int
  66. // DecoyRegistrarDelay specifies how long to wait after a successful API
  67. // registration before initiating the phantom dial(s), as required by the
  68. // Conjure protocol.
  69. //
  70. // Limitation: this value is not exposed by gotapdance and is currently
  71. // ignored.
  72. DecoyRegistrarDelay time.Duration
  73. // Transport may be protocol.CONJURE_TRANSPORT_MIN_OSSH or
  74. // protocol.CONJURE_TRANSPORT_OBFS4_OSSH.
  75. Transport string
  76. // DiagnosticID identifies this dial in diagnostics.
  77. DiagnosticID string
  78. // Logger is used for logging diagnostics.
  79. Logger common.Logger
  80. }