OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // TODO(eroman): put these methods into a namespace. | 5 // TODO(eroman): put these methods into a namespace. |
6 | 6 |
7 var createLogEntryTablePrinter; | 7 var createLogEntryTablePrinter; |
8 var proxySettingsToString; | 8 var proxySettingsToString; |
9 var stripPrivacyInfo; | 9 var stripPrivacyInfo; |
10 | 10 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 case EventType.PROXY_CONFIG_CHANGED: | 285 case EventType.PROXY_CONFIG_CHANGED: |
286 return writeParamsForProxyConfigChanged; | 286 return writeParamsForProxyConfigChanged; |
287 | 287 |
288 case EventType.CERT_VERIFIER_JOB: | 288 case EventType.CERT_VERIFIER_JOB: |
289 case EventType.SSL_CERTIFICATES_RECEIVED: | 289 case EventType.SSL_CERTIFICATES_RECEIVED: |
290 return writeParamsForCertificates; | 290 return writeParamsForCertificates; |
291 case EventType.CERT_CT_COMPLIANCE_CHECKED: | 291 case EventType.CERT_CT_COMPLIANCE_CHECKED: |
292 case EventType.EV_CERT_CT_COMPLIANCE_CHECKED: | 292 case EventType.EV_CERT_CT_COMPLIANCE_CHECKED: |
293 return writeParamsForCheckedCertificates; | 293 return writeParamsForCheckedCertificates; |
294 | |
295 case EventType.SSL_VERSION_FALLBACK: | |
296 return writeParamsForSSLVersionFallback; | |
297 } | 294 } |
298 return null; | 295 return null; |
299 } | 296 } |
300 | 297 |
301 /** | 298 /** |
302 * Default parameter writer that outputs a visualization of field named |key| | 299 * Default parameter writer that outputs a visualization of field named |key| |
303 * with value |value| to |out|. | 300 * with value |value| to |out|. |
304 */ | 301 */ |
305 function defaultWriteParameter(key, value, out) { | 302 function defaultWriteParameter(key, value, out) { |
306 if (key == 'headers' && value instanceof Array) { | 303 if (key == 'headers' && value instanceof Array) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 } | 396 } |
400 | 397 |
401 // If no flags were matched, returns a special value. | 398 // If no flags were matched, returns a special value. |
402 if (matchingFlagNames.length == 0) | 399 if (matchingFlagNames.length == 0) |
403 return zeroName; | 400 return zeroName; |
404 | 401 |
405 return matchingFlagNames.join(' | '); | 402 return matchingFlagNames.join(' | '); |
406 } | 403 } |
407 | 404 |
408 /** | 405 /** |
409 * Converts an SSL version number to a textual representation. | |
410 * For instance, SSLVersionNumberToName(0x0301) returns 'TLS 1.0'. | |
411 */ | |
412 function SSLVersionNumberToName(version) { | |
413 if ((version & 0xFFFF) != version) { | |
414 // If the version number is more than 2 bytes long something is wrong. | |
415 // Print it as hex. | |
416 return 'SSL 0x' + version.toString(16); | |
417 } | |
418 | |
419 // See if it is a known TLS name. | |
420 var kTLSNames = {0x0301: 'TLS 1.0', 0x0302: 'TLS 1.1', 0x0303: 'TLS 1.2'}; | |
421 var name = kTLSNames[version]; | |
422 if (name) | |
423 return name; | |
424 | |
425 // Otherwise label it as an SSL version. | |
426 var major = (version & 0xFF00) >> 8; | |
427 var minor = version & 0x00FF; | |
428 | |
429 return 'SSL ' + major + '.' + minor; | |
430 } | |
431 | |
432 /** | |
433 * TODO(eroman): get rid of this, as it is only used by 1 callsite. | 406 * TODO(eroman): get rid of this, as it is only used by 1 callsite. |
434 * | 407 * |
435 * Indent |lines| by |start|. | 408 * Indent |lines| by |start|. |
436 * | 409 * |
437 * For example, if |start| = ' -> ' and |lines| = ['line1', 'line2', 'line3'] | 410 * For example, if |start| = ' -> ' and |lines| = ['line1', 'line2', 'line3'] |
438 * the output will be: | 411 * the output will be: |
439 * | 412 * |
440 * " -> line1\n" + | 413 * " -> line1\n" + |
441 * " line2\n" + | 414 * " line2\n" + |
442 * " line3" | 415 * " line3" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 consumedParams.cert_status = true; | 623 consumedParams.cert_status = true; |
651 } | 624 } |
652 } | 625 } |
653 | 626 |
654 function writeParamsForCheckedCertificates(entry, out, consumedParams) { | 627 function writeParamsForCheckedCertificates(entry, out, consumedParams) { |
655 if (typeof(entry.params.certificate) == 'object') | 628 if (typeof(entry.params.certificate) == 'object') |
656 writeCertificateParam( | 629 writeCertificateParam( |
657 entry.params.certificate, out, consumedParams, 'certificate'); | 630 entry.params.certificate, out, consumedParams, 'certificate'); |
658 } | 631 } |
659 | 632 |
660 /** | |
661 * Outputs the SSL version fallback parameters of |entry| to |out|. | |
662 */ | |
663 function writeParamsForSSLVersionFallback(entry, out, consumedParams) { | |
664 var params = entry.params; | |
665 | |
666 if (typeof params.version_before != 'number' || | |
667 typeof params.version_after != 'number') { | |
668 // Unrecognized params. | |
669 return; | |
670 } | |
671 | |
672 var line = SSLVersionNumberToName(params.version_before) + ' ==> ' + | |
673 SSLVersionNumberToName(params.version_after); | |
674 out.writeArrowIndentedLines([line]); | |
675 | |
676 consumedParams.version_before = true; | |
677 consumedParams.version_after = true; | |
678 } | |
679 | |
680 function writeParamsForProxyConfigChanged(entry, out, consumedParams) { | 633 function writeParamsForProxyConfigChanged(entry, out, consumedParams) { |
681 var params = entry.params; | 634 var params = entry.params; |
682 | 635 |
683 if (typeof params.new_config != 'object') { | 636 if (typeof params.new_config != 'object') { |
684 // Unrecognized params. | 637 // Unrecognized params. |
685 return; | 638 return; |
686 } | 639 } |
687 | 640 |
688 if (typeof params.old_config == 'object') { | 641 if (typeof params.old_config == 'object') { |
689 var oldConfigString = proxySettingsToString(params.old_config); | 642 var oldConfigString = proxySettingsToString(params.old_config); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 } | 758 } |
806 | 759 |
807 if (config.source != undefined && config.source != 'UNKNOWN') | 760 if (config.source != undefined && config.source != 'UNKNOWN') |
808 result.push('Source: ' + config.source); | 761 result.push('Source: ' + config.source); |
809 | 762 |
810 return result.join('\n'); | 763 return result.join('\n'); |
811 }; | 764 }; |
812 | 765 |
813 // End of anonymous namespace. | 766 // End of anonymous namespace. |
814 })(); | 767 })(); |
OLD | NEW |