parameters.go 116 KB

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