api.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. * Copyright (c) 2016, 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. package server
  20. import (
  21. "crypto/subtle"
  22. "encoding/json"
  23. "errors"
  24. "fmt"
  25. "net"
  26. "regexp"
  27. "strconv"
  28. "strings"
  29. "unicode"
  30. "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon"
  31. )
  32. const MAX_API_PARAMS_SIZE = 256 * 1024 // 256KB
  33. type requestJSONObject map[string]interface{}
  34. // sshAPIRequestHandler routes Psiphon API requests transported as
  35. // JSON objects via the SSH request mechanism.
  36. //
  37. // The API request handlers, handshakeAPIRequestHandler, etc., are
  38. // reused by webServer which offers the Psiphon API via web transport.
  39. //
  40. // The API request parameters and event log values follow the legacy
  41. // psi_web protocol and naming conventions. The API is compatible all
  42. // tunnel-core clients but are not backwards compatible with older
  43. // clients.
  44. //
  45. func sshAPIRequestHandler(
  46. config *Config,
  47. psinetDatabase *PsinetDatabase,
  48. geoIPData GeoIPData,
  49. name string,
  50. requestPayload []byte) ([]byte, error) {
  51. // Note: for SSH requests, MAX_API_PARAMS_SIZE is implicitly enforced
  52. // by max SSH reqest packet size.
  53. var params requestJSONObject
  54. err := json.Unmarshal(requestPayload, &params)
  55. if err != nil {
  56. return nil, psiphon.ContextError(err)
  57. }
  58. switch name {
  59. case psiphon.SERVER_API_HANDSHAKE_REQUEST_NAME:
  60. return handshakeAPIRequestHandler(config, psinetDatabase, geoIPData, params)
  61. case psiphon.SERVER_API_CONNECTED_REQUEST_NAME:
  62. return connectedAPIRequestHandler(config, geoIPData, params)
  63. case psiphon.SERVER_API_STATUS_REQUEST_NAME:
  64. return statusAPIRequestHandler(config, geoIPData, params)
  65. case psiphon.SERVER_API_CLIENT_VERIFICATION_REQUEST_NAME:
  66. return clientVerificationAPIRequestHandler(config, geoIPData, params)
  67. }
  68. return nil, psiphon.ContextError(fmt.Errorf("invalid request name: %s", name))
  69. }
  70. // handshakeAPIRequestHandler implements the "handshake" API request.
  71. // Clients make the handshake immediately after establishing a tunnel
  72. // connection; the response tells the client what homepage to open, what
  73. // stats to record, etc.
  74. func handshakeAPIRequestHandler(
  75. config *Config,
  76. psinetDatabase *PsinetDatabase,
  77. geoIPData GeoIPData,
  78. params requestJSONObject) ([]byte, error) {
  79. // Note: ignoring "known_servers" params
  80. err := validateRequestParams(config, params, baseRequestParams)
  81. if err != nil {
  82. // TODO: fail2ban?
  83. return nil, psiphon.ContextError(errors.New("invalid params"))
  84. }
  85. log.WithContextFields(
  86. getRequestLogFields(
  87. config,
  88. "handshake",
  89. geoIPData,
  90. params,
  91. baseRequestParams)).Info("API event")
  92. // TODO: share struct definition with psiphon/serverApi.go?
  93. var handshakeResponse struct {
  94. Homepages []string `json:"homepages"`
  95. UpgradeClientVersion string `json:"upgrade_client_version"`
  96. PageViewRegexes []map[string]string `json:"page_view_regexes"`
  97. HttpsRequestRegexes []map[string]string `json:"https_request_regexes"`
  98. EncodedServerList []string `json:"encoded_server_list"`
  99. ClientRegion string `json:"client_region"`
  100. ServerTimestamp string `json:"server_timestamp"`
  101. }
  102. // Ignoring errors as params are validated
  103. sponsorID, _ := getStringRequestParam(params, "sponsor_id")
  104. propagationChannelID, _ := getStringRequestParam(params, "propagation_channel_id")
  105. clientVersion, _ := getStringRequestParam(params, "client_version")
  106. clientPlatform, _ := getStringRequestParam(params, "client_platform")
  107. clientRegion := geoIPData.Country
  108. handshakeResponse.Homepages = psinetDatabase.GetHomepages(
  109. sponsorID, clientRegion, clientPlatform)
  110. handshakeResponse.UpgradeClientVersion = psinetDatabase.GetUpgradeClientVersion(
  111. clientVersion, clientPlatform)
  112. handshakeResponse.HttpsRequestRegexes = psinetDatabase.GetHttpsRequestRegexes(
  113. sponsorID)
  114. handshakeResponse.EncodedServerList = psinetDatabase.DiscoverServers(
  115. propagationChannelID, geoIPData.DiscoveryValue)
  116. handshakeResponse.ClientRegion = clientRegion
  117. handshakeResponse.ServerTimestamp = psiphon.GetCurrentTimestamp()
  118. responsePayload, err := json.Marshal(handshakeResponse)
  119. if err != nil {
  120. return nil, psiphon.ContextError(err)
  121. }
  122. return responsePayload, nil
  123. }
  124. var connectedRequestParams = append(
  125. []requestParamSpec{requestParamSpec{"last_connected", isLastConnected, 0}},
  126. baseRequestParams...)
  127. // connectedAPIRequestHandler implements the "connected" API request.
  128. // Clients make the connected request once a tunnel connection has been
  129. // established and at least once per day. The last_connected input value,
  130. // which should be a connected_timestamp output from a previous connected
  131. // response, is used to calculate unique user stats.
  132. func connectedAPIRequestHandler(
  133. config *Config, geoIPData GeoIPData, params requestJSONObject) ([]byte, error) {
  134. err := validateRequestParams(config, params, connectedRequestParams)
  135. if err != nil {
  136. // TODO: fail2ban?
  137. return nil, psiphon.ContextError(errors.New("invalid params"))
  138. }
  139. log.WithContextFields(
  140. getRequestLogFields(
  141. config,
  142. "connected",
  143. geoIPData,
  144. params,
  145. connectedRequestParams)).Info("API event")
  146. var connectedResponse struct {
  147. ConnectedTimestamp string `json:"connected_timestamp"`
  148. }
  149. connectedResponse.ConnectedTimestamp =
  150. psiphon.TruncateTimestampToHour(psiphon.GetCurrentTimestamp())
  151. responsePayload, err := json.Marshal(connectedResponse)
  152. if err != nil {
  153. return nil, psiphon.ContextError(err)
  154. }
  155. return responsePayload, nil
  156. }
  157. var statusRequestParams = append(
  158. []requestParamSpec{requestParamSpec{"connected", isBooleanFlag, 0}},
  159. baseRequestParams...)
  160. // statusAPIRequestHandler implements the "status" API request.
  161. // Clients make periodic status requests which deliver client-side
  162. // recorded data transfer and tunnel duration stats.
  163. // Note from psi_web implementation: no input validation on domains;
  164. // any string is accepted (regex transform may result in arbitrary
  165. // string). Stats processor must handle this input with care.
  166. func statusAPIRequestHandler(
  167. config *Config, geoIPData GeoIPData, params requestJSONObject) ([]byte, error) {
  168. err := validateRequestParams(config, params, statusRequestParams)
  169. if err != nil {
  170. // TODO: fail2ban?
  171. return nil, psiphon.ContextError(errors.New("invalid params"))
  172. }
  173. statusData, err := getJSONObjectRequestParam(params, "statusData")
  174. if err != nil {
  175. return nil, psiphon.ContextError(err)
  176. }
  177. // Overall bytes transferred stats
  178. bytesTransferred, err := getInt64RequestParam(statusData, "bytes_transferred")
  179. if err != nil {
  180. return nil, psiphon.ContextError(err)
  181. }
  182. bytesTransferredFields := getRequestLogFields(
  183. config, "bytes_transferred", geoIPData, params, statusRequestParams)
  184. bytesTransferredFields["bytes"] = bytesTransferred
  185. log.WithContextFields(bytesTransferredFields).Info("API event")
  186. // Domain bytes transferred stats
  187. hostBytes, err := getMapStringInt64RequestParam(statusData, "host_bytes")
  188. if err != nil {
  189. return nil, psiphon.ContextError(err)
  190. }
  191. domainBytesFields := getRequestLogFields(
  192. config, "domain_bytes", geoIPData, params, statusRequestParams)
  193. for domain, bytes := range hostBytes {
  194. domainBytesFields["domain"] = domain
  195. domainBytesFields["bytes"] = bytes
  196. log.WithContextFields(domainBytesFields).Info("API event")
  197. }
  198. // Tunnel duration and bytes transferred stats
  199. tunnelStats, err := getJSONObjectArrayRequestParam(statusData, "tunnel_stats")
  200. if err != nil {
  201. return nil, psiphon.ContextError(err)
  202. }
  203. sessionFields := getRequestLogFields(
  204. config, "session", geoIPData, params, statusRequestParams)
  205. for _, tunnelStat := range tunnelStats {
  206. sessionID, err := getStringRequestParam(tunnelStat, "session_id")
  207. if err != nil {
  208. return nil, psiphon.ContextError(err)
  209. }
  210. sessionFields["session_id"] = sessionID
  211. tunnelNumber, err := getInt64RequestParam(tunnelStat, "tunnel_number")
  212. if err != nil {
  213. return nil, psiphon.ContextError(err)
  214. }
  215. sessionFields["tunnel_number"] = tunnelNumber
  216. tunnelServerIPAddress, err := getStringRequestParam(tunnelStat, "tunnel_server_ip_address")
  217. if err != nil {
  218. return nil, psiphon.ContextError(err)
  219. }
  220. sessionFields["tunnel_server_ip_address"] = tunnelServerIPAddress
  221. serverHandshakeTimestamp, err := getStringRequestParam(tunnelStat, "server_handshake_timestamp")
  222. if err != nil {
  223. return nil, psiphon.ContextError(err)
  224. }
  225. sessionFields["server_handshake_timestamp"] = serverHandshakeTimestamp
  226. duration, err := getInt64RequestParam(tunnelStat, "duration")
  227. if err != nil {
  228. return nil, psiphon.ContextError(err)
  229. }
  230. // Client reports durations in nanoseconds; divide to get to milliseconds
  231. sessionFields["duration"] = duration / 1000000
  232. totalBytesSent, err := getInt64RequestParam(tunnelStat, "total_bytes_sent")
  233. if err != nil {
  234. return nil, psiphon.ContextError(err)
  235. }
  236. sessionFields["total_bytes_sent"] = totalBytesSent
  237. totalBytesReceived, err := getInt64RequestParam(tunnelStat, "total_bytes_received")
  238. if err != nil {
  239. return nil, psiphon.ContextError(err)
  240. }
  241. sessionFields["total_bytes_received"] = totalBytesReceived
  242. log.WithContextFields(sessionFields).Info("API event")
  243. }
  244. return make([]byte, 0), nil
  245. }
  246. // clientVerificationAPIRequestHandler implements the
  247. // "client verification" API request. Clients make the client
  248. // verification request once per tunnel connection. The payload
  249. // attests that client is a legitimate Psiphon client.
  250. func clientVerificationAPIRequestHandler(
  251. config *Config, geoIPData GeoIPData, params requestJSONObject) ([]byte, error) {
  252. err := validateRequestParams(config, params, baseRequestParams)
  253. if err != nil {
  254. // TODO: fail2ban?
  255. return nil, psiphon.ContextError(errors.New("invalid params"))
  256. }
  257. // TODO: implement
  258. return make([]byte, 0), nil
  259. }
  260. type requestParamSpec struct {
  261. name string
  262. validator func(*Config, string) bool
  263. flags int32
  264. }
  265. const (
  266. requestParamOptional = 1
  267. requestParamNotLogged = 2
  268. )
  269. // baseRequestParams is the list of required and optional
  270. // request parameters; derived from COMMON_INPUTS and
  271. // OPTIONAL_COMMON_INPUTS in psi_web.
  272. var baseRequestParams = []requestParamSpec{
  273. requestParamSpec{"server_secret", isServerSecret, requestParamNotLogged},
  274. requestParamSpec{"client_session_id", isHexDigits, 0},
  275. requestParamSpec{"propagation_channel_id", isHexDigits, 0},
  276. requestParamSpec{"sponsor_id", isHexDigits, 0},
  277. requestParamSpec{"client_version", isDigits, 0},
  278. requestParamSpec{"client_platform", isClientPlatform, 0},
  279. requestParamSpec{"relay_protocol", isRelayProtocol, 0},
  280. requestParamSpec{"tunnel_whole_device", isBooleanFlag, 0},
  281. requestParamSpec{"device_region", isRegionCode, requestParamOptional},
  282. requestParamSpec{"meek_dial_address", isDialAddress, requestParamOptional},
  283. requestParamSpec{"meek_resolved_ip_address", isIPAddress, requestParamOptional},
  284. requestParamSpec{"meek_sni_server_name", isDomain, requestParamOptional},
  285. requestParamSpec{"meek_host_header", isHostHeader, requestParamOptional},
  286. requestParamSpec{"meek_transformed_host_name", isBooleanFlag, requestParamOptional},
  287. requestParamSpec{"server_entry_region", isRegionCode, requestParamOptional},
  288. requestParamSpec{"server_entry_source", isServerEntrySource, requestParamOptional},
  289. requestParamSpec{"server_entry_timestamp", isISO8601Date, requestParamOptional},
  290. }
  291. func validateRequestParams(
  292. config *Config,
  293. params requestJSONObject,
  294. expectedParams []requestParamSpec) error {
  295. for _, expectedParam := range expectedParams {
  296. value := params[expectedParam.name]
  297. if value == nil {
  298. if expectedParam.flags&requestParamOptional != 0 {
  299. continue
  300. }
  301. return psiphon.ContextError(
  302. fmt.Errorf("missing required param: %s", expectedParam.name))
  303. }
  304. strValue, ok := value.(string)
  305. if !ok {
  306. return psiphon.ContextError(
  307. fmt.Errorf("unexpected param type: %s", expectedParam.name))
  308. }
  309. if !expectedParam.validator(config, strValue) {
  310. return psiphon.ContextError(
  311. fmt.Errorf("invalid param: %s", expectedParam.name))
  312. }
  313. }
  314. return nil
  315. }
  316. // getRequestLogFields makes LogFields to log the API event following
  317. // the legacy psi_web and current ELK naming conventions.
  318. func getRequestLogFields(
  319. config *Config,
  320. eventName string,
  321. geoIPData GeoIPData,
  322. params requestJSONObject,
  323. expectedParams []requestParamSpec) LogFields {
  324. logFields := make(LogFields)
  325. logFields["event_name"] = eventName
  326. logFields["host_id"] = config.HostID
  327. // In psi_web, the space replacement was done to accommodate space
  328. // delimited logging, which is no longer required; we retain the
  329. // transformation so that stats aggregation isn't impacted.
  330. logFields["client_region"] = strings.Replace(geoIPData.Country, " ", "_", -1)
  331. logFields["client_city"] = strings.Replace(geoIPData.City, " ", "_", -1)
  332. logFields["client_isp"] = strings.Replace(geoIPData.ISP, " ", "_", -1)
  333. for _, expectedParam := range expectedParams {
  334. if expectedParam.flags&requestParamNotLogged != 0 {
  335. continue
  336. }
  337. value := params[expectedParam.name]
  338. if value == nil {
  339. // Skip optional params
  340. continue
  341. }
  342. strValue, ok := value.(string)
  343. if !ok {
  344. // This type assertion should be checked already in
  345. // validateRequestParams, so failure is unexpected.
  346. continue
  347. }
  348. // Special cases:
  349. // - Number fields are encoded as integer types.
  350. // - For ELK performance we record these domain-or-IP
  351. // fields as one of two different values based on type;
  352. // we also omit port from host:port fields for now.
  353. switch expectedParam.name {
  354. case "client_version":
  355. intValue, _ := strconv.Atoi(strValue)
  356. logFields[expectedParam.name] = intValue
  357. case "meek_dial_address":
  358. host, _, _ := net.SplitHostPort(strValue)
  359. if isIPAddress(config, host) {
  360. logFields["meek_dial_ip_address"] = host
  361. } else {
  362. logFields["meek_dial_domain"] = host
  363. }
  364. case "meek_host_header":
  365. host, _, _ := net.SplitHostPort(strValue)
  366. logFields[expectedParam.name] = host
  367. default:
  368. logFields[expectedParam.name] = strValue
  369. }
  370. }
  371. return logFields
  372. }
  373. func getStringRequestParam(params requestJSONObject, name string) (string, error) {
  374. if params[name] == nil {
  375. return "", psiphon.ContextError(errors.New("missing param"))
  376. }
  377. value, ok := params[name].(string)
  378. if !ok {
  379. return "", psiphon.ContextError(errors.New("invalid param"))
  380. }
  381. return value, nil
  382. }
  383. func getInt64RequestParam(params requestJSONObject, name string) (int64, error) {
  384. if params[name] == nil {
  385. return 0, psiphon.ContextError(errors.New("missing param"))
  386. }
  387. value, ok := params[name].(int64)
  388. if !ok {
  389. return 0, psiphon.ContextError(errors.New("invalid param"))
  390. }
  391. return value, nil
  392. }
  393. func getJSONObjectRequestParam(params requestJSONObject, name string) (requestJSONObject, error) {
  394. if params[name] == nil {
  395. return nil, psiphon.ContextError(errors.New("missing param"))
  396. }
  397. value, ok := params[name].(requestJSONObject)
  398. if !ok {
  399. return nil, psiphon.ContextError(errors.New("invalid param"))
  400. }
  401. return value, nil
  402. }
  403. func getJSONObjectArrayRequestParam(params requestJSONObject, name string) ([]requestJSONObject, error) {
  404. if params[name] == nil {
  405. return nil, psiphon.ContextError(errors.New("missing param"))
  406. }
  407. value, ok := params[name].([]requestJSONObject)
  408. if !ok {
  409. return nil, psiphon.ContextError(errors.New("invalid param"))
  410. }
  411. return value, nil
  412. }
  413. func getMapStringInt64RequestParam(params requestJSONObject, name string) (map[string]int64, error) {
  414. if params[name] == nil {
  415. return nil, psiphon.ContextError(errors.New("missing param"))
  416. }
  417. value, ok := params[name].(map[string]int64)
  418. if !ok {
  419. return nil, psiphon.ContextError(errors.New("invalid param"))
  420. }
  421. return value, nil
  422. }
  423. // Input validators follow the legacy validations rules in psi_web.
  424. func isServerSecret(config *Config, value string) bool {
  425. return subtle.ConstantTimeCompare(
  426. []byte(value),
  427. []byte(config.WebServerSecret)) == 1
  428. }
  429. func isHexDigits(_ *Config, value string) bool {
  430. return -1 == strings.IndexFunc(value, func(c rune) bool {
  431. return !unicode.Is(unicode.ASCII_Hex_Digit, c)
  432. })
  433. }
  434. func isDigits(_ *Config, value string) bool {
  435. return -1 == strings.IndexFunc(value, func(c rune) bool {
  436. return c < '0' || c > '9'
  437. })
  438. }
  439. func isClientPlatform(_ *Config, value string) bool {
  440. return -1 == strings.IndexFunc(value, func(c rune) bool {
  441. // Note: stricter than psi_web's Python string.whitespace
  442. return unicode.Is(unicode.White_Space, c)
  443. })
  444. }
  445. func isRelayProtocol(_ *Config, value string) bool {
  446. return psiphon.Contains(psiphon.SupportedTunnelProtocols, value)
  447. }
  448. func isBooleanFlag(_ *Config, value string) bool {
  449. return value == "0" || value == "1"
  450. }
  451. func isRegionCode(_ *Config, value string) bool {
  452. if len(value) != 2 {
  453. return false
  454. }
  455. return -1 == strings.IndexFunc(value, func(c rune) bool {
  456. return c < 'A' || c > 'Z'
  457. })
  458. }
  459. func isDialAddress(config *Config, value string) bool {
  460. // "<host>:<port>", where <host> is a domain or IP address
  461. parts := strings.Split(value, ":")
  462. if len(parts) != 2 {
  463. return false
  464. }
  465. if !isIPAddress(config, parts[0]) && !isDomain(config, parts[0]) {
  466. return false
  467. }
  468. if !isDigits(config, parts[1]) {
  469. return false
  470. }
  471. port, err := strconv.Atoi(parts[1])
  472. if err != nil {
  473. return false
  474. }
  475. return port > 0 && port < 65536
  476. }
  477. func isIPAddress(_ *Config, value string) bool {
  478. return net.ParseIP(value) != nil
  479. }
  480. var isDomainRegex = regexp.MustCompile("[a-zA-Z\\d-]{1,63}$")
  481. func isDomain(_ *Config, value string) bool {
  482. // From: http://stackoverflow.com/questions/2532053/validate-a-hostname-string
  483. //
  484. // "ensures that each segment
  485. // * contains at least one character and a maximum of 63 characters
  486. // * consists only of allowed characters
  487. // * doesn't begin or end with a hyphen"
  488. //
  489. if len(value) > 255 {
  490. return false
  491. }
  492. value = strings.TrimSuffix(value, ".")
  493. for _, part := range strings.Split(value, ".") {
  494. // Note: regexp doesn't support the following Perl expression which
  495. // would check for '-' prefix/suffix: "(?!-)[a-zA-Z\\d-]{1,63}(?<!-)$"
  496. if strings.HasPrefix(part, "-") || strings.HasSuffix(part, "-") {
  497. return false
  498. }
  499. if !isDomainRegex.Match([]byte(part)) {
  500. return false
  501. }
  502. }
  503. return true
  504. }
  505. func isHostHeader(config *Config, value string) bool {
  506. // "<host>:<port>", where <host> is a domain or IP address and ":<port>" is optional
  507. if strings.Contains(value, ":") {
  508. return isDialAddress(config, value)
  509. }
  510. return isIPAddress(config, value) || isDomain(config, value)
  511. }
  512. func isServerEntrySource(_ *Config, value string) bool {
  513. return psiphon.Contains(psiphon.SupportedServerEntrySources, value)
  514. }
  515. var isISO8601DateRegex = regexp.MustCompile(
  516. "(?P<year>[0-9]{4})-(?P<month>[0-9]{1,2})-(?P<day>[0-9]{1,2})T(?P<hour>[0-9]{2}):(?P<minute>[0-9]{2}):(?P<second>[0-9]{2})(\\.(?P<fraction>[0-9]+))?(?P<timezone>Z|(([-+])([0-9]{2}):([0-9]{2})))")
  517. func isISO8601Date(_ *Config, value string) bool {
  518. return isISO8601DateRegex.Match([]byte(value))
  519. }
  520. func isLastConnected(config *Config, value string) bool {
  521. return value == "None" || value == "Unknown" || isISO8601Date(config, value)
  522. }