parameters.go 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415
  1. /*
  2. * Copyright (c) 2018, 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. /*
  20. Package parameters implements dynamic, concurrency-safe parameters that
  21. determine Psiphon client and server behaviors.
  22. Parameters include network timeouts, probabilities for actions, lists of
  23. protocols, etc. Parameters are initialized with reasonable defaults. New
  24. values may be applied, allowing the client or server to customize its
  25. parameters from both a config file and tactics data. Sane minimum values are
  26. enforced.
  27. Parameters may be read and updated concurrently. The read mechanism offers a
  28. snapshot so that related parameters, such as two Ints representing a range; or
  29. a more complex series of related parameters; may be read in an atomic and
  30. consistent way. For example:
  31. p := params.Get()
  32. min := p.Int("Min")
  33. max := p.Int("Max")
  34. p = nil
  35. For long-running operations, it is recommended to set any pointer to the
  36. snapshot to nil to allow garbage collection of old snaphots in cases where the
  37. parameters change.
  38. In general, parameters should be read as close to the point of use as possible
  39. to ensure that dynamic changes to the parameter values take effect.
  40. For duration parameters, time.ParseDuration-compatible string values are
  41. supported when applying new values. This allows specifying durations as, for
  42. example, "100ms" or "24h".
  43. Values read from the parameters are not deep copies and must be treated as
  44. read-only.
  45. */
  46. package parameters
  47. import (
  48. "encoding/json"
  49. "net/http"
  50. "reflect"
  51. "sync/atomic"
  52. "time"
  53. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common"
  54. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/errors"
  55. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/obfuscator"
  56. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/prng"
  57. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/protocol"
  58. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/transforms"
  59. "golang.org/x/net/bpf"
  60. )
  61. const (
  62. NetworkLatencyMultiplier = "NetworkLatencyMultiplier"
  63. NetworkLatencyMultiplierMin = "NetworkLatencyMultiplierMin"
  64. NetworkLatencyMultiplierMax = "NetworkLatencyMultiplierMax"
  65. NetworkLatencyMultiplierLambda = "NetworkLatencyMultiplierLambda"
  66. TacticsWaitPeriod = "TacticsWaitPeriod"
  67. TacticsRetryPeriod = "TacticsRetryPeriod"
  68. TacticsRetryPeriodJitter = "TacticsRetryPeriodJitter"
  69. TacticsTimeout = "TacticsTimeout"
  70. ConnectionWorkerPoolSize = "ConnectionWorkerPoolSize"
  71. TunnelPoolSize = "TunnelPoolSize"
  72. TunnelConnectTimeout = "TunnelConnectTimeout"
  73. EstablishTunnelTimeout = "EstablishTunnelTimeout"
  74. EstablishTunnelWorkTime = "EstablishTunnelWorkTime"
  75. EstablishTunnelPausePeriod = "EstablishTunnelPausePeriod"
  76. EstablishTunnelNoServersPausePeriod = "EstablishTunnelNoServersPausePeriod"
  77. EstablishTunnelPausePeriodJitter = "EstablishTunnelPausePeriodJitter"
  78. EstablishTunnelServerAffinityGracePeriod = "EstablishTunnelServerAffinityGracePeriod"
  79. StaggerConnectionWorkersPeriod = "StaggerConnectionWorkersPeriod"
  80. StaggerConnectionWorkersJitter = "StaggerConnectionWorkersJitter"
  81. LimitIntensiveConnectionWorkers = "LimitIntensiveConnectionWorkers"
  82. UpstreamProxyErrorMinWaitDuration = "UpstreamProxyErrorMinWaitDuration"
  83. UpstreamProxyErrorMaxWaitDuration = "UpstreamProxyErrorMaxWaitDuration"
  84. IgnoreHandshakeStatsRegexps = "IgnoreHandshakeStatsRegexps"
  85. PrioritizeTunnelProtocolsProbability = "PrioritizeTunnelProtocolsProbability"
  86. PrioritizeTunnelProtocols = "PrioritizeTunnelProtocols"
  87. PrioritizeTunnelProtocolsCandidateCount = "PrioritizeTunnelProtocolsCandidateCount"
  88. InitialLimitTunnelProtocolsProbability = "InitialLimitTunnelProtocolsProbability"
  89. InitialLimitTunnelProtocols = "InitialLimitTunnelProtocols"
  90. InitialLimitTunnelProtocolsCandidateCount = "InitialLimitTunnelProtocolsCandidateCount"
  91. LimitTunnelProtocolsProbability = "LimitTunnelProtocolsProbability"
  92. LimitTunnelProtocols = "LimitTunnelProtocols"
  93. LimitTunnelDialPortNumbersProbability = "LimitTunnelDialPortNumbersProbability"
  94. LimitTunnelDialPortNumbers = "LimitTunnelDialPortNumbers"
  95. LimitTLSProfilesProbability = "LimitTLSProfilesProbability"
  96. LimitTLSProfiles = "LimitTLSProfiles"
  97. UseOnlyCustomTLSProfiles = "UseOnlyCustomTLSProfiles"
  98. CustomTLSProfiles = "CustomTLSProfiles"
  99. SelectRandomizedTLSProfileProbability = "SelectRandomizedTLSProfileProbability"
  100. NoDefaultTLSSessionIDProbability = "NoDefaultTLSSessionIDProbability"
  101. DisableFrontingProviderTLSProfiles = "DisableFrontingProviderTLSProfiles"
  102. LimitQUICVersionsProbability = "LimitQUICVersionsProbability"
  103. LimitQUICVersions = "LimitQUICVersions"
  104. DisableFrontingProviderQUICVersions = "DisableFrontingProviderQUICVersions"
  105. QUICDialEarlyProbability = "QUICDialEarlyProbability"
  106. QUICObfuscatedPSKProbability = "QUICObfuscatedPSKProbability"
  107. QUICDisableClientPathMTUDiscoveryProbability = "QUICDisableClientPathMTUDiscoveryProbability"
  108. FragmentorProbability = "FragmentorProbability"
  109. FragmentorLimitProtocols = "FragmentorLimitProtocols"
  110. FragmentorMinTotalBytes = "FragmentorMinTotalBytes"
  111. FragmentorMaxTotalBytes = "FragmentorMaxTotalBytes"
  112. FragmentorMinWriteBytes = "FragmentorMinWriteBytes"
  113. FragmentorMaxWriteBytes = "FragmentorMaxWriteBytes"
  114. FragmentorMinDelay = "FragmentorMinDelay"
  115. FragmentorMaxDelay = "FragmentorMaxDelay"
  116. FragmentorDownstreamProbability = "FragmentorDownstreamProbability"
  117. FragmentorDownstreamLimitProtocols = "FragmentorDownstreamLimitProtocols"
  118. FragmentorDownstreamMinTotalBytes = "FragmentorDownstreamMinTotalBytes"
  119. FragmentorDownstreamMaxTotalBytes = "FragmentorDownstreamMaxTotalBytes"
  120. FragmentorDownstreamMinWriteBytes = "FragmentorDownstreamMinWriteBytes"
  121. FragmentorDownstreamMaxWriteBytes = "FragmentorDownstreamMaxWriteBytes"
  122. FragmentorDownstreamMinDelay = "FragmentorDownstreamMinDelay"
  123. FragmentorDownstreamMaxDelay = "FragmentorDownstreamMaxDelay"
  124. ObfuscatedSSHMinPadding = "ObfuscatedSSHMinPadding"
  125. ObfuscatedSSHMaxPadding = "ObfuscatedSSHMaxPadding"
  126. TunnelOperateShutdownTimeout = "TunnelOperateShutdownTimeout"
  127. TunnelPortForwardDialTimeout = "TunnelPortForwardDialTimeout"
  128. PacketTunnelReadTimeout = "PacketTunnelReadTimeout"
  129. TunnelRateLimits = "TunnelRateLimits"
  130. AdditionalCustomHeaders = "AdditionalCustomHeaders"
  131. SpeedTestPaddingMinBytes = "SpeedTestPaddingMinBytes"
  132. SpeedTestPaddingMaxBytes = "SpeedTestPaddingMaxBytes"
  133. SpeedTestMaxSampleCount = "SpeedTestMaxSampleCount"
  134. SSHKeepAliveSpeedTestSampleProbability = "SSHKeepAliveSpeedTestSampleProbability"
  135. SSHKeepAlivePaddingMinBytes = "SSHKeepAlivePaddingMinBytes"
  136. SSHKeepAlivePaddingMaxBytes = "SSHKeepAlivePaddingMaxBytes"
  137. SSHKeepAlivePeriodMin = "SSHKeepAlivePeriodMin"
  138. SSHKeepAlivePeriodMax = "SSHKeepAlivePeriodMax"
  139. SSHKeepAlivePeriodicTimeout = "SSHKeepAlivePeriodicTimeout"
  140. SSHKeepAlivePeriodicInactivePeriod = "SSHKeepAlivePeriodicInactivePeriod"
  141. SSHKeepAliveProbeTimeout = "SSHKeepAliveProbeTimeout"
  142. SSHKeepAliveProbeInactivePeriod = "SSHKeepAliveProbeInactivePeriod"
  143. SSHKeepAliveNetworkConnectivityPollingPeriod = "SSHKeepAliveNetworkConnectivityPollingPeriod"
  144. SSHKeepAliveResetOnFailureProbability = "SSHKeepAliveResetOnFailureProbability"
  145. HTTPProxyOriginServerTimeout = "HTTPProxyOriginServerTimeout"
  146. HTTPProxyMaxIdleConnectionsPerHost = "HTTPProxyMaxIdleConnectionsPerHost"
  147. FetchRemoteServerListTimeout = "FetchRemoteServerListTimeout"
  148. FetchRemoteServerListRetryPeriod = "FetchRemoteServerListRetryPeriod"
  149. FetchRemoteServerListStalePeriod = "FetchRemoteServerListStalePeriod"
  150. RemoteServerListSignaturePublicKey = "RemoteServerListSignaturePublicKey"
  151. RemoteServerListURLs = "RemoteServerListURLs"
  152. ObfuscatedServerListRootURLs = "ObfuscatedServerListRootURLs"
  153. PsiphonAPIRequestTimeout = "PsiphonAPIRequestTimeout"
  154. PsiphonAPIStatusRequestPeriodMin = "PsiphonAPIStatusRequestPeriodMin"
  155. PsiphonAPIStatusRequestPeriodMax = "PsiphonAPIStatusRequestPeriodMax"
  156. PsiphonAPIStatusRequestShortPeriodMin = "PsiphonAPIStatusRequestShortPeriodMin"
  157. PsiphonAPIStatusRequestShortPeriodMax = "PsiphonAPIStatusRequestShortPeriodMax"
  158. PsiphonAPIStatusRequestPaddingMinBytes = "PsiphonAPIStatusRequestPaddingMinBytes"
  159. PsiphonAPIStatusRequestPaddingMaxBytes = "PsiphonAPIStatusRequestPaddingMaxBytes"
  160. PsiphonAPIPersistentStatsMaxCount = "PsiphonAPIPersistentStatsMaxCount"
  161. PsiphonAPIConnectedRequestPeriod = "PsiphonAPIConnectedRequestPeriod"
  162. PsiphonAPIConnectedRequestRetryPeriod = "PsiphonAPIConnectedRequestRetryPeriod"
  163. FetchSplitTunnelRoutesTimeout = "FetchSplitTunnelRoutesTimeout"
  164. SplitTunnelRoutesURLFormat = "SplitTunnelRoutesURLFormat"
  165. SplitTunnelRoutesSignaturePublicKey = "SplitTunnelRoutesSignaturePublicKey"
  166. SplitTunnelDNSServer = "SplitTunnelDNSServer"
  167. SplitTunnelClassificationTTL = "SplitTunnelClassificationTTL"
  168. SplitTunnelClassificationMaxEntries = "SplitTunnelClassificationMaxEntries"
  169. FetchUpgradeTimeout = "FetchUpgradeTimeout"
  170. FetchUpgradeRetryPeriod = "FetchUpgradeRetryPeriod"
  171. FetchUpgradeStalePeriod = "FetchUpgradeStalePeriod"
  172. UpgradeDownloadURLs = "UpgradeDownloadURLs"
  173. UpgradeDownloadClientVersionHeader = "UpgradeDownloadClientVersionHeader"
  174. TotalBytesTransferredNoticePeriod = "TotalBytesTransferredNoticePeriod"
  175. TotalBytesTransferredEmitMemoryMetrics = "TotalBytesTransferredEmitMemoryMetrics"
  176. MeekDialDomainsOnly = "MeekDialDomainsOnly"
  177. MeekLimitBufferSizes = "MeekLimitBufferSizes"
  178. MeekCookieMaxPadding = "MeekCookieMaxPadding"
  179. MeekFullReceiveBufferLength = "MeekFullReceiveBufferLength"
  180. MeekReadPayloadChunkLength = "MeekReadPayloadChunkLength"
  181. MeekLimitedFullReceiveBufferLength = "MeekLimitedFullReceiveBufferLength"
  182. MeekLimitedReadPayloadChunkLength = "MeekLimitedReadPayloadChunkLength"
  183. MeekMinPollInterval = "MeekMinPollInterval"
  184. MeekMinPollIntervalJitter = "MeekMinPollIntervalJitter"
  185. MeekMaxPollInterval = "MeekMaxPollInterval"
  186. MeekMaxPollIntervalJitter = "MeekMaxPollIntervalJitter"
  187. MeekPollIntervalMultiplier = "MeekPollIntervalMultiplier"
  188. MeekPollIntervalJitter = "MeekPollIntervalJitter"
  189. MeekApplyPollIntervalMultiplierProbability = "MeekApplyPollIntervalMultiplierProbability"
  190. MeekRoundTripRetryDeadline = "MeekRoundTripRetryDeadline"
  191. MeekRoundTripRetryMinDelay = "MeekRoundTripRetryMinDelay"
  192. MeekRoundTripRetryMaxDelay = "MeekRoundTripRetryMaxDelay"
  193. MeekRoundTripRetryMultiplier = "MeekRoundTripRetryMultiplier"
  194. MeekRoundTripTimeout = "MeekRoundTripTimeout"
  195. MeekTrafficShapingProbability = "MeekTrafficShapingProbability"
  196. MeekTrafficShapingLimitProtocols = "MeekTrafficShapingLimitProtocols"
  197. MeekMinTLSPadding = "MeekMinTLSPadding"
  198. MeekMaxTLSPadding = "MeekMaxTLSPadding"
  199. MeekMinLimitRequestPayloadLength = "MeekMinLimitRequestPayloadLength"
  200. MeekMaxLimitRequestPayloadLength = "MeekMaxLimitRequestPayloadLength"
  201. MeekRedialTLSProbability = "MeekRedialTLSProbability"
  202. MeekAlternateCookieNameProbability = "MeekAlternateCookieNameProbability"
  203. MeekAlternateContentTypeProbability = "MeekAlternateContentTypeProbability"
  204. TransformHostNameProbability = "TransformHostNameProbability"
  205. PickUserAgentProbability = "PickUserAgentProbability"
  206. InitialLivenessTest = "InitialLivenessTest"
  207. LivenessTest = "LivenessTest"
  208. LivenessTestMinUpstreamBytes = "LivenessTestMinUpstreamBytes"
  209. LivenessTestMaxUpstreamBytes = "LivenessTestMaxUpstreamBytes"
  210. LivenessTestMinDownstreamBytes = "LivenessTestMinDownstreamBytes"
  211. LivenessTestMaxDownstreamBytes = "LivenessTestMaxDownstreamBytes"
  212. ReplayCandidateCount = "ReplayCandidateCount"
  213. ReplayDialParametersTTL = "ReplayDialParametersTTL"
  214. ReplayTargetUpstreamBytes = "ReplayTargetUpstreamBytes"
  215. ReplayTargetDownstreamBytes = "ReplayTargetDownstreamBytes"
  216. ReplayTargetTunnelDuration = "ReplayTargetTunnelDuration"
  217. ReplayLaterRoundMoveToFrontProbability = "ReplayLaterRoundMoveToFrontProbability"
  218. ReplayRetainFailedProbability = "ReplayRetainFailedProbability"
  219. ReplayIgnoreChangedConfigStateProbability = "ReplayIgnoreChangedConfigStateProbability"
  220. ReplayBPF = "ReplayBPF"
  221. ReplaySSH = "ReplaySSH"
  222. ReplayObfuscatorPadding = "ReplayObfuscatorPadding"
  223. ReplayFragmentor = "ReplayFragmentor"
  224. ReplayTLSProfile = "ReplayTLSProfile"
  225. ReplayFronting = "ReplayFronting"
  226. ReplayHostname = "ReplayHostname"
  227. ReplayQUICVersion = "ReplayQUICVersion"
  228. ReplayObfuscatedQUIC = "ReplayObfuscatedQUIC"
  229. ReplayObfuscatedQUICNonceTransformer = "ReplayObfuscatedQUICNonceTransformer"
  230. ReplayConjureRegistration = "ReplayConjureRegistration"
  231. ReplayConjureTransport = "ReplayConjureTransport"
  232. ReplayLivenessTest = "ReplayLivenessTest"
  233. ReplayUserAgent = "ReplayUserAgent"
  234. ReplayAPIRequestPadding = "ReplayAPIRequestPadding"
  235. ReplayHoldOffTunnel = "ReplayHoldOffTunnel"
  236. ReplayResolveParameters = "ReplayResolveParameters"
  237. ReplayHTTPTransformerParameters = "ReplayHTTPTransformerParameters"
  238. ReplayOSSHSeedTransformerParameters = "ReplayOSSHSeedTransformerParameters"
  239. ReplayOSSHPrefix = "ReplayOSSHPrefix"
  240. ReplayTLSFragmentClientHello = "ReplayTLSFragmentClientHello"
  241. ReplayInproxyWebRTC = "ReplayInproxyWebRTC"
  242. ReplayInproxySTUN = "ReplayInproxySTUN"
  243. APIRequestUpstreamPaddingMinBytes = "APIRequestUpstreamPaddingMinBytes"
  244. APIRequestUpstreamPaddingMaxBytes = "APIRequestUpstreamPaddingMaxBytes"
  245. APIRequestDownstreamPaddingMinBytes = "APIRequestDownstreamPaddingMinBytes"
  246. APIRequestDownstreamPaddingMaxBytes = "APIRequestDownstreamPaddingMaxBytes"
  247. PersistentStatsMaxStoreRecords = "PersistentStatsMaxStoreRecords"
  248. PersistentStatsMaxSendBytes = "PersistentStatsMaxSendBytes"
  249. RecordRemoteServerListPersistentStatsProbability = "RecordRemoteServerListPersistentStatsProbability"
  250. RecordFailedTunnelPersistentStatsProbability = "RecordFailedTunnelPersistentStatsProbability"
  251. ServerEntryMinimumAgeForPruning = "ServerEntryMinimumAgeForPruning"
  252. ApplicationParameters = "ApplicationParameters"
  253. BPFServerTCPProgram = "BPFServerTCPProgram"
  254. BPFServerTCPProbability = "BPFServerTCPProbability"
  255. BPFClientTCPProgram = "BPFClientTCPProgram"
  256. BPFClientTCPProbability = "BPFClientTCPProbability"
  257. ServerPacketManipulationSpecs = "ServerPacketManipulationSpecs"
  258. ServerProtocolPacketManipulations = "ServerProtocolPacketManipulations"
  259. ServerPacketManipulationProbability = "ServerPacketManipulationProbability"
  260. FeedbackUploadURLs = "FeedbackUploadURLs"
  261. FeedbackEncryptionPublicKey = "FeedbackEncryptionPublicKey"
  262. FeedbackTacticsWaitPeriod = "FeedbackTacticsWaitPeriod"
  263. FeedbackUploadMaxAttempts = "FeedbackUploadMaxAttempts"
  264. FeedbackUploadRetryMinDelaySeconds = "FeedbackUploadRetryMinDelaySeconds"
  265. FeedbackUploadRetryMaxDelaySeconds = "FeedbackUploadRetryMaxDelaySeconds"
  266. FeedbackUploadTimeoutSeconds = "FeedbackUploadTimeoutSeconds"
  267. ServerReplayPacketManipulation = "ServerReplayPacketManipulation"
  268. ServerReplayFragmentor = "ServerReplayFragmentor"
  269. ServerReplayUnknownGeoIP = "ServerReplayUnknownGeoIP"
  270. ServerReplayTTL = "ServerReplayTTL"
  271. ServerReplayTargetWaitDuration = "ServerReplayTargetWaitDuration"
  272. ServerReplayTargetTunnelDuration = "ServerReplayTargetTunnelDuration"
  273. ServerReplayTargetUpstreamBytes = "ServerReplayTargetUpstreamBytes"
  274. ServerReplayTargetDownstreamBytes = "ServerReplayTargetDownstreamBytes"
  275. ServerReplayFailedCountThreshold = "ServerReplayFailedCountThreshold"
  276. ServerBurstUpstreamDeadline = "ServerBurstUpstreamDeadline"
  277. ServerBurstUpstreamTargetBytes = "ServerBurstUpstreamTargetBytes"
  278. ServerBurstDownstreamDeadline = "ServerBurstDownstreamDeadline"
  279. ServerBurstDownstreamTargetBytes = "ServerBurstDownstreamTargetBytes"
  280. ClientBurstUpstreamDeadline = "ClientBurstUpstreamDeadline"
  281. ClientBurstUpstreamTargetBytes = "ClientBurstUpstreamTargetBytes"
  282. ClientBurstDownstreamDeadline = "ClientBurstDownstreamDeadline"
  283. ClientBurstDownstreamTargetBytes = "ClientBurstDownstreamTargetBytes"
  284. ConjureCachedRegistrationTTL = "ConjureCachedRegistrationTTL"
  285. ConjureAPIRegistrarURL = "ConjureAPIRegistrarURL"
  286. ConjureAPIRegistrarBidirectionalURL = "ConjureAPIRegistrarBidirectionalURL"
  287. ConjureAPIRegistrarFrontingSpecs = "ConjureAPIRegistrarFrontingSpecs"
  288. ConjureAPIRegistrarMinDelay = "ConjureAPIRegistrarMinDelay"
  289. ConjureAPIRegistrarMaxDelay = "ConjureAPIRegistrarMaxDelay"
  290. ConjureDecoyRegistrarProbability = "ConjureDecoyRegistrarProbability"
  291. ConjureDecoyRegistrarWidth = "ConjureDecoyRegistrarWidth"
  292. ConjureDecoyRegistrarMinDelay = "ConjureDecoyRegistrarMinDelay"
  293. ConjureDecoyRegistrarMaxDelay = "ConjureDecoyRegistrarMaxDelay"
  294. ConjureEnableIPv6Dials = "ConjureEnableIPv6Dials"
  295. ConjureEnablePortRandomization = "ConjureEnablePortRandomization"
  296. ConjureEnableRegistrationOverrides = "ConjureEnableRegistrationOverrides"
  297. ConjureLimitTransportsProbability = "ConjureLimitTransportsProbability"
  298. ConjureLimitTransports = "ConjureLimitTransports"
  299. ConjureSTUNServerAddresses = "ConjureSTUNServerAddresses"
  300. ConjureDTLSEmptyInitialPacketProbability = "ConjureDTLSEmptyInitialPacketProbability"
  301. CustomHostNameRegexes = "CustomHostNameRegexes"
  302. CustomHostNameProbability = "CustomHostNameProbability"
  303. CustomHostNameLimitProtocols = "CustomHostNameLimitProtocols"
  304. HoldOffTunnelMinDuration = "HoldOffTunnelMinDuration"
  305. HoldOffTunnelMaxDuration = "HoldOffTunnelMaxDuration"
  306. HoldOffTunnelProtocols = "HoldOffTunnelProtocols"
  307. HoldOffTunnelFrontingProviderIDs = "HoldOffTunnelFrontingProviderIDs"
  308. HoldOffTunnelProbability = "HoldOffTunnelProbability"
  309. HoldOffTunnelProtocolMinDuration = "HoldOffTunnelProtocolMinDuration"
  310. HoldOffTunnelProtocolMaxDuration = "HoldOffTunnelProtocolMaxDuration"
  311. HoldOffTunnelProtocolNames = "HoldOffTunnelProtocolNames"
  312. HoldOffTunnelProtocolProbability = "HoldOffTunnelProtocolProbability"
  313. HoldOffFrontingTunnelMinDuration = "HoldOffFrontingTunnelMinDuration"
  314. HoldOffFrontingTunnelMaxDuration = "HoldOffFrontingTunnelMaxDuration"
  315. HoldOffFrontingTunnelProviderIDs = "HoldOffFrontingTunnelProviderIDs"
  316. HoldOffFrontingTunnelProbability = "HoldOffFrontingTunnelProbability"
  317. RestrictFrontingProviderIDs = "RestrictFrontingProviderIDs"
  318. RestrictFrontingProviderIDsServerProbability = "RestrictFrontingProviderIDsServerProbability"
  319. RestrictFrontingProviderIDsClientProbability = "RestrictFrontingProviderIDsClientProbability"
  320. HoldOffDirectTunnelMinDuration = "HoldOffDirectTunnelMinDuration"
  321. HoldOffDirectTunnelMaxDuration = "HoldOffDirectTunnelMaxDuration"
  322. HoldOffDirectTunnelProviderRegions = "HoldOffDirectTunnelProviderRegions"
  323. HoldOffDirectTunnelProbability = "HoldOffDirectTunnelProbability"
  324. RestrictDirectProviderRegions = "RestrictDirectProviderRegions"
  325. RestrictDirectProviderIDsServerProbability = "RestrictDirectProviderIDsServerProbability"
  326. RestrictDirectProviderIDsClientProbability = "RestrictDirectProviderIDsClientProbability"
  327. HoldOffInproxyTunnelMinDuration = "HoldOffInproxyTunnelMinDuration"
  328. HoldOffInproxyTunnelMaxDuration = "HoldOffInproxyTunnelMaxDuration"
  329. HoldOffInproxyTunnelProviderRegions = "HoldOffInproxyTunnelProviderRegions"
  330. HoldOffInproxyTunnelProbability = "HoldOffInproxyTunnelProbability"
  331. RestrictInproxyProviderRegions = "RestrictInproxyProviderRegions"
  332. RestrictInproxyProviderIDsServerProbability = "RestrictInproxyProviderIDsServerProbability"
  333. RestrictInproxyProviderIDsClientProbability = "RestrictInproxyProviderIDsClientProbability"
  334. UpstreamProxyAllowAllServerEntrySources = "UpstreamProxyAllowAllServerEntrySources"
  335. DestinationBytesMetricsASNs = "DestinationBytesMetricsASNs"
  336. DNSResolverAttemptsPerServer = "DNSResolverAttemptsPerServer"
  337. DNSResolverAttemptsPerPreferredServer = "DNSResolverAttemptsPerPreferredServer"
  338. DNSResolverRequestTimeout = "DNSResolverRequestTimeout"
  339. DNSResolverAwaitTimeout = "DNSResolverAwaitTimeout"
  340. DNSResolverPreresolvedIPAddressCIDRs = "DNSResolverPreresolvedIPAddressCIDRs"
  341. DNSResolverPreresolvedIPAddressProbability = "DNSResolverPreresolvedIPAddressProbability"
  342. DNSResolverAlternateServers = "DNSResolverAlternateServers"
  343. DNSResolverPreferredAlternateServers = "DNSResolverPreferredAlternateServers"
  344. DNSResolverPreferAlternateServerProbability = "DNSResolverPreferAlternateServerProbability"
  345. DNSResolverProtocolTransformSpecs = "DNSResolverProtocolTransformSpecs"
  346. DNSResolverProtocolTransformScopedSpecNames = "DNSResolverProtocolTransformScopedSpecNames"
  347. DNSResolverProtocolTransformProbability = "DNSResolverProtocolTransformProbability"
  348. DNSResolverIncludeEDNS0Probability = "DNSResolverIncludeEDNS0Probability"
  349. DNSResolverCacheExtensionInitialTTL = "DNSResolverCacheExtensionInitialTTL"
  350. DNSResolverCacheExtensionVerifiedTTL = "DNSResolverCacheExtensionVerifiedTTL"
  351. DNSResolverQNameRandomizeCasingProbability = "DNSResolverQNameRandomizeCasingProbability"
  352. DNSResolverQNameMustMatchProbability = "DNSResolverQNameMustMatchProbability"
  353. AddFrontingProviderPsiphonFrontingHeader = "AddFrontingProviderPsiphonFrontingHeader"
  354. DirectHTTPProtocolTransformSpecs = "DirectHTTPProtocolTransformSpecs"
  355. DirectHTTPProtocolTransformScopedSpecNames = "DirectHTTPProtocolTransformScopedSpecNames"
  356. DirectHTTPProtocolTransformProbability = "DirectHTTPProtocolTransformProbability"
  357. FrontedHTTPProtocolTransformSpecs = "FrontedHTTPProtocolTransformSpecs"
  358. FrontedHTTPProtocolTransformScopedSpecNames = "FrontedHTTPProtocolTransformScopedSpecNames"
  359. FrontedHTTPProtocolTransformProbability = "FrontedHTTPProtocolTransformProbability"
  360. OSSHObfuscatorSeedTransformSpecs = "OSSHObfuscatorSeedTransformSpecs"
  361. OSSHObfuscatorSeedTransformScopedSpecNames = "OSSHObfuscatorSeedTransformScopedSpecNames"
  362. OSSHObfuscatorSeedTransformProbability = "OSSHObfuscatorSeedTransformProbability"
  363. ObfuscatedQUICNonceTransformSpecs = "ObfuscatedQUICNonceTransformSpecs"
  364. ObfuscatedQUICNonceTransformScopedSpecNames = "ObfuscatedQUICNonceTransformScopedSpecNames"
  365. ObfuscatedQUICNonceTransformProbability = "ObfuscatedQUICNonceTransformProbability"
  366. OSSHPrefixSpecs = "OSSHPrefixSpecs"
  367. OSSHPrefixScopedSpecNames = "OSSHPrefixScopedSpecNames"
  368. OSSHPrefixProbability = "OSSHPrefixProbability"
  369. OSSHPrefixSplitMinDelay = "OSSHPrefixSplitMinDelay"
  370. OSSHPrefixSplitMaxDelay = "OSSHPrefixSplitMaxDelay"
  371. OSSHPrefixEnableFragmentor = "OSSHPrefixEnableFragmentor"
  372. ServerOSSHPrefixSpecs = "ServerOSSHPrefixSpecs"
  373. ShadowsocksPrefixSpecs = "ShadowsocksPrefixSpecs"
  374. ShadowsocksPrefixScopedSpecNames = "ShadowsocksPrefixScopedSpecNames"
  375. ShadowsocksPrefixProbability = "ShadowsocksPrefixProbability"
  376. ReplayShadowsocksPrefix = "ReplayShadowsocksPrefix"
  377. TLSTunnelObfuscatedPSKProbability = "TLSTunnelObfuscatedPSKProbability"
  378. TLSTunnelTrafficShapingProbability = "TLSTunnelTrafficShapingProbability"
  379. TLSTunnelMinTLSPadding = "TLSTunnelMinTLSPadding"
  380. TLSTunnelMaxTLSPadding = "TLSTunnelMaxTLSPadding"
  381. TLSFragmentClientHelloProbability = "TLSFragmentClientHelloProbability"
  382. TLSFragmentClientHelloLimitProtocols = "TLSFragmentClientHelloLimitProtocols"
  383. SteeringIPCacheTTL = "SteeringIPCacheTTL"
  384. SteeringIPCacheMaxEntries = "SteeringIPCacheMaxEntries"
  385. SteeringIPProbability = "SteeringIPProbability"
  386. ServerDiscoveryStrategy = "ServerDiscoveryStrategy"
  387. FrontedHTTPClientReplayDialParametersTTL = "FrontedHTTPClientReplayDialParametersTTL"
  388. FrontedHTTPClientReplayUpdateFrequency = "FrontedHTTPClientReplayUpdateFrequency"
  389. FrontedHTTPClientReplayDialParametersProbability = "FrontedHTTPClientReplayDialParametersProbability"
  390. FrontedHTTPClientReplayRetainFailedProbability = "FrontedHTTPClientReplayRetainFailedProbability"
  391. InproxyAllowProxy = "InproxyAllowProxy"
  392. InproxyAllowClient = "InproxyAllowClient"
  393. InproxyAllowDomainFrontedDestinations = "InproxyAllowDomainFrontedDestinations"
  394. InproxyAllowMatchByRegion = "InproxyAllowMatchByRegion"
  395. InproxyAllowMatchByASN = "InproxyAllowMatchByASN"
  396. InproxyDisallowMatchByRegion = "InproxyDisallowMatchByRegion"
  397. InproxyDisallowMatchByASN = "InproxyDisallowMatchByASN"
  398. InproxyAllBrokerSpecs = "InproxyAllBrokerSpecs"
  399. InproxyBrokerSpecs = "InproxyBrokerSpecs"
  400. InproxyPersonalPairingBrokerSpecs = "InproxyPersonalPairingBrokerSpecs"
  401. InproxyPersonalPairingMaxBrokerSpecCount = "InproxyPersonalPairingMaxBrokerSpecCount"
  402. InproxyProxyBrokerSpecs = "InproxyProxyBrokerSpecs"
  403. InproxyProxyPersonalPairingBrokerSpecs = "InproxyProxyPersonalPairingBrokerSpecs"
  404. InproxyClientBrokerSpecs = "InproxyClientBrokerSpecs"
  405. InproxyClientPersonalPairingBrokerSpecs = "InproxyClientPersonalPairingBrokerSpecs"
  406. InproxyReplayBrokerDialParametersTTL = "InproxyReplayBrokerDialParametersTTL"
  407. InproxyReplayBrokerUpdateFrequency = "InproxyReplayBrokerUpdateFrequency"
  408. InproxyReplayBrokerDialParametersProbability = "InproxyReplayBrokerDialParametersProbability"
  409. InproxyReplayBrokerRetainFailedProbability = "InproxyReplayBrokerRetainFailedProbability"
  410. InproxyAllCommonCompartmentIDs = "InproxyAllCommonCompartmentIDs"
  411. InproxyCommonCompartmentIDs = "InproxyCommonCompartmentIDs"
  412. InproxyMaxCompartmentIDListLength = "InproxyMaxCompartmentIDListLength"
  413. InproxyBrokerMatcherAnnouncementLimitEntryCount = "InproxyBrokerMatcherAnnouncementLimitEntryCount"
  414. InproxyBrokerMatcherAnnouncementRateLimitQuantity = "InproxyBrokerMatcherAnnouncementRateLimitQuantity"
  415. InproxyBrokerMatcherAnnouncementRateLimitInterval = "InproxyBrokerMatcherAnnouncementRateLimitInterval"
  416. InproxyBrokerMatcherAnnouncementNonlimitedProxyIDs = "InproxyBrokerMatcherAnnouncementNonlimitedProxyIDs"
  417. InproxyBrokerMatcherOfferLimitEntryCount = "InproxyBrokerMatcherOfferLimitEntryCount"
  418. InproxyBrokerMatcherOfferRateLimitQuantity = "InproxyBrokerMatcherOfferRateLimitQuantity"
  419. InproxyBrokerMatcherOfferRateLimitInterval = "InproxyBrokerMatcherOfferRateLimitInterval"
  420. InproxyBrokerMatcherPrioritizeProxiesProbability = "InproxyBrokerMatcherPrioritizeProxiesProbability"
  421. InproxyBrokerMatcherPrioritizeProxiesFilter = "InproxyBrokerMatcherPrioritizeProxiesFilter"
  422. InproxyBrokerMatcherPrioritizeProxiesMinVersion = "InproxyBrokerMatcherPrioritizeProxiesMinVersion"
  423. InproxyBrokerProxyAnnounceTimeout = "InproxyBrokerProxyAnnounceTimeout"
  424. InproxyBrokerClientOfferTimeout = "InproxyBrokerClientOfferTimeout"
  425. InproxyBrokerClientOfferPersonalTimeout = "InproxyBrokerClientOfferPersonalTimeout"
  426. InproxyBrokerPendingServerRequestsTTL = "InproxyBrokerPendingServerRequestsTTL"
  427. InproxyBrokerDSLRequestRateLimitQuantity = "InproxyBrokerDSLRequestRateLimitQuantity"
  428. InproxyBrokerDSLRequestRateLimitInterval = "InproxyBrokerDSLRequestRateLimitInterval"
  429. InproxySessionHandshakeRoundTripTimeout = "InproxySessionHandshakeRoundTripTimeout"
  430. InproxyProxyAnnounceRequestTimeout = "InproxyProxyAnnounceRequestTimeout"
  431. InproxyProxyAnnounceDelay = "InproxyProxyAnnounceDelay"
  432. InproxyProxyAnnounceDelayJitter = "InproxyProxyAnnounceDelayJitter"
  433. InproxyProxyAnnounceMaxBackoffDelay = "InproxyProxyAnnounceMaxBackoffDelay"
  434. InproxyProxyAnswerRequestTimeout = "InproxyProxyAnswerRequestTimeout"
  435. InproxyClientOfferRequestTimeout = "InproxyClientOfferRequestTimeout"
  436. InproxyClientOfferRequestPersonalTimeout = "InproxyClientOfferRequestPersonalTimeout"
  437. InproxyClientOfferRetryDelay = "InproxyClientOfferRetryDelay"
  438. InproxyClientOfferRetryJitter = "InproxyClientOfferRetryJitter"
  439. InproxyClientRelayedPacketRequestTimeout = "InproxyClientRelayedPacketRequestTimeout"
  440. InproxyClientDSLRequestTimeout = "InproxyClientDSLRequestTimeout"
  441. InproxyBrokerRoundTripStatusCodeFailureThreshold = "InproxyBrokerRoundTripStatusCodeFailureThreshold"
  442. InproxyDTLSRandomizationProbability = "InproxyDTLSRandomizationProbability"
  443. InproxyWebRTCMediaStreamsProbability = "InproxyWebRTCMediaStreamsProbability"
  444. InproxyWebRTCDataChannelTrafficShapingProbability = "InproxyWebRTCDataChannelTrafficShapingProbability"
  445. InproxyWebRTCDataChannelTrafficShapingParameters = "InproxyWebRTCDataChannelTrafficShapingParameters"
  446. InproxyWebRTCMediaStreamsTrafficShapingProbability = "InproxyWebRTCMediaStreamsTrafficShapingProbability"
  447. InproxyWebRTCMediaStreamsTrafficShapingParameters = "InproxyWebRTCMediaStreamsTrafficShapingParameters"
  448. InproxySTUNServerAddresses = "InproxySTUNServerAddresses"
  449. InproxySTUNServerAddressesRFC5780 = "InproxySTUNServerAddressesRFC5780"
  450. InproxyProxySTUNServerAddresses = "InproxyProxySTUNServerAddresses"
  451. InproxyProxySTUNServerAddressesRFC5780 = "InproxyProxySTUNServerAddressesRFC5780"
  452. InproxyClientSTUNServerAddresses = "InproxyClientSTUNServerAddresses"
  453. InproxyClientSTUNServerAddressesRFC5780 = "InproxyClientSTUNServerAddressesRFC5780"
  454. InproxyClientDiscoverNATProbability = "InproxyClientDiscoverNATProbability"
  455. InproxyDisableSTUN = "InproxyDisableSTUN"
  456. InproxyDisablePortMapping = "InproxyDisablePortMapping"
  457. InproxyDisableInboundForMobileNetworks = "InproxyDisableInboundForMobileNetworks"
  458. InproxyDisableIPv6ICECandidates = "InproxyDisableIPv6ICECandidates"
  459. InproxyProxyDisableSTUN = "InproxyProxyDisableSTUN"
  460. InproxyProxyDisablePortMapping = "InproxyProxyDisablePortMapping"
  461. InproxyProxyDisableInboundForMobileNetworks = "InproxyProxyDisableInboundForMobileNetworks"
  462. InproxyProxyDisableIPv6ICECandidates = "InproxyProxyDisableIPv6ICECandidates"
  463. InproxyClientDisableSTUN = "InproxyClientDisableSTUN"
  464. InproxyClientDisablePortMapping = "InproxyClientDisablePortMapping"
  465. InproxyClientDisableInboundForMobileNetworks = "InproxyClientDisableInboundForMobileNetworks"
  466. InproxyClientDisableIPv6ICECandidates = "InproxyClientDisableIPv6ICECandidates"
  467. InproxyProxyDiscoverNATTimeout = "InproxyProxyDiscoverNATTimeout"
  468. InproxyClientDiscoverNATTimeout = "InproxyClientDiscoverNATTimeout"
  469. InproxyWebRTCAnswerTimeout = "InproxyWebRTCAnswerTimeout"
  470. InproxyWebRTCAwaitPortMappingTimeout = "InproxyWebRTCAwaitPortMappingTimeout"
  471. InproxyProxyWebRTCAwaitReadyToProxyTimeout = "InproxyProxyWebRTCAwaitReadyToProxyTimeout"
  472. InproxyClientWebRTCAwaitReadyToProxyTimeout = "InproxyClientWebRTCAwaitReadyToProxyTimeout"
  473. InproxyProxyDestinationDialTimeout = "InproxyProxyDestinationDialTimeout"
  474. InproxyProxyRelayInactivityTimeout = "InproxyProxyRelayInactivityTimeout"
  475. InproxyPsiphonAPIRequestTimeout = "InproxyPsiphonAPIRequestTimeout"
  476. InproxyProxyTotalActivityNoticePeriod = "InproxyProxyTotalActivityNoticePeriod"
  477. InproxyPersonalPairingConnectionWorkerPoolSize = "InproxyPersonalPairingConnectionWorkerPoolSize"
  478. InproxyClientDialRateLimitQuantity = "InproxyClientDialRateLimitQuantity"
  479. InproxyClientDialRateLimitInterval = "InproxyClientDialRateLimitInterval"
  480. InproxyClientNoMatchFailoverProbability = "InproxyClientNoMatchFailoverProbability"
  481. InproxyClientNoMatchFailoverPersonalProbability = "InproxyClientNoMatchFailoverPersonalProbability"
  482. InproxyFrontingProviderClientMaxRequestTimeouts = "InproxyFrontingProviderClientMaxRequestTimeouts"
  483. InproxyFrontingProviderServerMaxRequestTimeouts = "InproxyFrontingProviderServerMaxRequestTimeouts"
  484. InproxyProxyOnBrokerClientFailedRetryPeriod = "InproxyProxyOnBrokerClientFailedRetryPeriod"
  485. InproxyProxyIncompatibleNetworkTypes = "InproxyProxyIncompatibleNetworkTypes"
  486. InproxyClientIncompatibleNetworkTypes = "InproxyClientIncompatibleNetworkTypes"
  487. InproxyReplayRetainFailedProbability = "InproxyReplayRetainFailedProbability"
  488. InproxyProxyDisableWaitToShareSession = "InproxyProxyDisableWaitToShareSession"
  489. InproxyClientDisableWaitToShareSession = "InproxyClientDisableWaitToShareSession"
  490. InproxyTunnelProtocolPreferProbability = "InproxyTunnelProtocolPreferProbability"
  491. InproxyTunnelProtocolForceSelectionCount = "InproxyTunnelProtocolForceSelectionCount"
  492. InproxyEnableProxyQuality = "InproxyEnableProxyQuality"
  493. InproxyEnableProxyQualityClientRegions = "InproxyEnableProxyQualityClientRegions"
  494. InproxyProxyQualityTargetUpstreamBytes = "InproxyProxyQualityTargetUpstreamBytes"
  495. InproxyProxyQualityTargetDownstreamBytes = "InproxyProxyQualityTargetDownstreamBytes"
  496. InproxyProxyQualityTargetDuration = "InproxyProxyQualityTargetDuration"
  497. InproxyProxyQualityReporterTrustedCACertificates = "InproxyProxyQualityReporterTrustedCACertificates"
  498. InproxyProxyQualityReporterAdditionalHeaders = "InproxyProxyQualityReporterAdditionalHeaders"
  499. InproxyProxyQualityReporterMaxRequestEntries = "InproxyProxyQualityReporterMaxRequestEntries"
  500. InproxyProxyQualityReporterRequestDelay = "InproxyProxyQualityReporterRequestDelay"
  501. InproxyProxyQualityReporterRequestTimeout = "InproxyProxyQualityReporterRequestTimeout"
  502. InproxyProxyQualityReporterRequestRetries = "InproxyProxyQualityReporterRequestRetries"
  503. InproxyProxyQualityTTL = "InproxyProxyQualityTTL"
  504. InproxyProxyQualityPendingFailedMatchDeadline = "InproxyProxyQualityPendingFailedMatchDeadline"
  505. InproxyProxyQualityFailedMatchThreshold = "InproxyProxyQualityFailedMatchThreshold"
  506. NetworkIDCacheTTL = "NetworkIDCacheTTL"
  507. ServerDNSResolverCacheMaxSize = "ServerDNSResolverCacheMaxSize"
  508. ServerDNSResolverCacheTTL = "ServerDNSResolverCacheTTL"
  509. CheckServerEntryTagsEnabled = "CheckServerEntryTagsEnabled"
  510. CheckServerEntryTagsPeriod = "CheckServerEntryTagsPeriod"
  511. CheckServerEntryTagsRepeatRatio = "CheckServerEntryTagsRepeatRatio"
  512. CheckServerEntryTagsRepeatMinimum = "CheckServerEntryTagsRepeatMinimum"
  513. CheckServerEntryTagsMaxSendBytes = "CheckServerEntryTagsMaxSendBytes"
  514. CheckServerEntryTagsMaxWorkTime = "CheckServerEntryTagsMaxWorkTime"
  515. ServerEntryPruneDialPortNumberZero = "ServerEntryPruneDialPortNumberZero"
  516. CompressTactics = "CompressTactics"
  517. DSLRelayServiceAddress = "DSLRelayServiceAddress"
  518. DSLRelayMaxHttpConns = "DSLRelayMaxHttpConns"
  519. DSLRelayMaxHttpIdleConns = "DSLRelayMaxHttpIdleConns"
  520. DSLRelayHttpIdleConnTimeout = "DSLRelayHttpIdleConnTimeout"
  521. DSLRelayRequestTimeout = "DSLRelayRequestTimeout"
  522. DSLRelayRetryCount = "DSLRelayRetryCount"
  523. DSLRelayCacheTTL = "DSLRelayCacheTTL"
  524. DSLRelayCacheMaxSize = "DSLRelayCacheMaxSize"
  525. EnableDSLFetcher = "EnableDSLFetcher"
  526. DSLFetcherTunneledRequestTimeout = "DSLFetcherTunneledRequestTimeout"
  527. DSLFetcherTunneledRequestRetryCount = "DSLFetcherTunneledRequestRetryCount"
  528. DSLFetcherTunneledRequestRetryDelay = "DSLFetcherTunneledRequestRetryDelay"
  529. DSLFetcherTunneledRequestRetryDelayJitter = "DSLFetcherTunneledRequestRetryDelayJitter"
  530. DSLFetcherTunneledFetchTTL = "DSLFetcherTunneledFetchTTL"
  531. DSLFetcherTunneledDiscoverServerEntriesMinCount = "DSLFetcherTunneledDiscoverServerEntriesMinCount"
  532. DSLFetcherTunneledDiscoverServerEntriesMaxCount = "DSLFetcherTunneledDiscoverServerEntriesMaxCount"
  533. DSLFetcherTunneledGetServerEntriesMinCount = "DSLFetcherTunneledGetServerEntriesMinCount"
  534. DSLFetcherTunneledGetServerEntriesMaxCount = "DSLFetcherTunneledGetServerEntriesMaxCount"
  535. DSLFetcherUntunneledRequestTimeout = "DSLFetcherUntunneledRequestTimeout"
  536. DSLFetcherUntunneledRequestRetryCount = "DSLFetcherUntunneledRequestRetryCount"
  537. DSLFetcherUntunneledRequestRetryDelay = "DSLFetcherUntunneledRequestRetryDelay"
  538. DSLFetcherUntunneledRequestRetryDelayJitter = "DSLFetcherUntunneledRequestRetryDelayJitter"
  539. DSLFetcherUntunneledFetchTTL = "DSLFetcherUntunneledFetchTTL"
  540. DSLFetcherUntunneledDiscoverServerEntriesMinCount = "DSLFetcherUntunneledDiscoverServerEntriesMinCount"
  541. DSLFetcherUntunneledDiscoverServerEntriesMaxCount = "DSLFetcherUntunneledDiscoverServerEntriesMaxCount"
  542. DSLFetcherUntunneledGetServerEntriesMinCount = "DSLFetcherUntunneledGetServerEntriesMinCount"
  543. DSLFetcherUntunneledGetServerEntriesMaxCount = "DSLFetcherUntunneledGetServerEntriesMaxCount"
  544. DSLFetcherGetLastActiveOSLsTTL = "DSLFetcherGetLastActiveOSLsTTL"
  545. DSLFetcherGetOSLFileSpecsMinCount = "DSLFetcherGetOSLFileSpecsMinCount"
  546. DSLFetcherGetOSLFileSpecsMaxCount = "DSLFetcherGetOSLFileSpecsMaxCount"
  547. DSLPrioritizeDialNewServerEntryProbability = "DSLPrioritizeDialNewServerEntryProbability"
  548. DSLPrioritizeDialExistingServerEntryProbability = "DSLPrioritizeDialExistingServerEntryProbability"
  549. DSLPrioritizeDialRetainFailedProbability = "DSLPrioritizeDialRetainFailedProbability"
  550. DSLPrioritizeDialPlaceholderTTL = "DSLPrioritizeDialPlaceholderTTL"
  551. ServerEntryIteratorMaxMoveToFront = "ServerEntryIteratorMaxMoveToFront"
  552. ServerEntryIteratorResetProbability = "ServerEntryIteratorResetProbability"
  553. // Retired parameters
  554. ReplayRandomizedTLSProfile = "ReplayRandomizedTLSProfile"
  555. InproxyAllBrokerPublicKeys = "InproxyAllBrokerPublicKeys"
  556. InproxyTunnelProtocolSelectionProbability = "InproxyTunnelProtocolSelectionProbability"
  557. ReplayIgnoreChangedConfigState = "ReplayIgnoreChangedConfigState"
  558. DestinationBytesMetricsASN = "DestinationBytesMetricsASN"
  559. )
  560. const (
  561. useNetworkLatencyMultiplier = 1
  562. serverSideOnly = 2
  563. )
  564. // defaultParameters specifies the type, default value, and minimum value for
  565. // all dynamically configurable client and server parameters.
  566. //
  567. // Do not change the names or types of existing values, as that can break
  568. // client logic or cause parameters to not be applied.
  569. //
  570. // Minimum values are a fail-safe for cases where lower values would break the
  571. // client logic. For example, setting a ConnectionWorkerPoolSize of 0 would
  572. // make the client never connect.
  573. var defaultParameters = map[string]struct {
  574. value interface{}
  575. minimum interface{}
  576. flags int32
  577. }{
  578. // NetworkLatencyMultiplier defaults to 0, meaning off. But when set, it
  579. // must be a multiplier >= 1.
  580. NetworkLatencyMultiplier: {value: 0.0, minimum: 1.0},
  581. NetworkLatencyMultiplierMin: {value: 1.0, minimum: 1.0},
  582. NetworkLatencyMultiplierMax: {value: 3.0, minimum: 1.0},
  583. NetworkLatencyMultiplierLambda: {value: 2.0, minimum: 0.001},
  584. TacticsWaitPeriod: {value: 10 * time.Second, minimum: 0 * time.Second, flags: useNetworkLatencyMultiplier},
  585. TacticsRetryPeriod: {value: 5 * time.Second, minimum: 1 * time.Millisecond},
  586. TacticsRetryPeriodJitter: {value: 0.3, minimum: 0.0},
  587. TacticsTimeout: {value: 2 * time.Minute, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  588. ConnectionWorkerPoolSize: {value: 10, minimum: 1},
  589. TunnelPoolSize: {value: 1, minimum: 1},
  590. TunnelConnectTimeout: {value: 20 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  591. EstablishTunnelTimeout: {value: 300 * time.Second, minimum: time.Duration(0)},
  592. EstablishTunnelWorkTime: {value: 60 * time.Second, minimum: 1 * time.Second},
  593. EstablishTunnelPausePeriod: {value: 2 * time.Second, minimum: 1 * time.Millisecond},
  594. EstablishTunnelNoServersPausePeriod: {value: 250 * time.Millisecond, minimum: 1 * time.Millisecond},
  595. EstablishTunnelPausePeriodJitter: {value: 0.1, minimum: 0.0},
  596. EstablishTunnelServerAffinityGracePeriod: {value: 1 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  597. StaggerConnectionWorkersPeriod: {value: time.Duration(0), minimum: time.Duration(0)},
  598. StaggerConnectionWorkersJitter: {value: 0.1, minimum: 0.0},
  599. LimitIntensiveConnectionWorkers: {value: 0, minimum: 0},
  600. UpstreamProxyErrorMinWaitDuration: {value: 10 * time.Second, minimum: time.Duration(0)},
  601. UpstreamProxyErrorMaxWaitDuration: {value: 30 * time.Second, minimum: time.Duration(0)},
  602. IgnoreHandshakeStatsRegexps: {value: false},
  603. TunnelOperateShutdownTimeout: {value: 1 * time.Second, minimum: 1 * time.Millisecond, flags: useNetworkLatencyMultiplier},
  604. TunnelPortForwardDialTimeout: {value: 10 * time.Second, minimum: 1 * time.Millisecond, flags: useNetworkLatencyMultiplier},
  605. PacketTunnelReadTimeout: {value: 10 * time.Second, minimum: 1 * time.Millisecond, flags: useNetworkLatencyMultiplier},
  606. TunnelRateLimits: {value: common.RateLimits{}},
  607. // PrioritizeTunnelProtocols parameters are obsoleted by InitialLimitTunnelProtocols.
  608. // TODO: remove once no longer required for older clients.
  609. PrioritizeTunnelProtocolsProbability: {value: 1.0, minimum: 0.0},
  610. PrioritizeTunnelProtocols: {value: protocol.TunnelProtocols{}},
  611. PrioritizeTunnelProtocolsCandidateCount: {value: 10, minimum: 0},
  612. InitialLimitTunnelProtocolsProbability: {value: 1.0, minimum: 0.0},
  613. InitialLimitTunnelProtocols: {value: protocol.TunnelProtocols{}},
  614. InitialLimitTunnelProtocolsCandidateCount: {value: 0, minimum: 0},
  615. LimitTunnelProtocolsProbability: {value: 1.0, minimum: 0.0},
  616. LimitTunnelProtocols: {value: protocol.TunnelProtocols{}},
  617. LimitTunnelDialPortNumbersProbability: {value: 1.0, minimum: 0.0},
  618. LimitTunnelDialPortNumbers: {value: TunnelProtocolPortLists{}},
  619. LimitTLSProfilesProbability: {value: 1.0, minimum: 0.0},
  620. LimitTLSProfiles: {value: protocol.TLSProfiles{}},
  621. UseOnlyCustomTLSProfiles: {value: false},
  622. CustomTLSProfiles: {value: protocol.CustomTLSProfiles{}},
  623. SelectRandomizedTLSProfileProbability: {value: 0.25, minimum: 0.0},
  624. NoDefaultTLSSessionIDProbability: {value: 0.5, minimum: 0.0},
  625. DisableFrontingProviderTLSProfiles: {value: protocol.LabeledTLSProfiles{}},
  626. LimitQUICVersionsProbability: {value: 1.0, minimum: 0.0},
  627. LimitQUICVersions: {value: protocol.QUICVersions{}},
  628. DisableFrontingProviderQUICVersions: {value: protocol.LabeledQUICVersions{}},
  629. QUICDialEarlyProbability: {value: 1.0, minimum: 0.0},
  630. QUICObfuscatedPSKProbability: {value: 0.5, minimum: 0.0},
  631. QUICDisableClientPathMTUDiscoveryProbability: {value: 0.0, minimum: 0.0},
  632. FragmentorProbability: {value: 0.5, minimum: 0.0},
  633. FragmentorLimitProtocols: {value: protocol.TunnelProtocols{}},
  634. FragmentorMinTotalBytes: {value: 0, minimum: 0},
  635. FragmentorMaxTotalBytes: {value: 0, minimum: 0},
  636. FragmentorMinWriteBytes: {value: 1, minimum: 1},
  637. FragmentorMaxWriteBytes: {value: 1500, minimum: 1},
  638. FragmentorMinDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  639. FragmentorMaxDelay: {value: 10 * time.Millisecond, minimum: time.Duration(0)},
  640. FragmentorDownstreamProbability: {value: 0.5, minimum: 0.0, flags: serverSideOnly},
  641. FragmentorDownstreamLimitProtocols: {value: protocol.TunnelProtocols{}, flags: serverSideOnly},
  642. FragmentorDownstreamMinTotalBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  643. FragmentorDownstreamMaxTotalBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  644. FragmentorDownstreamMinWriteBytes: {value: 1, minimum: 1, flags: serverSideOnly},
  645. FragmentorDownstreamMaxWriteBytes: {value: 1500, minimum: 1, flags: serverSideOnly},
  646. FragmentorDownstreamMinDelay: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  647. FragmentorDownstreamMaxDelay: {value: 10 * time.Millisecond, minimum: time.Duration(0), flags: serverSideOnly},
  648. // The Psiphon server will reject obfuscated SSH seed messages with
  649. // padding greater than OBFUSCATE_MAX_PADDING.
  650. // obfuscator.NewClientObfuscator will ignore invalid min/max padding
  651. // configurations.
  652. ObfuscatedSSHMinPadding: {value: 0, minimum: 0},
  653. ObfuscatedSSHMaxPadding: {value: obfuscator.OBFUSCATE_MAX_PADDING, minimum: 0},
  654. AdditionalCustomHeaders: {value: make(http.Header)},
  655. // Speed test and SSH keep alive padding is intended to frustrate
  656. // fingerprinting and should not exceed ~1 IP packet size.
  657. //
  658. // Currently, each serialized speed test sample, populated with real
  659. // values, is approximately 100 bytes. All SpeedTestMaxSampleCount samples
  660. // are loaded into memory are sent as API inputs.
  661. SpeedTestPaddingMinBytes: {value: 0, minimum: 0},
  662. SpeedTestPaddingMaxBytes: {value: 256, minimum: 0},
  663. SpeedTestMaxSampleCount: {value: 5, minimum: 1},
  664. // The Psiphon server times out inactive tunnels after 5 minutes, so this
  665. // is a soft max for SSHKeepAlivePeriodMax.
  666. SSHKeepAliveSpeedTestSampleProbability: {value: 0.5, minimum: 0.0},
  667. SSHKeepAlivePaddingMinBytes: {value: 0, minimum: 0},
  668. SSHKeepAlivePaddingMaxBytes: {value: 256, minimum: 0},
  669. SSHKeepAlivePeriodMin: {value: 1 * time.Minute, minimum: 1 * time.Second},
  670. SSHKeepAlivePeriodMax: {value: 2 * time.Minute, minimum: 1 * time.Second},
  671. SSHKeepAlivePeriodicTimeout: {value: 30 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  672. SSHKeepAlivePeriodicInactivePeriod: {value: 10 * time.Second, minimum: 1 * time.Second},
  673. SSHKeepAliveProbeTimeout: {value: 5 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  674. SSHKeepAliveProbeInactivePeriod: {value: 10 * time.Second, minimum: 1 * time.Second},
  675. SSHKeepAliveNetworkConnectivityPollingPeriod: {value: 500 * time.Millisecond, minimum: 1 * time.Millisecond},
  676. SSHKeepAliveResetOnFailureProbability: {value: 0.0, minimum: 0.0},
  677. HTTPProxyOriginServerTimeout: {value: 15 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  678. HTTPProxyMaxIdleConnectionsPerHost: {value: 50, minimum: 0},
  679. FetchRemoteServerListTimeout: {value: 30 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  680. FetchRemoteServerListRetryPeriod: {value: 30 * time.Second, minimum: 1 * time.Millisecond},
  681. FetchRemoteServerListStalePeriod: {value: 6 * time.Hour, minimum: 1 * time.Hour},
  682. RemoteServerListSignaturePublicKey: {value: ""},
  683. RemoteServerListURLs: {value: TransferURLs{}},
  684. ObfuscatedServerListRootURLs: {value: TransferURLs{}},
  685. PsiphonAPIRequestTimeout: {value: 10 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  686. PsiphonAPIStatusRequestPeriodMin: {value: 5 * time.Minute, minimum: 1 * time.Second},
  687. PsiphonAPIStatusRequestPeriodMax: {value: 10 * time.Minute, minimum: 1 * time.Second},
  688. PsiphonAPIStatusRequestShortPeriodMin: {value: 5 * time.Second, minimum: 1 * time.Second},
  689. PsiphonAPIStatusRequestShortPeriodMax: {value: 10 * time.Second, minimum: 1 * time.Second},
  690. // PsiphonAPIPersistentStatsMaxCount parameter is obsoleted by PersistentStatsMaxSendBytes.
  691. // TODO: remove once no longer required for older clients.
  692. PsiphonAPIPersistentStatsMaxCount: {value: 100, minimum: 1},
  693. // PsiphonAPIStatusRequestPadding parameters are obsoleted by APIRequestUp/DownstreamPadding.
  694. // TODO: remove once no longer required for older clients.
  695. PsiphonAPIStatusRequestPaddingMinBytes: {value: 0, minimum: 0},
  696. PsiphonAPIStatusRequestPaddingMaxBytes: {value: 256, minimum: 0},
  697. PsiphonAPIConnectedRequestRetryPeriod: {value: 5 * time.Second, minimum: 1 * time.Millisecond},
  698. // FetchSplitTunnelRoutesTimeout, SplitTunnelRoutesURLFormat,
  699. // SplitTunnelRoutesSignaturePublicKey and SplitTunnelDNSServer are obsoleted
  700. // by the server-assisted split tunnel implementation.
  701. // TODO: remove once no longer required for older clients.
  702. FetchSplitTunnelRoutesTimeout: {value: 60 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  703. SplitTunnelRoutesURLFormat: {value: ""},
  704. SplitTunnelRoutesSignaturePublicKey: {value: ""},
  705. SplitTunnelDNSServer: {value: ""},
  706. SplitTunnelClassificationTTL: {value: 24 * time.Hour, minimum: 0 * time.Second},
  707. SplitTunnelClassificationMaxEntries: {value: 65536, minimum: 0},
  708. FetchUpgradeTimeout: {value: 60 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  709. FetchUpgradeRetryPeriod: {value: 30 * time.Second, minimum: 1 * time.Millisecond},
  710. FetchUpgradeStalePeriod: {value: 6 * time.Hour, minimum: 1 * time.Hour},
  711. UpgradeDownloadURLs: {value: TransferURLs{}},
  712. UpgradeDownloadClientVersionHeader: {value: ""},
  713. TotalBytesTransferredNoticePeriod: {value: 5 * time.Minute, minimum: 1 * time.Second},
  714. TotalBytesTransferredEmitMemoryMetrics: {value: true},
  715. // The meek server times out inactive sessions after 45 seconds, so this
  716. // is a soft max for MeekMaxPollInterval, MeekRoundTripTimeout, and
  717. // MeekRoundTripRetryDeadline.
  718. //
  719. // MeekCookieMaxPadding cannot exceed common.OBFUSCATE_SEED_LENGTH.
  720. //
  721. // MeekMinTLSPadding/MeekMaxTLSPadding are subject to TLS server limitations.
  722. //
  723. // MeekMinLimitRequestPayloadLength/MeekMaxLimitRequestPayloadLength
  724. // cannot exceed server.MEEK_MAX_REQUEST_PAYLOAD_LENGTH.
  725. MeekDialDomainsOnly: {value: false},
  726. MeekLimitBufferSizes: {value: false},
  727. MeekCookieMaxPadding: {value: 256, minimum: 0},
  728. MeekFullReceiveBufferLength: {value: 4194304, minimum: 1024},
  729. MeekReadPayloadChunkLength: {value: 65536, minimum: 1024},
  730. MeekLimitedFullReceiveBufferLength: {value: 131072, minimum: 1024},
  731. MeekLimitedReadPayloadChunkLength: {value: 4096, minimum: 1024},
  732. MeekMinPollInterval: {value: 100 * time.Millisecond, minimum: 1 * time.Millisecond},
  733. MeekMinPollIntervalJitter: {value: 0.3, minimum: 0.0},
  734. MeekMaxPollInterval: {value: 5 * time.Second, minimum: 1 * time.Millisecond},
  735. MeekMaxPollIntervalJitter: {value: 0.1, minimum: 0.0},
  736. MeekPollIntervalMultiplier: {value: 1.5, minimum: 0.0},
  737. MeekPollIntervalJitter: {value: 0.1, minimum: 0.0},
  738. MeekApplyPollIntervalMultiplierProbability: {value: 0.5},
  739. MeekRoundTripRetryDeadline: {value: 5 * time.Second, minimum: 1 * time.Millisecond, flags: useNetworkLatencyMultiplier},
  740. MeekRoundTripRetryMinDelay: {value: 50 * time.Millisecond, minimum: time.Duration(0)},
  741. MeekRoundTripRetryMaxDelay: {value: 1 * time.Second, minimum: time.Duration(0)},
  742. MeekRoundTripRetryMultiplier: {value: 2.0, minimum: 0.0},
  743. MeekRoundTripTimeout: {value: 20 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  744. MeekTrafficShapingProbability: {value: 1.0, minimum: 0.0},
  745. MeekTrafficShapingLimitProtocols: {value: protocol.TunnelProtocols{}},
  746. MeekMinTLSPadding: {value: 0, minimum: 0},
  747. MeekMaxTLSPadding: {value: 0, minimum: 0},
  748. MeekMinLimitRequestPayloadLength: {value: 65536, minimum: 1},
  749. MeekMaxLimitRequestPayloadLength: {value: 65536, minimum: 1},
  750. MeekRedialTLSProbability: {value: 0.0, minimum: 0.0},
  751. MeekAlternateCookieNameProbability: {value: 0.5, minimum: 0.0},
  752. MeekAlternateContentTypeProbability: {value: 0.5, minimum: 0.0},
  753. TransformHostNameProbability: {value: 0.5, minimum: 0.0},
  754. PickUserAgentProbability: {value: 0.5, minimum: 0.0},
  755. InitialLivenessTest: {value: make(LivenessTestSpecs)},
  756. LivenessTest: {value: make(LivenessTestSpecs)},
  757. LivenessTestMinUpstreamBytes: {value: 0, minimum: 0},
  758. LivenessTestMaxUpstreamBytes: {value: 0, minimum: 0},
  759. LivenessTestMinDownstreamBytes: {value: 0, minimum: 0},
  760. LivenessTestMaxDownstreamBytes: {value: 0, minimum: 0},
  761. ReplayCandidateCount: {value: 10, minimum: -1},
  762. ReplayDialParametersTTL: {value: 24 * time.Hour, minimum: time.Duration(0)},
  763. ReplayTargetUpstreamBytes: {value: 0, minimum: 0},
  764. ReplayTargetDownstreamBytes: {value: 0, minimum: 0},
  765. ReplayTargetTunnelDuration: {value: 1 * time.Second, minimum: time.Duration(0)},
  766. ReplayLaterRoundMoveToFrontProbability: {value: 0.0, minimum: 0.0},
  767. ReplayRetainFailedProbability: {value: 0.5, minimum: 0.0},
  768. ReplayIgnoreChangedConfigState: {value: false},
  769. ReplayIgnoreChangedConfigStateProbability: {value: 0.0, minimum: 0.0},
  770. ReplayBPF: {value: true},
  771. ReplaySSH: {value: true},
  772. ReplayObfuscatorPadding: {value: true},
  773. ReplayFragmentor: {value: true},
  774. ReplayTLSProfile: {value: true},
  775. ReplayFronting: {value: true},
  776. ReplayHostname: {value: true},
  777. ReplayQUICVersion: {value: true},
  778. ReplayObfuscatedQUIC: {value: true},
  779. ReplayObfuscatedQUICNonceTransformer: {value: true},
  780. ReplayConjureRegistration: {value: true},
  781. ReplayConjureTransport: {value: true},
  782. ReplayLivenessTest: {value: true},
  783. ReplayUserAgent: {value: true},
  784. ReplayAPIRequestPadding: {value: true},
  785. ReplayHoldOffTunnel: {value: true},
  786. ReplayResolveParameters: {value: true},
  787. ReplayHTTPTransformerParameters: {value: true},
  788. ReplayOSSHSeedTransformerParameters: {value: true},
  789. ReplayOSSHPrefix: {value: true},
  790. ReplayShadowsocksPrefix: {value: true},
  791. ReplayTLSFragmentClientHello: {value: true},
  792. ReplayInproxyWebRTC: {value: true},
  793. ReplayInproxySTUN: {value: true},
  794. APIRequestUpstreamPaddingMinBytes: {value: 0, minimum: 0},
  795. APIRequestUpstreamPaddingMaxBytes: {value: 1024, minimum: 0},
  796. APIRequestDownstreamPaddingMinBytes: {value: 0, minimum: 0},
  797. APIRequestDownstreamPaddingMaxBytes: {value: 1024, minimum: 0},
  798. PersistentStatsMaxStoreRecords: {value: 200, minimum: 1},
  799. PersistentStatsMaxSendBytes: {value: 65536, minimum: 1},
  800. RecordRemoteServerListPersistentStatsProbability: {value: 1.0, minimum: 0.0},
  801. RecordFailedTunnelPersistentStatsProbability: {value: 0.0, minimum: 0.0},
  802. ServerEntryMinimumAgeForPruning: {value: 7 * 24 * time.Hour, minimum: 24 * time.Hour},
  803. ApplicationParameters: {value: KeyValues{}},
  804. BPFServerTCPProgram: {value: (*BPFProgramSpec)(nil), flags: serverSideOnly},
  805. BPFServerTCPProbability: {value: 0.5, minimum: 0.0, flags: serverSideOnly},
  806. BPFClientTCPProgram: {value: (*BPFProgramSpec)(nil)},
  807. BPFClientTCPProbability: {value: 0.5, minimum: 0.0},
  808. ServerPacketManipulationSpecs: {value: PacketManipulationSpecs{}, flags: serverSideOnly},
  809. ServerProtocolPacketManipulations: {value: make(ProtocolPacketManipulations), flags: serverSideOnly},
  810. ServerPacketManipulationProbability: {value: 0.5, minimum: 0.0, flags: serverSideOnly},
  811. FeedbackUploadURLs: {value: TransferURLs{}},
  812. FeedbackEncryptionPublicKey: {value: ""},
  813. FeedbackTacticsWaitPeriod: {value: 5 * time.Second, minimum: 0 * time.Second, flags: useNetworkLatencyMultiplier},
  814. FeedbackUploadMaxAttempts: {value: 5, minimum: 0},
  815. // TODO: rename -- remove "Seconds" suffix
  816. FeedbackUploadRetryMinDelaySeconds: {value: 1 * time.Minute, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  817. FeedbackUploadRetryMaxDelaySeconds: {value: 5 * time.Minute, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  818. FeedbackUploadTimeoutSeconds: {value: 30 * time.Second, minimum: 0 * time.Second, flags: useNetworkLatencyMultiplier},
  819. ServerReplayPacketManipulation: {value: true, flags: serverSideOnly},
  820. ServerReplayFragmentor: {value: true, flags: serverSideOnly},
  821. ServerReplayUnknownGeoIP: {value: false, flags: serverSideOnly},
  822. ServerReplayTTL: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  823. ServerReplayTargetWaitDuration: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  824. ServerReplayTargetTunnelDuration: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  825. ServerReplayTargetUpstreamBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  826. ServerReplayTargetDownstreamBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  827. ServerReplayFailedCountThreshold: {value: 0, minimum: 0, flags: serverSideOnly},
  828. ServerBurstUpstreamTargetBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  829. ServerBurstUpstreamDeadline: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  830. ServerBurstDownstreamTargetBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  831. ServerBurstDownstreamDeadline: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  832. ClientBurstUpstreamTargetBytes: {value: 0, minimum: 0},
  833. ClientBurstUpstreamDeadline: {value: time.Duration(0), minimum: time.Duration(0)},
  834. ClientBurstDownstreamTargetBytes: {value: 0, minimum: 0},
  835. ClientBurstDownstreamDeadline: {value: time.Duration(0), minimum: time.Duration(0)},
  836. ConjureCachedRegistrationTTL: {value: time.Duration(0), minimum: time.Duration(0)},
  837. // ConjureAPIRegistrarURL parameter is obsoleted by ConjureAPIRegistrarBidirectionalURL.
  838. // TODO: remove once no longer required for older clients.
  839. ConjureAPIRegistrarURL: {value: ""},
  840. ConjureAPIRegistrarBidirectionalURL: {value: ""},
  841. ConjureAPIRegistrarFrontingSpecs: {value: FrontingSpecs{}},
  842. ConjureAPIRegistrarMinDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  843. ConjureAPIRegistrarMaxDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  844. ConjureDecoyRegistrarProbability: {value: 0.0, minimum: 0.0},
  845. ConjureDecoyRegistrarWidth: {value: 5, minimum: 0},
  846. ConjureDecoyRegistrarMinDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  847. ConjureDecoyRegistrarMaxDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  848. ConjureEnableIPv6Dials: {value: true},
  849. ConjureEnablePortRandomization: {value: true},
  850. ConjureEnableRegistrationOverrides: {value: false},
  851. ConjureLimitTransportsProbability: {value: 1.0, minimum: 0.0},
  852. ConjureLimitTransports: {value: protocol.ConjureTransports{}},
  853. ConjureSTUNServerAddresses: {value: []string{}},
  854. ConjureDTLSEmptyInitialPacketProbability: {value: 0.0, minimum: 0.0},
  855. CustomHostNameRegexes: {value: RegexStrings{}},
  856. CustomHostNameProbability: {value: 0.0, minimum: 0.0},
  857. CustomHostNameLimitProtocols: {value: protocol.TunnelProtocols{}},
  858. HoldOffTunnelMinDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  859. HoldOffTunnelMaxDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  860. HoldOffTunnelProtocols: {value: protocol.TunnelProtocols{}},
  861. HoldOffTunnelFrontingProviderIDs: {value: []string{}},
  862. HoldOffTunnelProbability: {value: 0.0, minimum: 0.0},
  863. HoldOffTunnelProtocolMinDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  864. HoldOffTunnelProtocolMaxDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  865. HoldOffTunnelProtocolNames: {value: protocol.TunnelProtocols{}},
  866. HoldOffTunnelProtocolProbability: {value: 0.0, minimum: 0.0},
  867. HoldOffFrontingTunnelMinDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  868. HoldOffFrontingTunnelMaxDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  869. HoldOffFrontingTunnelProviderIDs: {value: []string{}},
  870. HoldOffFrontingTunnelProbability: {value: 0.0, minimum: 0.0},
  871. RestrictFrontingProviderIDs: {value: []string{}},
  872. RestrictFrontingProviderIDsServerProbability: {value: 0.0, minimum: 0.0, flags: serverSideOnly},
  873. RestrictFrontingProviderIDsClientProbability: {value: 0.0, minimum: 0.0},
  874. HoldOffDirectTunnelMinDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  875. HoldOffDirectTunnelMaxDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  876. HoldOffDirectTunnelProviderRegions: {value: KeyStrings{}},
  877. HoldOffDirectTunnelProbability: {value: 0.0, minimum: 0.0},
  878. RestrictDirectProviderRegions: {value: KeyStrings{}},
  879. RestrictDirectProviderIDsServerProbability: {value: 0.0, minimum: 0.0, flags: serverSideOnly},
  880. RestrictDirectProviderIDsClientProbability: {value: 0.0, minimum: 0.0},
  881. HoldOffInproxyTunnelMinDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  882. HoldOffInproxyTunnelMaxDuration: {value: time.Duration(0), minimum: time.Duration(0)},
  883. HoldOffInproxyTunnelProviderRegions: {value: KeyStrings{}},
  884. HoldOffInproxyTunnelProbability: {value: 0.0, minimum: 0.0},
  885. RestrictInproxyProviderRegions: {value: KeyStrings{}},
  886. RestrictInproxyProviderIDsServerProbability: {value: 0.0, minimum: 0.0, flags: serverSideOnly},
  887. RestrictInproxyProviderIDsClientProbability: {value: 0.0, minimum: 0.0},
  888. UpstreamProxyAllowAllServerEntrySources: {value: false},
  889. DestinationBytesMetricsASN: {value: "", flags: serverSideOnly},
  890. DestinationBytesMetricsASNs: {value: []string{}, flags: serverSideOnly},
  891. DNSResolverAttemptsPerServer: {value: 2, minimum: 1},
  892. DNSResolverAttemptsPerPreferredServer: {value: 1, minimum: 1},
  893. DNSResolverRequestTimeout: {value: 5 * time.Second, minimum: 100 * time.Millisecond, flags: useNetworkLatencyMultiplier},
  894. DNSResolverAwaitTimeout: {value: 10 * time.Millisecond, minimum: 1 * time.Millisecond, flags: useNetworkLatencyMultiplier},
  895. DNSResolverPreresolvedIPAddressCIDRs: {value: LabeledCIDRs{}},
  896. DNSResolverPreresolvedIPAddressProbability: {value: 0.0, minimum: 0.0},
  897. DNSResolverAlternateServers: {value: []string{}},
  898. DNSResolverPreferredAlternateServers: {value: []string{}},
  899. DNSResolverPreferAlternateServerProbability: {value: 0.0, minimum: 0.0},
  900. DNSResolverProtocolTransformSpecs: {value: transforms.Specs{}},
  901. DNSResolverProtocolTransformScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  902. DNSResolverProtocolTransformProbability: {value: 0.0, minimum: 0.0},
  903. DNSResolverIncludeEDNS0Probability: {value: 0.0, minimum: 0.0},
  904. DNSResolverCacheExtensionInitialTTL: {value: time.Duration(0), minimum: time.Duration(0)},
  905. DNSResolverCacheExtensionVerifiedTTL: {value: time.Duration(0), minimum: time.Duration(0)},
  906. DNSResolverQNameRandomizeCasingProbability: {value: 0.0, minimum: 0.0},
  907. DNSResolverQNameMustMatchProbability: {value: 0.0, minimum: 0.0},
  908. AddFrontingProviderPsiphonFrontingHeader: {value: protocol.LabeledTunnelProtocols{}},
  909. DirectHTTPProtocolTransformSpecs: {value: transforms.Specs{}},
  910. DirectHTTPProtocolTransformScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  911. DirectHTTPProtocolTransformProbability: {value: 0.0, minimum: 0.0},
  912. FrontedHTTPProtocolTransformSpecs: {value: transforms.Specs{}},
  913. FrontedHTTPProtocolTransformScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  914. FrontedHTTPProtocolTransformProbability: {value: 0.0, minimum: 0.0},
  915. OSSHObfuscatorSeedTransformSpecs: {value: transforms.Specs{}},
  916. OSSHObfuscatorSeedTransformScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  917. OSSHObfuscatorSeedTransformProbability: {value: 0.0, minimum: 0.0},
  918. ObfuscatedQUICNonceTransformSpecs: {value: transforms.Specs{}},
  919. ObfuscatedQUICNonceTransformScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  920. ObfuscatedQUICNonceTransformProbability: {value: 0.0, minimum: 0.0},
  921. OSSHPrefixSpecs: {value: transforms.Specs{}},
  922. OSSHPrefixScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  923. OSSHPrefixProbability: {value: 0.0, minimum: 0.0},
  924. OSSHPrefixSplitMinDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  925. OSSHPrefixSplitMaxDelay: {value: time.Duration(0), minimum: time.Duration(0)},
  926. OSSHPrefixEnableFragmentor: {value: false},
  927. ServerOSSHPrefixSpecs: {value: transforms.Specs{}, flags: serverSideOnly},
  928. ShadowsocksPrefixSpecs: {value: transforms.Specs{}},
  929. ShadowsocksPrefixScopedSpecNames: {value: transforms.ScopedSpecNames{}},
  930. ShadowsocksPrefixProbability: {value: 0.0, minimum: 0.0},
  931. // TLSTunnelMinTLSPadding/TLSTunnelMaxTLSPadding are subject to TLS server limitations.
  932. TLSTunnelObfuscatedPSKProbability: {value: 0.5, minimum: 0.0},
  933. TLSTunnelTrafficShapingProbability: {value: 1.0, minimum: 0.0},
  934. TLSTunnelMinTLSPadding: {value: 0, minimum: 0},
  935. TLSTunnelMaxTLSPadding: {value: 0, minimum: 0},
  936. TLSFragmentClientHelloProbability: {value: 0.0, minimum: 0.0},
  937. TLSFragmentClientHelloLimitProtocols: {value: protocol.TunnelProtocols{}},
  938. SteeringIPCacheTTL: {value: 1 * time.Hour, minimum: time.Duration(0)},
  939. SteeringIPCacheMaxEntries: {value: 65536, minimum: 0},
  940. SteeringIPProbability: {value: 1.0, minimum: 0.0},
  941. ServerDiscoveryStrategy: {value: "", flags: serverSideOnly},
  942. FrontedHTTPClientReplayDialParametersTTL: {value: 24 * time.Hour, minimum: time.Duration(0)},
  943. FrontedHTTPClientReplayUpdateFrequency: {value: 5 * time.Minute, minimum: time.Duration(0)},
  944. FrontedHTTPClientReplayDialParametersProbability: {value: 1.0, minimum: 0.0},
  945. FrontedHTTPClientReplayRetainFailedProbability: {value: 0.5, minimum: 0.0},
  946. // For inproxy tactics, there is no proxyOnly flag, since Psiphon apps may
  947. // run both clients and inproxy proxies.
  948. //
  949. // Note: useNetworkLatencyMultiplier is not applied to request timeouts
  950. // since timeouts are strictly enforced on the broker server-side.
  951. InproxyAllowProxy: {value: false},
  952. InproxyAllowClient: {value: false, flags: serverSideOnly},
  953. InproxyAllowDomainFrontedDestinations: {value: false, flags: serverSideOnly},
  954. InproxyAllowMatchByRegion: {value: KeyStrings{}, flags: serverSideOnly},
  955. InproxyAllowMatchByASN: {value: KeyStrings{}, flags: serverSideOnly},
  956. InproxyDisallowMatchByRegion: {value: KeyStrings{}, flags: serverSideOnly},
  957. InproxyDisallowMatchByASN: {value: KeyStrings{}, flags: serverSideOnly},
  958. InproxyTunnelProtocolSelectionProbability: {value: 1.0, minimum: 0.0},
  959. InproxyAllBrokerPublicKeys: {value: []string{}, flags: serverSideOnly},
  960. InproxyAllBrokerSpecs: {value: InproxyBrokerSpecsValue{}, flags: serverSideOnly},
  961. InproxyBrokerSpecs: {value: InproxyBrokerSpecsValue{}},
  962. InproxyPersonalPairingBrokerSpecs: {value: InproxyBrokerSpecsValue{}},
  963. InproxyPersonalPairingMaxBrokerSpecCount: {value: 3, minimum: 1},
  964. InproxyProxyBrokerSpecs: {value: InproxyBrokerSpecsValue{}},
  965. InproxyProxyPersonalPairingBrokerSpecs: {value: InproxyBrokerSpecsValue{}},
  966. InproxyClientBrokerSpecs: {value: InproxyBrokerSpecsValue{}},
  967. InproxyClientPersonalPairingBrokerSpecs: {value: InproxyBrokerSpecsValue{}},
  968. InproxyReplayBrokerDialParametersTTL: {value: 24 * time.Hour, minimum: time.Duration(0)},
  969. InproxyReplayBrokerUpdateFrequency: {value: 5 * time.Minute, minimum: time.Duration(0)},
  970. InproxyReplayBrokerDialParametersProbability: {value: 1.0, minimum: 0.0},
  971. InproxyReplayBrokerRetainFailedProbability: {value: 0.5, minimum: 0.0},
  972. InproxyAllCommonCompartmentIDs: {value: []string{}, flags: serverSideOnly},
  973. InproxyCommonCompartmentIDs: {value: InproxyCompartmentIDsValue{}},
  974. InproxyMaxCompartmentIDListLength: {value: 50, minimum: 0},
  975. InproxyBrokerMatcherAnnouncementLimitEntryCount: {value: 50, minimum: 0, flags: serverSideOnly},
  976. InproxyBrokerMatcherAnnouncementRateLimitQuantity: {value: 50, minimum: 0, flags: serverSideOnly},
  977. InproxyBrokerMatcherAnnouncementRateLimitInterval: {value: 1 * time.Minute, minimum: time.Duration(0), flags: serverSideOnly},
  978. InproxyBrokerMatcherAnnouncementNonlimitedProxyIDs: {value: []string{}, flags: serverSideOnly},
  979. InproxyBrokerMatcherOfferLimitEntryCount: {value: 10, minimum: 0, flags: serverSideOnly},
  980. InproxyBrokerMatcherOfferRateLimitQuantity: {value: 50, minimum: 0, flags: serverSideOnly},
  981. InproxyBrokerMatcherOfferRateLimitInterval: {value: 1 * time.Minute, minimum: time.Duration(0), flags: serverSideOnly},
  982. InproxyBrokerMatcherPrioritizeProxiesProbability: {value: 1.0, minimum: 0.0, flags: serverSideOnly},
  983. InproxyBrokerMatcherPrioritizeProxiesFilter: {value: KeyStrings{}, flags: serverSideOnly},
  984. InproxyBrokerMatcherPrioritizeProxiesMinVersion: {value: 0, minimum: 0, flags: serverSideOnly},
  985. InproxyBrokerProxyAnnounceTimeout: {value: 2 * time.Minute, minimum: time.Duration(0), flags: serverSideOnly},
  986. InproxyBrokerClientOfferTimeout: {value: 10 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  987. InproxyBrokerClientOfferPersonalTimeout: {value: 5 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  988. InproxyBrokerPendingServerRequestsTTL: {value: 60 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  989. InproxyBrokerDSLRequestRateLimitQuantity: {value: 20, minimum: 0, flags: serverSideOnly},
  990. InproxyBrokerDSLRequestRateLimitInterval: {value: 1 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  991. InproxySessionHandshakeRoundTripTimeout: {value: 10 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  992. InproxyProxyAnnounceRequestTimeout: {value: 2*time.Minute + 10*time.Second, minimum: time.Duration(0)},
  993. InproxyProxyAnnounceDelay: {value: 100 * time.Millisecond, minimum: time.Duration(0)},
  994. InproxyProxyAnnounceDelayJitter: {value: 0.5, minimum: 0.0},
  995. InproxyProxyAnnounceMaxBackoffDelay: {value: 1 * time.Minute, minimum: time.Duration(0)},
  996. InproxyProxyAnswerRequestTimeout: {value: 10*time.Second + 10*time.Second, minimum: time.Duration(0)},
  997. InproxyClientOfferRequestTimeout: {value: 10*time.Second + 10*time.Second, minimum: time.Duration(0)},
  998. InproxyClientOfferRequestPersonalTimeout: {value: 5*time.Second + 10*time.Second, minimum: time.Duration(0)},
  999. InproxyClientOfferRetryDelay: {value: 100 * time.Millisecond, minimum: time.Duration(0)},
  1000. InproxyClientOfferRetryJitter: {value: 0.5, minimum: 0.0},
  1001. InproxyClientRelayedPacketRequestTimeout: {value: 35 * time.Second, minimum: time.Duration(0)},
  1002. InproxyClientDSLRequestTimeout: {value: 10 * time.Second, minimum: time.Duration(0)},
  1003. InproxyBrokerRoundTripStatusCodeFailureThreshold: {value: 2 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1004. InproxyDTLSRandomizationProbability: {value: 0.5, minimum: 0.0},
  1005. InproxyWebRTCMediaStreamsProbability: {value: 0.0, minimum: 0.0},
  1006. InproxyWebRTCDataChannelTrafficShapingProbability: {value: 0.5, minimum: 0.0},
  1007. InproxyWebRTCDataChannelTrafficShapingParameters: {value: InproxyTrafficShapingParametersValue{0, 10, 0, 1500, 0, 10, 1, 1500, 0.5}},
  1008. InproxyWebRTCMediaStreamsTrafficShapingProbability: {value: 0.5, minimum: 0.0},
  1009. InproxyWebRTCMediaStreamsTrafficShapingParameters: {value: InproxyTrafficShapingParametersValue{0, 10, 0, 254, 0, 10, 1, 1200, 0.5}},
  1010. InproxySTUNServerAddresses: {value: []string{}},
  1011. InproxySTUNServerAddressesRFC5780: {value: []string{}},
  1012. InproxyProxySTUNServerAddresses: {value: []string{}},
  1013. InproxyProxySTUNServerAddressesRFC5780: {value: []string{}},
  1014. InproxyClientSTUNServerAddresses: {value: []string{}},
  1015. InproxyClientSTUNServerAddressesRFC5780: {value: []string{}},
  1016. InproxyClientDiscoverNATProbability: {value: 0.0, minimum: 0.0},
  1017. InproxyDisableSTUN: {value: false},
  1018. InproxyDisablePortMapping: {value: false},
  1019. InproxyDisableInboundForMobileNetworks: {value: false},
  1020. InproxyDisableIPv6ICECandidates: {value: false},
  1021. InproxyProxyDisableSTUN: {value: false},
  1022. InproxyProxyDisablePortMapping: {value: false},
  1023. InproxyProxyDisableInboundForMobileNetworks: {value: false},
  1024. InproxyProxyDisableIPv6ICECandidates: {value: false},
  1025. InproxyClientDisableSTUN: {value: false},
  1026. InproxyClientDisablePortMapping: {value: false},
  1027. InproxyClientDisableInboundForMobileNetworks: {value: false},
  1028. InproxyClientDisableIPv6ICECandidates: {value: false},
  1029. InproxyProxyDiscoverNATTimeout: {value: 10 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1030. InproxyClientDiscoverNATTimeout: {value: 10 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1031. InproxyWebRTCAnswerTimeout: {value: 20 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1032. InproxyWebRTCAwaitPortMappingTimeout: {value: 2 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1033. InproxyProxyWebRTCAwaitReadyToProxyTimeout: {value: 30 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1034. InproxyClientWebRTCAwaitReadyToProxyTimeout: {value: 20 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1035. InproxyProxyDestinationDialTimeout: {value: 20 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1036. InproxyProxyRelayInactivityTimeout: {value: 5 * time.Minute, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1037. InproxyPsiphonAPIRequestTimeout: {value: 10 * time.Second, minimum: 1 * time.Second, flags: useNetworkLatencyMultiplier},
  1038. InproxyProxyTotalActivityNoticePeriod: {value: 5 * time.Minute, minimum: 1 * time.Second},
  1039. InproxyPersonalPairingConnectionWorkerPoolSize: {value: 2, minimum: 1},
  1040. InproxyClientDialRateLimitQuantity: {value: 2, minimum: 0},
  1041. InproxyClientDialRateLimitInterval: {value: 500 * time.Millisecond, minimum: time.Duration(0)},
  1042. InproxyClientNoMatchFailoverProbability: {value: 0.5, minimum: 0.0},
  1043. InproxyClientNoMatchFailoverPersonalProbability: {value: 1.0, minimum: 0.0},
  1044. InproxyFrontingProviderClientMaxRequestTimeouts: {value: KeyDurations{}},
  1045. InproxyFrontingProviderServerMaxRequestTimeouts: {value: KeyDurations{}, flags: serverSideOnly},
  1046. InproxyProxyOnBrokerClientFailedRetryPeriod: {value: 30 * time.Second, minimum: time.Duration(0)},
  1047. InproxyProxyIncompatibleNetworkTypes: {value: []string{}},
  1048. InproxyClientIncompatibleNetworkTypes: {value: []string{}},
  1049. InproxyReplayRetainFailedProbability: {value: 1.0, minimum: 0.0},
  1050. InproxyProxyDisableWaitToShareSession: {value: false},
  1051. InproxyClientDisableWaitToShareSession: {value: true},
  1052. InproxyTunnelProtocolPreferProbability: {value: 0.0, minimum: 0.0},
  1053. InproxyTunnelProtocolForceSelectionCount: {value: 0, minimum: 0},
  1054. InproxyEnableProxyQuality: {value: false, flags: serverSideOnly},
  1055. InproxyEnableProxyQualityClientRegions: {value: []string{}, flags: serverSideOnly},
  1056. InproxyProxyQualityTargetUpstreamBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  1057. InproxyProxyQualityTargetDownstreamBytes: {value: 0, minimum: 0, flags: serverSideOnly},
  1058. InproxyProxyQualityTargetDuration: {value: time.Duration(0), minimum: time.Duration(0), flags: serverSideOnly},
  1059. InproxyProxyQualityReporterMaxRequestEntries: {value: 1000, minimum: 1, flags: serverSideOnly},
  1060. InproxyProxyQualityReporterTrustedCACertificates: {value: "", flags: serverSideOnly},
  1061. InproxyProxyQualityReporterAdditionalHeaders: {value: http.Header{}, flags: serverSideOnly},
  1062. InproxyProxyQualityReporterRequestDelay: {value: 10 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  1063. InproxyProxyQualityReporterRequestTimeout: {value: 10 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  1064. InproxyProxyQualityReporterRequestRetries: {value: 2, minimum: 0, flags: serverSideOnly},
  1065. InproxyProxyQualityTTL: {value: 24 * time.Hour, minimum: time.Duration(0), flags: serverSideOnly},
  1066. InproxyProxyQualityPendingFailedMatchDeadline: {value: 5 * time.Minute, minimum: time.Duration(0), flags: serverSideOnly},
  1067. InproxyProxyQualityFailedMatchThreshold: {value: 10, minimum: 1, flags: serverSideOnly},
  1068. NetworkIDCacheTTL: {value: 500 * time.Millisecond, minimum: time.Duration(0)},
  1069. ServerDNSResolverCacheMaxSize: {value: 32, minimum: 0, flags: serverSideOnly},
  1070. ServerDNSResolverCacheTTL: {value: 10 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  1071. CheckServerEntryTagsEnabled: {value: true},
  1072. CheckServerEntryTagsPeriod: {value: 90 * 24 * time.Hour, minimum: time.Duration(0)},
  1073. CheckServerEntryTagsRepeatRatio: {value: 0.10, minimum: 0.0},
  1074. CheckServerEntryTagsRepeatMinimum: {value: 1, minimum: 0},
  1075. CheckServerEntryTagsMaxSendBytes: {value: 65536, minimum: 1},
  1076. CheckServerEntryTagsMaxWorkTime: {value: 60 * time.Second, minimum: time.Duration(0)},
  1077. ServerEntryPruneDialPortNumberZero: {value: true},
  1078. CompressTactics: {value: true},
  1079. DSLRelayServiceAddress: {value: "", flags: serverSideOnly},
  1080. DSLRelayMaxHttpConns: {value: 100, minimum: 1, flags: serverSideOnly},
  1081. DSLRelayMaxHttpIdleConns: {value: 10, minimum: 1, flags: serverSideOnly},
  1082. DSLRelayHttpIdleConnTimeout: {value: 120 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  1083. DSLRelayRequestTimeout: {value: 30 * time.Second, minimum: time.Duration(0), flags: serverSideOnly},
  1084. DSLRelayRetryCount: {value: 1, minimum: 0, flags: serverSideOnly},
  1085. DSLRelayCacheTTL: {value: 24 * time.Hour, minimum: time.Duration(0), flags: serverSideOnly},
  1086. DSLRelayCacheMaxSize: {value: 200000, minimum: 0, flags: serverSideOnly},
  1087. EnableDSLFetcher: {value: false},
  1088. DSLFetcherTunneledRequestTimeout: {value: 5 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1089. DSLFetcherTunneledRequestRetryCount: {value: 0, minimum: 0},
  1090. DSLFetcherTunneledRequestRetryDelay: {value: 5 * time.Second, minimum: time.Duration(0)},
  1091. DSLFetcherTunneledRequestRetryDelayJitter: {value: 0.3, minimum: 0.0},
  1092. DSLFetcherTunneledFetchTTL: {value: 1 * time.Hour, minimum: time.Duration(0)},
  1093. DSLFetcherTunneledDiscoverServerEntriesMinCount: {value: 1, minimum: 0},
  1094. DSLFetcherTunneledDiscoverServerEntriesMaxCount: {value: 2, minimum: 0},
  1095. DSLFetcherTunneledGetServerEntriesMinCount: {value: 30, minimum: 0},
  1096. DSLFetcherTunneledGetServerEntriesMaxCount: {value: 60, minimum: 0},
  1097. DSLFetcherUntunneledRequestTimeout: {value: 30 * time.Second, minimum: time.Duration(0), flags: useNetworkLatencyMultiplier},
  1098. DSLFetcherUntunneledRequestRetryCount: {value: 2, minimum: 0},
  1099. DSLFetcherUntunneledRequestRetryDelay: {value: 5 * time.Second, minimum: time.Duration(0)},
  1100. DSLFetcherUntunneledRequestRetryDelayJitter: {value: 0.3, minimum: 0.0},
  1101. DSLFetcherUntunneledFetchTTL: {value: 6 * time.Hour, minimum: time.Duration(0)},
  1102. DSLFetcherUntunneledDiscoverServerEntriesMinCount: {value: 200, minimum: 0},
  1103. DSLFetcherUntunneledDiscoverServerEntriesMaxCount: {value: 400, minimum: 0},
  1104. DSLFetcherUntunneledGetServerEntriesMinCount: {value: 30, minimum: 0},
  1105. DSLFetcherUntunneledGetServerEntriesMaxCount: {value: 60, minimum: 0},
  1106. DSLFetcherGetLastActiveOSLsTTL: {value: 24 * time.Hour, minimum: time.Duration(0)},
  1107. DSLFetcherGetOSLFileSpecsMinCount: {value: 1, minimum: 0},
  1108. DSLFetcherGetOSLFileSpecsMaxCount: {value: 1, minimum: 0},
  1109. DSLPrioritizeDialNewServerEntryProbability: {value: 0.5, minimum: 0.0},
  1110. DSLPrioritizeDialExistingServerEntryProbability: {value: 0.25, minimum: 0.0},
  1111. DSLPrioritizeDialRetainFailedProbability: {value: 0.0, minimum: 0.0},
  1112. DSLPrioritizeDialPlaceholderTTL: {value: 24 * time.Hour, minimum: time.Duration(0)},
  1113. ServerEntryIteratorMaxMoveToFront: {value: -1, minimum: -1},
  1114. ServerEntryIteratorResetProbability: {value: 1.0, minimum: 0.0},
  1115. }
  1116. // IsServerSideOnly indicates if the parameter specified by name is used
  1117. // server-side only.
  1118. func IsServerSideOnly(name string) bool {
  1119. defaultParameter, ok := defaultParameters[name]
  1120. return ok && (defaultParameter.flags&serverSideOnly) != 0
  1121. }
  1122. // Parameters is a set of parameters. To use the parameters, call Get. To
  1123. // apply new values to the parameters, call Set.
  1124. type Parameters struct {
  1125. getValueLogger func(error)
  1126. snapshot atomic.Value
  1127. }
  1128. // NewParameters initializes a new Parameters with the default parameter
  1129. // values.
  1130. //
  1131. // getValueLogger is optional, and is used to report runtime errors with
  1132. // getValue; see comment in getValue.
  1133. func NewParameters(
  1134. getValueLogger func(error)) (*Parameters, error) {
  1135. parameters := &Parameters{
  1136. getValueLogger: getValueLogger,
  1137. }
  1138. // Note: validationFlags excludes ValidationServerSide, so the
  1139. // Parameters.Set checkInproxyLists logic is not invoked; however, all
  1140. // the relevent lists currently default to empty values.
  1141. _, err := parameters.Set("", 0)
  1142. if err != nil {
  1143. return nil, errors.Trace(err)
  1144. }
  1145. return parameters, nil
  1146. }
  1147. func makeDefaultParameters() (map[string]interface{}, error) {
  1148. parameters := make(map[string]interface{})
  1149. for name, defaults := range defaultParameters {
  1150. if defaults.value == nil {
  1151. return nil, errors.Tracef("default parameter missing value: %s", name)
  1152. }
  1153. if defaults.minimum != nil &&
  1154. reflect.TypeOf(defaults.value) != reflect.TypeOf(defaults.minimum) {
  1155. return nil, errors.Tracef("default parameter value and minimum type mismatch: %s", name)
  1156. }
  1157. _, isDuration := defaults.value.(time.Duration)
  1158. if defaults.flags&useNetworkLatencyMultiplier != 0 && !isDuration {
  1159. return nil, errors.Tracef("default non-duration parameter uses multipler: %s", name)
  1160. }
  1161. parameters[name] = defaults.value
  1162. }
  1163. return parameters, nil
  1164. }
  1165. const (
  1166. // ValidationSkipOnError indicates whether invalid tactics are to be
  1167. // skipped/omitted, or if Set should fail on invalid tactics. In some
  1168. // cases, clients set ValidationSkipOnError as older client code may
  1169. // download newer tactics which do not validate; while servers perform
  1170. // strict validation.
  1171. ValidationSkipOnError = 1
  1172. // ValidationServerSide indicates whether the validation is server-side,
  1173. // in which case additonal checks referencing serverSideOnly parameters
  1174. // are performed.
  1175. ValidationServerSide = 2
  1176. )
  1177. // Set replaces the current parameters. First, a set of parameters are
  1178. // initialized using the default values. Then, each applyParameters is applied
  1179. // in turn, with the later instances having precedence.
  1180. //
  1181. // When skipOnError is true, unknown or invalid parameters in any
  1182. // applyParameters are skipped instead of aborting with an error.
  1183. //
  1184. // For protocol.TunnelProtocols and protocol.TLSProfiles type values, when
  1185. // skipOnError is true the values are filtered instead of validated, so
  1186. // only known tunnel protocols and TLS profiles are retained.
  1187. //
  1188. // When an error is returned, the previous parameters remain completely
  1189. // unmodified.
  1190. //
  1191. // For use in logging, Set returns a count of the number of parameters applied
  1192. // from each applyParameters.
  1193. func (p *Parameters) Set(
  1194. tag string,
  1195. validationFlags int,
  1196. applyParameters ...map[string]interface{}) ([]int, error) {
  1197. skipOnError := (validationFlags & ValidationSkipOnError) != 0
  1198. serverSide := (validationFlags & ValidationServerSide) != 0
  1199. makeTypedValue := func(templateValue, value interface{}) (interface{}, error) {
  1200. // Accept strings such as "1h" for duration parameters.
  1201. switch templateValue.(type) {
  1202. case time.Duration:
  1203. if s, ok := value.(string); ok {
  1204. if d, err := time.ParseDuration(s); err == nil {
  1205. value = d
  1206. }
  1207. }
  1208. }
  1209. // A JSON remarshal resolves cases where applyParameters is a
  1210. // result of unmarshal-into-interface, in which case non-scalar
  1211. // values will not have the expected types; see:
  1212. // https://golang.org/pkg/encoding/json/#Unmarshal. This remarshal
  1213. // also results in a deep copy.
  1214. marshaledValue, err := json.Marshal(value)
  1215. if err != nil {
  1216. return nil, errors.Trace(err)
  1217. }
  1218. newValuePtr := reflect.New(reflect.TypeOf(templateValue))
  1219. err = json.Unmarshal(marshaledValue, newValuePtr.Interface())
  1220. if err != nil {
  1221. return nil, errors.Trace(err)
  1222. }
  1223. return newValuePtr.Elem().Interface(), nil
  1224. }
  1225. getAppliedValue := func(
  1226. name string,
  1227. parameters map[string]interface{},
  1228. applyParameters []map[string]interface{}) (interface{}, error) {
  1229. templateValue := parameters[name]
  1230. if templateValue == nil {
  1231. return nil, errors.Tracef("unknown parameter: %s", name)
  1232. }
  1233. value := templateValue
  1234. for i := len(applyParameters) - 1; i >= 0; i-- {
  1235. if v := applyParameters[i][name]; v != nil {
  1236. value = v
  1237. break
  1238. }
  1239. }
  1240. return makeTypedValue(templateValue, value)
  1241. }
  1242. var counts []int
  1243. parameters, err := makeDefaultParameters()
  1244. if err != nil {
  1245. return nil, errors.Trace(err)
  1246. }
  1247. // Special case: TLSProfiles/LabeledTLSProfiles may reference
  1248. // CustomTLSProfiles names. Inspect the CustomTLSProfiles parameter and
  1249. // extract its names. Do not call Get().CustomTLSProfilesNames() as
  1250. // CustomTLSProfiles may not yet be validated.
  1251. customTLSProfilesValue, err := getAppliedValue(
  1252. CustomTLSProfiles, parameters, applyParameters)
  1253. if err != nil {
  1254. return nil, errors.Trace(err)
  1255. }
  1256. customTLSProfiles, _ := customTLSProfilesValue.(protocol.CustomTLSProfiles)
  1257. customTLSProfileNames := make([]string, len(customTLSProfiles))
  1258. for i, profile := range customTLSProfiles {
  1259. customTLSProfileNames[i] = profile.Name
  1260. }
  1261. // Special case: PacketManipulations will reference PacketManipulationSpecs.
  1262. serverPacketManipulationSpecsValue, err := getAppliedValue(
  1263. ServerPacketManipulationSpecs, parameters, applyParameters)
  1264. if err != nil {
  1265. return nil, errors.Trace(err)
  1266. }
  1267. serverPacketManipulationSpecs, _ :=
  1268. serverPacketManipulationSpecsValue.(PacketManipulationSpecs)
  1269. // Special case: ProtocolTransformScopedSpecNames will reference
  1270. // ProtocolTransformSpecs.
  1271. dnsResolverProtocolTransformSpecsValue, err := getAppliedValue(
  1272. DNSResolverProtocolTransformSpecs, parameters, applyParameters)
  1273. if err != nil {
  1274. return nil, errors.Trace(err)
  1275. }
  1276. dnsResolverProtocolTransformSpecs, _ :=
  1277. dnsResolverProtocolTransformSpecsValue.(transforms.Specs)
  1278. directHttpProtocolTransformSpecsValue, err := getAppliedValue(
  1279. DirectHTTPProtocolTransformSpecs, parameters, applyParameters)
  1280. if err != nil {
  1281. return nil, errors.Trace(err)
  1282. }
  1283. directHttpProtocolTransformSpecs, _ :=
  1284. directHttpProtocolTransformSpecsValue.(transforms.Specs)
  1285. frontedHttpProtocolTransformSpecsValue, err := getAppliedValue(
  1286. FrontedHTTPProtocolTransformSpecs, parameters, applyParameters)
  1287. if err != nil {
  1288. return nil, errors.Trace(err)
  1289. }
  1290. frontedHttpProtocolTransformSpecs, _ :=
  1291. frontedHttpProtocolTransformSpecsValue.(transforms.Specs)
  1292. osshObfuscatorSeedTransformSpecsValue, err := getAppliedValue(
  1293. OSSHObfuscatorSeedTransformSpecs, parameters, applyParameters)
  1294. if err != nil {
  1295. return nil, errors.Trace(err)
  1296. }
  1297. osshObfuscatorSeedTransformSpecs, _ :=
  1298. osshObfuscatorSeedTransformSpecsValue.(transforms.Specs)
  1299. obfuscatedQuicNonceTransformSpecsValue, err := getAppliedValue(
  1300. ObfuscatedQUICNonceTransformSpecs, parameters, applyParameters)
  1301. if err != nil {
  1302. return nil, errors.Trace(err)
  1303. }
  1304. obfuscatedQuicNonceTransformSpecs, _ :=
  1305. obfuscatedQuicNonceTransformSpecsValue.(transforms.Specs)
  1306. osshPrefixSpecsValue, err := getAppliedValue(
  1307. OSSHPrefixSpecs, parameters, applyParameters)
  1308. if err != nil {
  1309. return nil, errors.Trace(err)
  1310. }
  1311. osshPrefixSpecs, _ := osshPrefixSpecsValue.(transforms.Specs)
  1312. shadowsocksPrefixSpecsValue, err := getAppliedValue(
  1313. ShadowsocksPrefixSpecs, parameters, applyParameters)
  1314. if err != nil {
  1315. return nil, errors.Trace(err)
  1316. }
  1317. shadowsocksPrefixSpecs, _ := shadowsocksPrefixSpecsValue.(transforms.Specs)
  1318. // Special case: in-proxy broker specs in any InproxyBrokerSpecs must
  1319. // appear in InproxyAllBrokerSpecs; and in-proxy common compartment IDs
  1320. // must appear in InproxyAllCommonCompartmentIDs. This check is
  1321. // server-side only as the "All" parameters are serverSideOnly.
  1322. // Note that similar validation for InproxyAllBrokerPublicKeys has been
  1323. // retired, although InproxyAllBrokerPublicKeys is still present in
  1324. // defaultParameters for backwards compatibility during the transition to
  1325. // InproxyAllBrokerSpecs.
  1326. //
  1327. // TODO: fully retire InproxyAllBrokerPublicKeys.
  1328. checkInproxyLists := !skipOnError && serverSide
  1329. inproxyAllBrokerSpecsValue, err := getAppliedValue(
  1330. InproxyAllBrokerSpecs, parameters, applyParameters)
  1331. if err != nil {
  1332. return nil, errors.Trace(err)
  1333. }
  1334. inproxyAllBrokerSpecs, _ := inproxyAllBrokerSpecsValue.(InproxyBrokerSpecsValue)
  1335. // Fall back to InproxyBrokerSpecs if InproxyAllBrokerSpecs is not
  1336. // configured.
  1337. if len(inproxyAllBrokerSpecs) == 0 {
  1338. inproxyBrokerSpecsValue, err := getAppliedValue(
  1339. InproxyBrokerSpecs, parameters, applyParameters)
  1340. if err != nil {
  1341. return nil, errors.Trace(err)
  1342. }
  1343. inproxyAllBrokerSpecs, _ = inproxyBrokerSpecsValue.(InproxyBrokerSpecsValue)
  1344. }
  1345. inproxyAllCommonCompartmentIDsValue, err := getAppliedValue(
  1346. InproxyAllCommonCompartmentIDs, parameters, applyParameters)
  1347. if err != nil {
  1348. return nil, errors.Trace(err)
  1349. }
  1350. inproxyAllCommonCompartmentIDs, _ := inproxyAllCommonCompartmentIDsValue.([]string)
  1351. // Special case: skip validation of transforms.Specs on the client side,
  1352. // since the regen operations may be slow. transforms.Specs are still
  1353. // validated on the server side, before being sent to clients. If a
  1354. // client's transforms.Spec is somehow corrupted, the tunnel dial
  1355. // applying the transform will error out -- transforms.Specs.Validate
  1356. // simply invokes the same apply operations.
  1357. validateTransformSpecs := serverSide
  1358. for i := 0; i < len(applyParameters); i++ {
  1359. count := 0
  1360. for name, value := range applyParameters[i] {
  1361. templateValue, ok := parameters[name]
  1362. if !ok {
  1363. if skipOnError {
  1364. continue
  1365. }
  1366. return nil, errors.Tracef("unknown parameter: %s", name)
  1367. }
  1368. newValue, err := makeTypedValue(templateValue, value)
  1369. if err != nil {
  1370. if skipOnError {
  1371. continue
  1372. }
  1373. return nil, errors.Tracef(
  1374. "unmarshal parameter %s failed: %v", name, err)
  1375. }
  1376. // Perform type-specific validation for some cases.
  1377. // TODO: require RemoteServerListSignaturePublicKey when
  1378. // RemoteServerListURLs is set?
  1379. switch v := newValue.(type) {
  1380. case TransferURLs:
  1381. err := v.DecodeAndValidate()
  1382. if err != nil {
  1383. if skipOnError {
  1384. continue
  1385. }
  1386. return nil, errors.Trace(err)
  1387. }
  1388. case protocol.TunnelProtocols:
  1389. if skipOnError {
  1390. newValue = v.PruneInvalid()
  1391. } else {
  1392. err := v.Validate()
  1393. if err != nil {
  1394. return nil, errors.Trace(err)
  1395. }
  1396. }
  1397. case protocol.LabeledTunnelProtocols:
  1398. if skipOnError {
  1399. newValue = v.PruneInvalid()
  1400. } else {
  1401. err := v.Validate()
  1402. if err != nil {
  1403. return nil, errors.Trace(err)
  1404. }
  1405. }
  1406. case protocol.TLSProfiles:
  1407. if skipOnError {
  1408. newValue = v.PruneInvalid(customTLSProfileNames)
  1409. } else {
  1410. err := v.Validate(customTLSProfileNames)
  1411. if err != nil {
  1412. return nil, errors.Trace(err)
  1413. }
  1414. }
  1415. case protocol.LabeledTLSProfiles:
  1416. if skipOnError {
  1417. newValue = v.PruneInvalid(customTLSProfileNames)
  1418. } else {
  1419. err := v.Validate(customTLSProfileNames)
  1420. if err != nil {
  1421. return nil, errors.Trace(err)
  1422. }
  1423. }
  1424. case protocol.QUICVersions:
  1425. if skipOnError {
  1426. newValue = v.PruneInvalid()
  1427. } else {
  1428. err := v.Validate()
  1429. if err != nil {
  1430. return nil, errors.Trace(err)
  1431. }
  1432. }
  1433. case protocol.LabeledQUICVersions:
  1434. if skipOnError {
  1435. newValue = v.PruneInvalid()
  1436. } else {
  1437. err := v.Validate()
  1438. if err != nil {
  1439. return nil, errors.Trace(err)
  1440. }
  1441. }
  1442. case protocol.CustomTLSProfiles:
  1443. err := v.Validate()
  1444. if err != nil {
  1445. if skipOnError {
  1446. continue
  1447. }
  1448. return nil, errors.Trace(err)
  1449. }
  1450. case KeyValues:
  1451. err := v.Validate()
  1452. if err != nil {
  1453. if skipOnError {
  1454. continue
  1455. }
  1456. return nil, errors.Trace(err)
  1457. }
  1458. case KeyStrings:
  1459. err := v.Validate()
  1460. if err != nil {
  1461. if skipOnError {
  1462. continue
  1463. }
  1464. return nil, errors.Trace(err)
  1465. }
  1466. case KeyDurations:
  1467. err := v.Validate()
  1468. if err != nil {
  1469. if skipOnError {
  1470. continue
  1471. }
  1472. return nil, errors.Trace(err)
  1473. }
  1474. case *BPFProgramSpec:
  1475. if v != nil {
  1476. err := v.Validate()
  1477. if err != nil {
  1478. if skipOnError {
  1479. continue
  1480. }
  1481. return nil, errors.Trace(err)
  1482. }
  1483. }
  1484. case PacketManipulationSpecs:
  1485. err := v.Validate()
  1486. if err != nil {
  1487. if skipOnError {
  1488. continue
  1489. }
  1490. return nil, errors.Trace(err)
  1491. }
  1492. case ProtocolPacketManipulations:
  1493. var packetManipulationSpecs PacketManipulationSpecs
  1494. if name == ServerProtocolPacketManipulations {
  1495. packetManipulationSpecs = serverPacketManipulationSpecs
  1496. }
  1497. err := v.Validate(packetManipulationSpecs)
  1498. if err != nil {
  1499. if skipOnError {
  1500. continue
  1501. }
  1502. return nil, errors.Trace(err)
  1503. }
  1504. case RegexStrings:
  1505. err := v.Validate()
  1506. if err != nil {
  1507. if skipOnError {
  1508. continue
  1509. }
  1510. return nil, errors.Trace(err)
  1511. }
  1512. case FrontingSpecs:
  1513. // By default, FrontingSpecs are not permitted to specify
  1514. // SkipVerify. This includes the ConjureAPIRegistrarFrontingSpecs
  1515. // case which uses MeekModePlaintextRoundTrip.
  1516. allowSkipVerify := false
  1517. err := v.Validate(allowSkipVerify)
  1518. if err != nil {
  1519. if skipOnError {
  1520. continue
  1521. }
  1522. return nil, errors.Trace(err)
  1523. }
  1524. case TunnelProtocolPortLists:
  1525. err := v.Validate()
  1526. if err != nil {
  1527. if skipOnError {
  1528. continue
  1529. }
  1530. return nil, errors.Trace(err)
  1531. }
  1532. case LabeledCIDRs:
  1533. err := v.Validate()
  1534. if err != nil {
  1535. if skipOnError {
  1536. continue
  1537. }
  1538. return nil, errors.Trace(err)
  1539. }
  1540. case transforms.Specs:
  1541. if !validateTransformSpecs {
  1542. break
  1543. }
  1544. prefixMode := false
  1545. if name == OSSHPrefixSpecs || name == ServerOSSHPrefixSpecs || name == ShadowsocksPrefixSpecs {
  1546. prefixMode = true
  1547. }
  1548. err := v.Validate(prefixMode)
  1549. if err != nil {
  1550. if skipOnError {
  1551. continue
  1552. }
  1553. return nil, errors.Trace(err)
  1554. }
  1555. case transforms.ScopedSpecNames:
  1556. var specs transforms.Specs
  1557. if name == DNSResolverProtocolTransformScopedSpecNames {
  1558. specs = dnsResolverProtocolTransformSpecs
  1559. } else if name == DirectHTTPProtocolTransformScopedSpecNames {
  1560. specs = directHttpProtocolTransformSpecs
  1561. } else if name == FrontedHTTPProtocolTransformScopedSpecNames {
  1562. specs = frontedHttpProtocolTransformSpecs
  1563. } else if name == OSSHObfuscatorSeedTransformScopedSpecNames {
  1564. specs = osshObfuscatorSeedTransformSpecs
  1565. } else if name == ObfuscatedQUICNonceTransformScopedSpecNames {
  1566. specs = obfuscatedQuicNonceTransformSpecs
  1567. } else if name == OSSHPrefixScopedSpecNames {
  1568. specs = osshPrefixSpecs
  1569. } else if name == ShadowsocksPrefixScopedSpecNames {
  1570. specs = shadowsocksPrefixSpecs
  1571. }
  1572. err := v.Validate(specs)
  1573. if err != nil {
  1574. if skipOnError {
  1575. continue
  1576. }
  1577. return nil, errors.Trace(err)
  1578. }
  1579. case protocol.ConjureTransports:
  1580. if skipOnError {
  1581. newValue = v.PruneInvalid()
  1582. } else {
  1583. err := v.Validate()
  1584. if err != nil {
  1585. return nil, errors.Trace(err)
  1586. }
  1587. }
  1588. case InproxyBrokerSpecsValue:
  1589. var checkList *InproxyBrokerSpecsValue
  1590. if checkInproxyLists && name == InproxyBrokerSpecs {
  1591. checkList = &inproxyAllBrokerSpecs
  1592. }
  1593. err := v.Validate(checkList)
  1594. if err != nil {
  1595. if skipOnError {
  1596. continue
  1597. }
  1598. return nil, errors.Trace(err)
  1599. }
  1600. case InproxyCompartmentIDsValue:
  1601. var checkList *[]string
  1602. if checkInproxyLists && name == InproxyCommonCompartmentIDs {
  1603. checkList = &inproxyAllCommonCompartmentIDs
  1604. }
  1605. err := v.Validate(checkList)
  1606. if err != nil {
  1607. if skipOnError {
  1608. continue
  1609. }
  1610. return nil, errors.Trace(err)
  1611. }
  1612. case InproxyTrafficShapingParametersValue:
  1613. err := v.Validate()
  1614. if err != nil {
  1615. if skipOnError {
  1616. continue
  1617. }
  1618. return nil, errors.Trace(err)
  1619. }
  1620. case LivenessTestSpecs:
  1621. err := v.Validate()
  1622. if err != nil {
  1623. if skipOnError {
  1624. continue
  1625. }
  1626. return nil, errors.Trace(err)
  1627. }
  1628. }
  1629. // Enforce any minimums. Assumes defaultParameters[name]
  1630. // exists.
  1631. if defaultParameters[name].minimum != nil {
  1632. valid := true
  1633. switch v := newValue.(type) {
  1634. case int:
  1635. m, ok := defaultParameters[name].minimum.(int)
  1636. if !ok || v < m {
  1637. valid = false
  1638. }
  1639. case float64:
  1640. m, ok := defaultParameters[name].minimum.(float64)
  1641. if !ok || v < m {
  1642. valid = false
  1643. }
  1644. case time.Duration:
  1645. m, ok := defaultParameters[name].minimum.(time.Duration)
  1646. if !ok || v < m {
  1647. valid = false
  1648. }
  1649. default:
  1650. if skipOnError {
  1651. continue
  1652. }
  1653. return nil, errors.Tracef("unexpected parameter with minimum: %s", name)
  1654. }
  1655. if !valid {
  1656. if skipOnError {
  1657. continue
  1658. }
  1659. return nil, errors.Tracef("parameter below minimum: %s", name)
  1660. }
  1661. }
  1662. parameters[name] = newValue
  1663. count++
  1664. }
  1665. counts = append(counts, count)
  1666. }
  1667. snapshot := &parametersSnapshot{
  1668. getValueLogger: p.getValueLogger,
  1669. tag: tag,
  1670. parameters: parameters,
  1671. }
  1672. p.snapshot.Store(snapshot)
  1673. return counts, nil
  1674. }
  1675. // Get returns the current parameters.
  1676. //
  1677. // Values read from the current parameters are not deep copies and must be
  1678. // treated read-only.
  1679. //
  1680. // The returned ParametersAccessor may be used to read multiple related values
  1681. // atomically and consistently while the current set of values in Parameters
  1682. // may change concurrently.
  1683. //
  1684. // Get does not perform any heap allocations and is intended for repeated,
  1685. // direct, low-overhead invocations.
  1686. func (p *Parameters) Get() ParametersAccessor {
  1687. return ParametersAccessor{
  1688. snapshot: p.snapshot.Load().(*parametersSnapshot)}
  1689. }
  1690. // GetCustom returns the current parameters while also setting customizations
  1691. // for this instance.
  1692. //
  1693. // The properties of Get also apply to GetCustom: must be read-only; atomic
  1694. // and consisent view; no heap allocations.
  1695. //
  1696. // Customizations include:
  1697. //
  1698. // - customNetworkLatencyMultiplier, which overrides NetworkLatencyMultiplier
  1699. // for this instance only.
  1700. func (p *Parameters) GetCustom(
  1701. customNetworkLatencyMultiplier float64) ParametersAccessor {
  1702. return ParametersAccessor{
  1703. snapshot: p.snapshot.Load().(*parametersSnapshot),
  1704. customNetworkLatencyMultiplier: customNetworkLatencyMultiplier,
  1705. }
  1706. }
  1707. // parametersSnapshot is an atomic snapshot of the parameter values.
  1708. // Parameters.Get will return a snapshot which may be used to read multiple
  1709. // related values atomically and consistently while the current snapshot in
  1710. // Parameters may change concurrently.
  1711. type parametersSnapshot struct {
  1712. getValueLogger func(error)
  1713. tag string
  1714. parameters map[string]interface{}
  1715. }
  1716. // getValue sets target to the value of the named parameter.
  1717. //
  1718. // It is an error if the name is not found, target is not a pointer, or the
  1719. // type of target points to does not match the value.
  1720. //
  1721. // Any of these conditions would be a bug in the caller. getValue does not
  1722. // panic in these cases as clients are deployed as a library in various apps
  1723. // and the failure of Psiphon may not be a failure for the app process.
  1724. //
  1725. // Instead, errors are logged to the getValueLogger and getValue leaves the
  1726. // target unset, which will result in the caller getting and using a zero
  1727. // value of the requested type.
  1728. func (p *parametersSnapshot) getValue(name string, target interface{}) {
  1729. value, ok := p.parameters[name]
  1730. if !ok {
  1731. if p.getValueLogger != nil {
  1732. p.getValueLogger(errors.Tracef(
  1733. "value %s not found", name))
  1734. }
  1735. return
  1736. }
  1737. valueType := reflect.TypeOf(value)
  1738. if reflect.PtrTo(valueType) != reflect.TypeOf(target) {
  1739. if p.getValueLogger != nil {
  1740. p.getValueLogger(errors.Tracef(
  1741. "value %s has unexpected type %s", name, valueType.Name()))
  1742. }
  1743. return
  1744. }
  1745. // Note: there is no deep copy of parameter values; the returned value may
  1746. // share memory with the original and should not be modified.
  1747. targetValue := reflect.ValueOf(target)
  1748. if targetValue.Kind() != reflect.Ptr {
  1749. p.getValueLogger(errors.Tracef(
  1750. "target for value %s is not pointer", name))
  1751. return
  1752. }
  1753. targetValue.Elem().Set(reflect.ValueOf(value))
  1754. }
  1755. // ParametersAccessor provides consistent, atomic access to parameter values.
  1756. // Any customizations are applied transparently.
  1757. type ParametersAccessor struct {
  1758. snapshot *parametersSnapshot
  1759. customNetworkLatencyMultiplier float64
  1760. }
  1761. // MakeNilParametersAccessor produces a stub ParametersAccessor which returns
  1762. // true for IsNil. This may be used where a ParametersAccessor value is
  1763. // required, but Parameters.Get may not succeed. In contexts where
  1764. // MakeNilParametersAccessor may be used, calls to ParametersAccessor must
  1765. // first check IsNil before calling accessor functions.
  1766. func MakeNilParametersAccessor() ParametersAccessor {
  1767. return ParametersAccessor{}
  1768. }
  1769. // IsNil indicates that this ParametersAccessor is a stub and its accessor
  1770. // functions may not be called. A ParametersAccessor produced by
  1771. // Parameters.Get will never return true for IsNil and IsNil guards are not
  1772. // required for ParametersAccessors known to be produced by Parameters.Get.
  1773. func (p ParametersAccessor) IsNil() bool {
  1774. return p.snapshot == nil
  1775. }
  1776. // Close clears internal references to large memory objects, allowing them to
  1777. // be garbage collected. Call Close when done using a ParametersAccessor,
  1778. // where memory footprint is a concern, and where the ParametersAccessor is
  1779. // not immediately going out of scope. After Close is called, all other
  1780. // ParametersAccessor functions will panic if called.
  1781. //
  1782. // Limitation: since ParametersAccessor is typically passed by value, this
  1783. // Close call only impacts the immediate copy.
  1784. func (p *ParametersAccessor) Close() {
  1785. p.snapshot = nil
  1786. }
  1787. // Tag returns the tag associated with these parameters.
  1788. func (p ParametersAccessor) Tag() string {
  1789. return p.snapshot.tag
  1790. }
  1791. // String returns a string parameter value.
  1792. func (p ParametersAccessor) String(name string) string {
  1793. value := ""
  1794. p.snapshot.getValue(name, &value)
  1795. return value
  1796. }
  1797. // Strings returns a []string parameter value. If multiple parameter names are
  1798. // specified, the first name with a non-empty value is used.
  1799. func (p ParametersAccessor) Strings(names ...string) []string {
  1800. for _, name := range names {
  1801. value := []string{}
  1802. p.snapshot.getValue(name, &value)
  1803. if len(value) > 0 {
  1804. return value
  1805. }
  1806. }
  1807. return []string{}
  1808. }
  1809. // Int returns an int parameter value.
  1810. func (p ParametersAccessor) Int(name string) int {
  1811. value := int(0)
  1812. p.snapshot.getValue(name, &value)
  1813. return value
  1814. }
  1815. // Bool returns a bool parameter value.
  1816. func (p ParametersAccessor) Bool(name string) bool {
  1817. value := false
  1818. p.snapshot.getValue(name, &value)
  1819. return value
  1820. }
  1821. // Float returns a float64 parameter value.
  1822. func (p ParametersAccessor) Float(name string) float64 {
  1823. value := float64(0.0)
  1824. p.snapshot.getValue(name, &value)
  1825. return value
  1826. }
  1827. // WeightedCoinFlip returns the result of prng.FlipWeightedCoin using the
  1828. // specified float parameter as the probability input.
  1829. func (p ParametersAccessor) WeightedCoinFlip(name string) bool {
  1830. var value float64
  1831. p.snapshot.getValue(name, &value)
  1832. return prng.FlipWeightedCoin(value)
  1833. }
  1834. // Duration returns a time.Duration parameter value. When the duration
  1835. // parameter has the useNetworkLatencyMultiplier flag, the
  1836. // NetworkLatencyMultiplier is applied to the returned value.
  1837. func (p ParametersAccessor) Duration(name string) time.Duration {
  1838. value := time.Duration(0)
  1839. p.snapshot.getValue(name, &value)
  1840. defaultParameter, ok := defaultParameters[name]
  1841. if value > 0 && ok && defaultParameter.flags&useNetworkLatencyMultiplier != 0 {
  1842. multiplier := float64(0.0)
  1843. if p.customNetworkLatencyMultiplier != 0.0 {
  1844. multiplier = p.customNetworkLatencyMultiplier
  1845. } else {
  1846. p.snapshot.getValue(NetworkLatencyMultiplier, &multiplier)
  1847. }
  1848. if multiplier > 0.0 {
  1849. value = time.Duration(float64(value) * multiplier)
  1850. }
  1851. }
  1852. return value
  1853. }
  1854. // TunnelProtocols returns a protocol.TunnelProtocols parameter value.
  1855. // If there is a corresponding Probability value, a weighted coin flip
  1856. // will be performed and, depending on the result, the value or the
  1857. // parameter default will be returned.
  1858. func (p ParametersAccessor) TunnelProtocols(name string) protocol.TunnelProtocols {
  1859. probabilityName := name + "Probability"
  1860. _, ok := p.snapshot.parameters[probabilityName]
  1861. if ok {
  1862. probabilityValue := float64(1.0)
  1863. p.snapshot.getValue(probabilityName, &probabilityValue)
  1864. if !prng.FlipWeightedCoin(probabilityValue) {
  1865. defaultParameter, ok := defaultParameters[name]
  1866. if ok {
  1867. defaultValue, ok := defaultParameter.value.(protocol.TunnelProtocols)
  1868. if ok {
  1869. value := make(protocol.TunnelProtocols, len(defaultValue))
  1870. copy(value, defaultValue)
  1871. return value
  1872. }
  1873. }
  1874. }
  1875. }
  1876. value := protocol.TunnelProtocols{}
  1877. p.snapshot.getValue(name, &value)
  1878. return value
  1879. }
  1880. // LabeledTunnelProtocols returns a protocol.TunnelProtocols parameter value
  1881. // corresponding to the specified labeled set and label value. The return
  1882. // value is nil when no set is found.
  1883. func (p ParametersAccessor) LabeledTunnelProtocols(name, label string) protocol.TunnelProtocols {
  1884. var value protocol.LabeledTunnelProtocols
  1885. p.snapshot.getValue(name, &value)
  1886. return value[label]
  1887. }
  1888. // TLSProfiles returns a protocol.TLSProfiles parameter value.
  1889. // If there is a corresponding Probability value, a weighted coin flip
  1890. // will be performed and, depending on the result, the value or the
  1891. // parameter default will be returned.
  1892. func (p ParametersAccessor) TLSProfiles(name string) protocol.TLSProfiles {
  1893. probabilityName := name + "Probability"
  1894. _, ok := p.snapshot.parameters[probabilityName]
  1895. if ok {
  1896. probabilityValue := float64(1.0)
  1897. p.snapshot.getValue(probabilityName, &probabilityValue)
  1898. if !prng.FlipWeightedCoin(probabilityValue) {
  1899. defaultParameter, ok := defaultParameters[name]
  1900. if ok {
  1901. defaultValue, ok := defaultParameter.value.(protocol.TLSProfiles)
  1902. if ok {
  1903. value := make(protocol.TLSProfiles, len(defaultValue))
  1904. copy(value, defaultValue)
  1905. return value
  1906. }
  1907. }
  1908. }
  1909. }
  1910. value := protocol.TLSProfiles{}
  1911. p.snapshot.getValue(name, &value)
  1912. return value
  1913. }
  1914. // LabeledTLSProfiles returns a protocol.TLSProfiles parameter value
  1915. // corresponding to the specified labeled set and label value. The return
  1916. // value is nil when no set is found.
  1917. func (p ParametersAccessor) LabeledTLSProfiles(name, label string) protocol.TLSProfiles {
  1918. var value protocol.LabeledTLSProfiles
  1919. p.snapshot.getValue(name, &value)
  1920. return value[label]
  1921. }
  1922. // QUICVersions returns a protocol.QUICVersions parameter value.
  1923. // If there is a corresponding Probability value, a weighted coin flip
  1924. // will be performed and, depending on the result, the value or the
  1925. // parameter default will be returned.
  1926. func (p ParametersAccessor) QUICVersions(name string) protocol.QUICVersions {
  1927. probabilityName := name + "Probability"
  1928. _, ok := p.snapshot.parameters[probabilityName]
  1929. if ok {
  1930. probabilityValue := float64(1.0)
  1931. p.snapshot.getValue(probabilityName, &probabilityValue)
  1932. if !prng.FlipWeightedCoin(probabilityValue) {
  1933. defaultParameter, ok := defaultParameters[name]
  1934. if ok {
  1935. defaultValue, ok := defaultParameter.value.(protocol.QUICVersions)
  1936. if ok {
  1937. value := make(protocol.QUICVersions, len(defaultValue))
  1938. copy(value, defaultValue)
  1939. return value
  1940. }
  1941. }
  1942. }
  1943. }
  1944. value := protocol.QUICVersions{}
  1945. p.snapshot.getValue(name, &value)
  1946. return value
  1947. }
  1948. // LabeledQUICVersions returns a protocol.QUICVersions parameter value
  1949. // corresponding to the specified labeled set and label value. The return
  1950. // value is nil when no set is found.
  1951. func (p ParametersAccessor) LabeledQUICVersions(name, label string) protocol.QUICVersions {
  1952. value := protocol.LabeledQUICVersions{}
  1953. p.snapshot.getValue(name, &value)
  1954. return value[label]
  1955. }
  1956. // TransferURLs returns a TransferURLs parameter value.
  1957. func (p ParametersAccessor) TransferURLs(name string) TransferURLs {
  1958. value := TransferURLs{}
  1959. p.snapshot.getValue(name, &value)
  1960. return value
  1961. }
  1962. // RateLimits returns a common.RateLimits parameter value.
  1963. func (p ParametersAccessor) RateLimits(name string) common.RateLimits {
  1964. value := common.RateLimits{}
  1965. p.snapshot.getValue(name, &value)
  1966. return value
  1967. }
  1968. // HTTPHeaders returns an http.Header parameter value.
  1969. func (p ParametersAccessor) HTTPHeaders(name string) http.Header {
  1970. value := make(http.Header)
  1971. p.snapshot.getValue(name, &value)
  1972. return value
  1973. }
  1974. // CustomTLSProfileNames returns the CustomTLSProfile.Name fields for
  1975. // each profile in the CustomTLSProfiles parameter value.
  1976. func (p ParametersAccessor) CustomTLSProfileNames() []string {
  1977. value := protocol.CustomTLSProfiles{}
  1978. p.snapshot.getValue(CustomTLSProfiles, &value)
  1979. names := make([]string, len(value))
  1980. for i := 0; i < len(value); i++ {
  1981. names[i] = value[i].Name
  1982. }
  1983. return names
  1984. }
  1985. // CustomTLSProfile returns the CustomTLSProfile fields with the specified
  1986. // Name field if it exists in the CustomTLSProfiles parameter value.
  1987. // Returns nil if not found.
  1988. func (p ParametersAccessor) CustomTLSProfile(name string) *protocol.CustomTLSProfile {
  1989. value := protocol.CustomTLSProfiles{}
  1990. p.snapshot.getValue(CustomTLSProfiles, &value)
  1991. // Note: linear lookup -- assumes a short list
  1992. for i := 0; i < len(value); i++ {
  1993. if value[i].Name == name {
  1994. return value[i]
  1995. }
  1996. }
  1997. return nil
  1998. }
  1999. // KeyValues returns a KeyValues parameter value.
  2000. func (p ParametersAccessor) KeyValues(name string) KeyValues {
  2001. value := KeyValues{}
  2002. p.snapshot.getValue(name, &value)
  2003. return value
  2004. }
  2005. // KeyStrings returns a KeyStrings parameter value.
  2006. func (p ParametersAccessor) KeyStrings(name, key string) []string {
  2007. value := KeyStrings{}
  2008. p.snapshot.getValue(name, &value)
  2009. return value[key]
  2010. }
  2011. // KeyStringsValue returns a complete KeyStrings parameter value.
  2012. func (p ParametersAccessor) KeyStringsValue(name string) KeyStrings {
  2013. value := KeyStrings{}
  2014. p.snapshot.getValue(name, &value)
  2015. return value
  2016. }
  2017. // KeyDurations returns a KeyDurations parameter value, with string durations
  2018. // converted to time.Duration.
  2019. func (p ParametersAccessor) KeyDurations(name string) map[string]time.Duration {
  2020. value := KeyDurations{}
  2021. p.snapshot.getValue(name, &value)
  2022. durations := make(map[string]time.Duration)
  2023. for key, duration := range value {
  2024. d, err := time.ParseDuration(duration)
  2025. if err != nil {
  2026. // Skip invalid duration. Not expected with validation.
  2027. continue
  2028. }
  2029. durations[key] = d
  2030. }
  2031. return durations
  2032. }
  2033. // BPFProgram returns an assembled BPF program corresponding to a
  2034. // BPFProgramSpec parameter value. Returns nil in the case of any empty
  2035. // program.
  2036. func (p ParametersAccessor) BPFProgram(name string) (bool, string, []bpf.RawInstruction) {
  2037. var value *BPFProgramSpec
  2038. p.snapshot.getValue(name, &value)
  2039. if value == nil {
  2040. return false, "", nil
  2041. }
  2042. // Validation checks that Assemble is successful.
  2043. rawInstructions, _ := value.Assemble()
  2044. return true, value.Name, rawInstructions
  2045. }
  2046. // PacketManipulationSpecs returns a PacketManipulationSpecs parameter value.
  2047. func (p ParametersAccessor) PacketManipulationSpecs(name string) PacketManipulationSpecs {
  2048. value := PacketManipulationSpecs{}
  2049. p.snapshot.getValue(name, &value)
  2050. return value
  2051. }
  2052. // ProtocolPacketManipulations returns a ProtocolPacketManipulations parameter value.
  2053. func (p ParametersAccessor) ProtocolPacketManipulations(name string) ProtocolPacketManipulations {
  2054. value := make(ProtocolPacketManipulations)
  2055. p.snapshot.getValue(name, &value)
  2056. return value
  2057. }
  2058. // RegexStrings returns a RegexStrings parameter value.
  2059. func (p ParametersAccessor) RegexStrings(name string) RegexStrings {
  2060. value := RegexStrings{}
  2061. p.snapshot.getValue(name, &value)
  2062. return value
  2063. }
  2064. // FrontingSpecs returns a FrontingSpecs parameter value.
  2065. func (p ParametersAccessor) FrontingSpecs(name string) FrontingSpecs {
  2066. value := FrontingSpecs{}
  2067. p.snapshot.getValue(name, &value)
  2068. return value
  2069. }
  2070. // TunnelProtocolPortLists returns a TunnelProtocolPortLists parameter value.
  2071. func (p ParametersAccessor) TunnelProtocolPortLists(name string) TunnelProtocolPortLists {
  2072. probabilityName := name + "Probability"
  2073. _, ok := p.snapshot.parameters[probabilityName]
  2074. if ok {
  2075. probabilityValue := float64(1.0)
  2076. p.snapshot.getValue(probabilityName, &probabilityValue)
  2077. if !prng.FlipWeightedCoin(probabilityValue) {
  2078. defaultParameter, ok := defaultParameters[name]
  2079. if ok {
  2080. defaultValue, ok := defaultParameter.value.(TunnelProtocolPortLists)
  2081. if ok {
  2082. value := make(TunnelProtocolPortLists)
  2083. for tunnelProtocol, portLists := range defaultValue {
  2084. value[tunnelProtocol] = portLists
  2085. }
  2086. return value
  2087. }
  2088. }
  2089. }
  2090. }
  2091. value := make(TunnelProtocolPortLists)
  2092. p.snapshot.getValue(name, &value)
  2093. return value
  2094. }
  2095. // LabeledCIDRs returns a CIDR string list parameter value corresponding to
  2096. // the specified labeled set and label value. The return value is nil when no
  2097. // set is found.
  2098. func (p ParametersAccessor) LabeledCIDRs(name, label string) []string {
  2099. value := LabeledCIDRs{}
  2100. p.snapshot.getValue(name, &value)
  2101. return value[label]
  2102. }
  2103. // ProtocolTransformSpecs returns a transforms.Specs parameter value.
  2104. func (p ParametersAccessor) ProtocolTransformSpecs(name string) transforms.Specs {
  2105. value := transforms.Specs{}
  2106. p.snapshot.getValue(name, &value)
  2107. return value
  2108. }
  2109. // ProtocolTransformScopedSpecNames returns a transforms.ScopedSpecNames
  2110. // parameter value.
  2111. func (p ParametersAccessor) ProtocolTransformScopedSpecNames(name string) transforms.ScopedSpecNames {
  2112. value := transforms.ScopedSpecNames{}
  2113. p.snapshot.getValue(name, &value)
  2114. return value
  2115. }
  2116. // ConjureTransports returns a protocol.ConjureTransports parameter value. If
  2117. // there is a corresponding Probability value, a weighted coin flip will be
  2118. // performed and, depending on the result, the value or the parameter default
  2119. // will be returned.
  2120. func (p ParametersAccessor) ConjureTransports(name string) protocol.ConjureTransports {
  2121. probabilityName := name + "Probability"
  2122. _, ok := p.snapshot.parameters[probabilityName]
  2123. if ok {
  2124. probabilityValue := float64(1.0)
  2125. p.snapshot.getValue(probabilityName, &probabilityValue)
  2126. if !prng.FlipWeightedCoin(probabilityValue) {
  2127. defaultParameter, ok := defaultParameters[name]
  2128. if ok {
  2129. defaultValue, ok := defaultParameter.value.(protocol.ConjureTransports)
  2130. if ok {
  2131. value := make(protocol.ConjureTransports, len(defaultValue))
  2132. copy(value, defaultValue)
  2133. return value
  2134. }
  2135. }
  2136. }
  2137. }
  2138. value := protocol.ConjureTransports{}
  2139. p.snapshot.getValue(name, &value)
  2140. return value
  2141. }
  2142. // InproxyBrokerSpecs returns a InproxyBrokerSpecs parameter value. If
  2143. // multiple parameter names are specified, the first name with a non-empty
  2144. // value is used.
  2145. func (p ParametersAccessor) InproxyBrokerSpecs(names ...string) InproxyBrokerSpecsValue {
  2146. for _, name := range names {
  2147. value := InproxyBrokerSpecsValue{}
  2148. p.snapshot.getValue(name, &value)
  2149. if len(value) > 0 {
  2150. return value
  2151. }
  2152. }
  2153. return InproxyBrokerSpecsValue{}
  2154. }
  2155. // InproxyBrokerSpecs returns a InproxyBrokerSpecs parameter value.
  2156. func (p ParametersAccessor) InproxyCompartmentIDs(name string) InproxyCompartmentIDsValue {
  2157. value := InproxyCompartmentIDsValue{}
  2158. p.snapshot.getValue(name, &value)
  2159. return value
  2160. }
  2161. // InproxyTrafficShapingParameters returns a InproxyTrafficShapingParameters
  2162. // parameter value.
  2163. func (p ParametersAccessor) InproxyTrafficShapingParameters(
  2164. name string) InproxyTrafficShapingParametersValue {
  2165. value := InproxyTrafficShapingParametersValue{}
  2166. p.snapshot.getValue(name, &value)
  2167. return value
  2168. }
  2169. func (p ParametersAccessor) LivenessTest(name string) LivenessTestSpecs {
  2170. value := make(LivenessTestSpecs)
  2171. p.snapshot.getValue(name, &value)
  2172. return value
  2173. }