parameters.go 115 KB

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