parameters.go 116 KB

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