parameters.go 113 KB

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