diff --git a/lib/cli/cli.js b/lib/cli/cli.js index 638740aed..04bd2fbd1 100644 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -403,6 +403,13 @@ module.exports.parseCommandLine = function parseCommandLine() { 'Run axe tests. Axe will run after all other metrics is collected and will add some extra time to each test.', group: 'Browser' }) + .option('browsertime.tcpdump', { + alias: 'tcpdump', + type: 'boolean', + default: false, + describe: + 'Collect a tcpdump for each tested URL. The user that runs sitespeed.io should have sudo rights for tcpdump to work.' + }) .option('browsertime.firefox.includeResponseBodies', { alias: 'firefox.includeResponseBodies', describe: 'Include response bodies in HAR', diff --git a/lib/plugins/html/templates/url/iteration/index.pug b/lib/plugins/html/templates/url/iteration/index.pug index 6f8dccbcf..24bc90b27 100644 --- a/lib/plugins/html/templates/url/iteration/index.pug +++ b/lib/plugins/html/templates/url/iteration/index.pug @@ -133,6 +133,7 @@ block content img.screenshot(src=screenshotName, width=width, alt='Screenshot') .downloads include ./downloads.pug + include ./tcpdump.pug if d.browsertime && d.browsertime.run && d.browsertime.run.har section#waterfall-panel include ../waterfall/index.pug diff --git a/lib/plugins/html/templates/url/iteration/tcpdump.pug b/lib/plugins/html/templates/url/iteration/tcpdump.pug new file mode 100644 index 000000000..b2c0db099 --- /dev/null +++ b/lib/plugins/html/templates/url/iteration/tcpdump.pug @@ -0,0 +1,6 @@ +if options.browsertime.tcpdump + - const tcpDumpPath = 'data/' + (runNumber? runNumber : 1) + '.pcap' + a.button.button-download(href=tcpDumpPath, download) Download tcpdump +if process.env.SSLKEYLOGFILE + - const sslKeyLogFile = process.env.SSLKEYLOGFILE + a.button.button-download(href=sslKeyLogFile, download) Download SSLKEYLOGFILE diff --git a/lib/plugins/html/templates/url/summary/index.pug b/lib/plugins/html/templates/url/summary/index.pug index ff9a58c62..19e4823b9 100644 --- a/lib/plugins/html/templates/url/summary/index.pug +++ b/lib/plugins/html/templates/url/summary/index.pug @@ -133,6 +133,7 @@ block content .downloads include ./downloads.pug + include ./tcpdump.pug if d.browsertime && d.browsertime.har section#waterfall-panel diff --git a/lib/plugins/html/templates/url/summary/tcpdump.pug b/lib/plugins/html/templates/url/summary/tcpdump.pug new file mode 100644 index 000000000..b2c0db099 --- /dev/null +++ b/lib/plugins/html/templates/url/summary/tcpdump.pug @@ -0,0 +1,6 @@ +if options.browsertime.tcpdump + - const tcpDumpPath = 'data/' + (runNumber? runNumber : 1) + '.pcap' + a.button.button-download(href=tcpDumpPath, download) Download tcpdump +if process.env.SSLKEYLOGFILE + - const sslKeyLogFile = process.env.SSLKEYLOGFILE + a.button.button-download(href=sslKeyLogFile, download) Download SSLKEYLOGFILE diff --git a/lib/sitespeed.js b/lib/sitespeed.js index 5038a9a96..4d08cd572 100644 --- a/lib/sitespeed.js +++ b/lib/sitespeed.js @@ -6,6 +6,7 @@ const log = require('intel').getLogger('sitespeedio'); const intel = require('intel'); const os = require('os'); const process = require('process'); +const path = require('path'); const logging = require('./core/logging'); const toArray = require('./support/util').toArray; const pullAll = require('lodash.pullall'); @@ -57,6 +58,17 @@ module.exports = { // Setup logging const logDir = await storageManager.createDirectory('logs'); + + if ( + options.browsertime && + options.browsertime.tcpdump && + !process.env.SSLKEYLOGFILE + ) { + process.env.SSLKEYLOGFILE = path.join( + storageManager.getBaseDir(), + 'SSLKEYLOGFILE.txt' + ); + } logging.configure(options, logDir); // Tell the world what we are using