parameters.go 99 KB

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