parameters.go 124 KB

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