parameters.go 123 KB

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