@vpalmisano/webrtcperf 4.7.9 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -808,6 +808,7 @@ alert will be successful only when at least 95% of the checks pass.`,
808
808
  doc: `The HTTP server basic auth secret. The auth user name is set to \`admin\` by default.`,
809
809
  format: String,
810
810
  default: 'secret',
811
+ nullable: true,
811
812
  env: 'SERVER_SECRET',
812
813
  arg: 'server-secret',
813
814
  },
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAo5BA,sCAEC;AAOD,gDA2BC;AAWD,gCA6CC;AA8BD,oDA2BC;AAziCD,mDAAwD;AACxD,6BAAuB;AACvB,iFAA8D;AAC9D,2BAA+B;AAC/B,4CAAmB;AACnB,6CAAiC;AACjC,kDAAyB;AACzB,gDAAuB;AACvB,gDAAuB;AACvB,4CAAmB;AAEnB,iEAAiE;AACjE,MAAM,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAE3C,mCAA6C;AAC7C,MAAM,GAAG,GAAG,IAAA,cAAM,EAAC,mBAAmB,CAAC,CAAA;AAEvC,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACpC,QAAQ,EAAE,CAAC,CAAS,EAAE,EAAE;QACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;CACF,CAAA;AAED,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC;IACzB,QAAQ,EAAE,CAAC,CAA4B,EAAE,E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z } from 'zod'\nimport { ipaddress, url } from 'convict-format-with-validator'\nimport { existsSync } from 'fs'\nimport os from 'os'\nimport path, { join } from 'path'\nimport json5 from 'json5'\nimport yaml from 'yaml'\nimport toml from 'toml'\nimport fs from 'fs'\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst puppeteer = require('puppeteer-core')\n\nimport { downloadUrl, logger } from './utils'\nconst log = logger('webrtcperf:config')\n\nconst float = {\n name: 'float',\n coerce: (v: string) => parseFloat(v),\n validate: (v: number) => {\n if (!Number.isFinite(v)) throw new Error(`Invalid float: ${v}`)\n },\n}\n\nconst index = {\n name: 'index',\n coerce: (v: unknown) => v,\n validate: (v: boolean | string | number) => {\n if (typeof v === 'string') {\n if (v === 'true' || v === 'false' || v === '') return\n if (v.includes('-')) {\n v.split('-').forEach(n => {\n if (isNaN(parseInt(n)) || !isFinite(parseInt(n))) throw new Error(`Invalid string index: ${n}`)\n })\n return\n }\n if (v.includes(',')) {\n v.split(',').forEach(n => {\n if (isNaN(parseInt(n)) || !isFinite(parseInt(n))) throw new Error(`Invalid string index: ${n}`)\n })\n return\n }\n if (isNaN(parseInt(v)) || !isFinite(parseInt(v))) throw new Error(`Invalid string index: ${v}`)\n return\n } else if (typeof v === 'number' || typeof v === 'boolean') {\n return\n }\n throw new Error(`Invalid index: \"${v}\" (type: ${typeof v})`)\n },\n}\n\naddFormats({ ipaddress, url, float, index })\n\nconvict.addParser([\n { extension: 'json', parse: json5.parse },\n { extension: ['yml', 'yaml'], parse: yaml.parse },\n { extension: 'toml', parse: toml.parse },\n])\n\nconst configSchema = {\n url: {\n doc: `The page url to load.`,\n format: String,\n default: '',\n nullable: true,\n env: 'URL',\n arg: 'url',\n },\n urlQuery: {\n doc: `The query string to append to the page url; the following template \\\nvariables are replaced: \\`$p\\` the process pid, \\`$s\\` the session index, \\\n\\`$S\\` the total sessions, \\`$t\\` the tab index, \\`$T\\` the total tabs per \\\nsession, \\`$i\\` the tab absolute index.`,\n format: String,\n default: '',\n nullable: true,\n env: 'URL_QUERY',\n arg: 'url-query',\n },\n customUrlHandler: {\n doc: `This argument specifies the file path for the custom page URL handler that will be exported by default. \\\nThe custom page URL handler allows you to define custom URLs that can be used to open your application. \\\nThe handler function will be called with the following variables: \\\n- sessions: the total number of sessions; \\\n- tabsPerSession: the total number of tabs per session; \\\n- id: the session global index (0-indexed); \\\n- index: the tab global index (0-indexed); \\\n- tabIndex: the tab index in the current session (0-indexed); \\\n- pid: the process pid; \\\n- env: the environment variables object; \\\n- params: the script parameters object. \\\nYou can use these variables to create custom URL schemes that suit your application's needs.`,\n format: String,\n default: '',\n nullable: true,\n env: 'CUSTOM_URL_HANDLER',\n arg: 'custom-url-handler',\n },\n // fake video/audio\n videoPath: {\n doc: `The fake video path; if set, the video will be used as fake \\\nmedia source. It accepts a single path or a comma-separated list of videos \\\npaths that will be used in round-robin by the started sessions. \\\nThe docker pre-built image contains a 2 minutes video sequence stored at \\\n\\`/app/video.mp4\\`. \\\nIt accepts a local file, an http endpoint or a string starting with\n\\`generate:\\` (example: \\`generate:null\\` will generate a black video with \\\nsilent audio). \\\nThe temporary files containing the raw video and audio will be stored at \\\n\\`\\${VIDEO_CACHE_PATH}/video.\\${VIDEO_FORMAT}\\` and \\\n\\`\\${VIDEO_CACHE_PATH}/audio.wav\\`.`,\n format: String,\n default: 'https://github.com/vpalmisano/webrtcperf/releases/download/videos-1.0/kt.mp4',\n env: 'VIDEO_PATH',\n arg: 'video-path',\n },\n videoWidth: {\n doc: `The fake video resize width.`,\n format: 'nat',\n default: 1280,\n env: 'VIDEO_WIDTH',\n arg: 'video-width',\n },\n videoHeight: {\n doc: `The fake video resize height.`,\n format: 'nat',\n default: 720,\n env: 'VIDEO_HEIGHT',\n arg: 'video-height',\n },\n videoFramerate: {\n doc: `The fake video framerate.`,\n format: 'nat',\n default: 25,\n env: 'VIDEO_FRAMERATE',\n arg: 'video-framerate',\n },\n videoSeek: {\n doc: `The fake audio/video seek position in seconds.`,\n format: 'nat',\n default: 0,\n env: 'VIDEO_SEEK',\n arg: 'video-seek',\n },\n videoDuration: {\n doc: `The fake audio/video duration in seconds.`,\n format: 'nat',\n default: 120,\n env: 'VIDEO_DURATION',\n arg: 'video-duration',\n },\n videoCacheRaw: {\n doc: `If the temporary video and audio raw files can be reused across \\\nmultiple runs.`,\n format: 'Boolean',\n default: true,\n env: 'VIDEO_CACHE_RAW',\n arg: 'video-cache-raw',\n },\n videoCachePath: {\n doc: `The path where the video and audio raw files are stored.`,\n format: String,\n default: join(os.homedir(), '.webrtcperf/cache'),\n env: 'VIDEO_CACHE_PATH',\n arg: 'video-cache-path',\n },\n videoFormat: {\n doc: `The fake video file format presented to the browser.`,\n format: ['y4m', 'mjpeg'],\n default: 'y4m',\n env: 'VIDEO_FORMAT',\n arg: 'video-format',\n },\n useFakeMedia: {\n doc: `If true, the audio/video/screenshare will be generated using the browser fake device.\nOtherwise, the audio and video streams will be captured from a video element attached to the page, \nwhile the screenshare will be captured from a new browser tab.`,\n format: 'Boolean',\n default: true,\n env: 'USE_FAKE_MEDIA',\n arg: 'use-fake-media',\n },\n //\n runDuration: {\n doc: `If greater than 0, the test will stop after the provided number of \\\nseconds.`,\n format: 'nat',\n default: 0,\n env: 'RUN_DURATION',\n arg: 'run-duration',\n },\n throttleConfig: {\n doc: `A JSON5 string with a valid throttler configuration (https://github.com/vpalmisano/throttler). \\\nExample: \\\n\n \\`\\`\\`javascript\n [{\n sessions: '0-1',\n device: 'eth0',\n protocol: 'udp',\n skipSourcePorts: \"443\",\n skipDestinationPorts: \"443\",\n filter: \"--sports 443 --dports 443\",\n match: 'nbyte(\"ababa\" at 12 layer 1)',\n capture: 'capture.pcap',\n up: {\n rate: 1000,\n delay: 50,\n loss: 5,\n queue: 10,\n },\n down: [\n { rate: 2000, delay: 50, delayJitter: 10, delayJitterCorrelation: 25, loss: 2, lossBurst: 2, queue: 20 },\n { rate: 1000, delay: 50, loss: 2, queue: 20, at: 60 },\n ]\n }]\n \\`\\`\\`\n- The sessions field represents the sessions IDs range that will be affected by the rule, e.g.: \"0-10\", \"2,4\" or simply \"2\".\n- The device, protocol, up, down fields are optional. When device is not set, the default route device will be used. If protocol is specified ('udp' or 'tcp'), \\\nonly the packets with the specified protocol will be affected by the shaping rules.\n- The capture field is optional and specifies the pcap file to save the captured packets.\n- With skipSourcePorts and skipDestinationPorts you can specify a comma-separated list of ports that will not be affected by the shaping rules.\n- The filter field is optional and specifies the additional IPTables filter to apply for filtering the packets.\n- The match field is optional and specifies the additional match rule to apply for filtering the packets (https://man7.org/linux/man-pages/man8/tc-ematch.8.html).\n- The up and down fields are optional and they specify the upstream and downstream shaping rules. The possible options for the up and down rules could be:\n - rate: the shaping rate in Kbps;\n - delay: the shaping delay in milliseconds;\n - delayJitter: the shaping delay jitter in milliseconds;\n - delayJitterCorrelation: the shaping delay jitter correlation in milliseconds;\n - loss: the packet loss percentage;\n - lossBurst: the packet loss burst percentage;\n - queue: the shaping queue size in packets;\n - at: the time in seconds when the shaping rule will be applied (default: 0).\nThe up and down rules can be specified as a single object or an array of objects.\nWhen using an array of objects, specify a different \"at\" value for each of them, in order to apply a sequence of actions; please note that only the specified properties will override previous ones, so you can omit the values that you don't want to change. \\\n \\\n `,\n format: String,\n nullable: true,\n default: '',\n env: 'THROTTLE_CONFIG',\n arg: 'throttle-config',\n },\n useBrowserThrottling: {\n doc: `If true, the network will be throttled using the browser internal throttling mechanism.`,\n format: 'Boolean',\n default: os.platform() !== 'linux',\n env: 'USE_BROWSER_THROTTLING',\n arg: 'use-browser-throttling',\n },\n randomAudioPeriod: {\n doc: `If not zero, it specifies the maximum period in seconds after which \\\na new random active session is selected, enabling the getUserMedia audio tracks in \\\nthat session and disabling all of the others.`,\n format: 'nat',\n default: 0,\n env: 'RANDOM_AUDIO_PERIOD',\n arg: 'random-audio-period',\n },\n randomAudioProbability: {\n doc: `When using random audio period, it defines the probability % that \\\nthe selected audio will be activated (value: 0-100).`,\n format: 'nat',\n default: 100,\n env: 'RANDOM_AUDIO_PROBABILITY',\n arg: 'random-audio-probability',\n },\n randomAudioRange: {\n doc: `When using random audio period, it defines the session indexes \\\nto be included into the random selection (default: include all the sessions).`,\n format: 'index',\n default: 'true',\n nullable: true,\n env: 'RANDOM_AUDIO_RANGE',\n arg: 'random-audio-range',\n },\n // Session config\n chromiumPath: {\n doc: `The Chromium executable path.`,\n format: String,\n nullable: true,\n default: '',\n env: 'CHROMIUM_PATH',\n arg: 'chromium-path',\n },\n chromiumVersion: {\n doc: `The Chromium version. It will be downloaded if the chromium \\\npath is not provided.`,\n format: String,\n nullable: false,\n default: puppeteer.PUPPETEER_REVISIONS.chrome,\n env: 'CHROMIUM_VERSION',\n arg: 'chromium-version',\n },\n chromiumUrl: {\n doc: `The remote Chromium URL (\\`http://HOST:PORT\\`).\nIf provided, the remote instance will be used instead of running a local\nchromium process.`,\n format: String,\n default: '',\n nullable: true,\n env: 'CHROMIUM_URL',\n arg: 'chromium-url',\n },\n chromiumFieldTrials: {\n doc: `Chromium additional field trials.`,\n format: String,\n nullable: true,\n default: '',\n env: 'CHROMIUM_FIELD_TRIALS',\n arg: 'chromium-field-trials',\n },\n windowWidth: {\n doc: `The browser window width.`,\n format: 'nat',\n default: 1920,\n env: 'WINDOW_WIDTH',\n arg: 'window-width',\n },\n windowHeight: {\n doc: `The browser window height.`,\n format: 'nat',\n default: 1080,\n env: 'WINDOW_HEIGHT',\n arg: 'window-height',\n },\n deviceScaleFactor: {\n doc: `The browser device scale factor.`,\n format: 'float',\n default: 1,\n env: 'DEVICE_SCALE_FACTOR',\n arg: 'device-scale-factor',\n },\n maxVideoDecoders: {\n doc: `Specifies the maximum number of concurrent WebRTC video decoder \\\ninstances that can be created on the same host.\nIf set it will disable the received video resolution and jitter buffer stats. \\\nThis option is supported only when using the custom chromium build. \\\nThe total decoders count is stored into the virtual file \\`/dev/shm/chromium-video-decoders\\``,\n format: Number,\n default: -1,\n env: 'MAX_VIDEO_DECODERS',\n arg: 'max-video-decoders',\n },\n maxVideoDecodersRange: {\n doc: `It applies the max video decoders option to the sessions included into this list (default: include all the sessions)`,\n format: 'index',\n default: 'true',\n nullable: true,\n env: 'MAX_VIDEO_DECODERS_RANGE',\n arg: 'max-video-decoders-range',\n },\n incognito: {\n doc: `Runs the browser in incognito mode.`,\n format: 'Boolean',\n default: false,\n env: 'INCOGNITO',\n arg: 'incognito',\n },\n display: {\n doc: `If unset, the browser will run in headless mode, otherwise it will run in normal windowed mode.\nWhen running on MacOS or Windows, set it to any not-empty string.\nOn Linux, set it to a valid X server \\`DISPLAY\\` string (e.g. \\`:0\\`).`,\n format: String,\n default: '',\n nullable: true,\n arg: 'display',\n },\n /* audioRedForOpus: {\n doc: `Enables RED for OPUS codec (experimental).`,\n format: 'Boolean',\n default: false,\n env: 'AUDIO_RED_FOR_OPUS',\n arg: 'audio-red-for-opus',\n }, */\n sessions: {\n doc: `The number of browser sessions to start.`,\n format: 'nat',\n default: 0,\n env: 'SESSIONS',\n arg: 'sessions',\n },\n tabsPerSession: {\n doc: `The number of tabs to open in each browser session.`,\n format: 'nat',\n default: 1,\n env: 'TABS_PER_SESSION',\n arg: 'tabs-per-session',\n },\n startSessionId: {\n doc: `The starting ID assigned to sessions.`,\n format: 'nat',\n default: 0,\n env: 'START_SESSION_ID',\n arg: 'start-session-id',\n },\n startTimestamp: {\n doc: `The start timestamp (in milliseconds). If 0, the value will be \\\ncalculated using \\`Date.now()\\``,\n format: 'nat',\n default: 0,\n env: 'START_TIMESTAMP',\n arg: 'start-timestamp',\n },\n enableDetailedStats: {\n doc: `If detailed participant metrics values should be collected.`,\n format: 'index',\n default: '0-24',\n nullable: true,\n env: 'ENABLE_DETAILED_STATS',\n arg: 'enable-detailed-stats',\n },\n spawnRate: {\n doc: `The pages spawn rate (pages/s).`,\n format: 'float',\n default: 1,\n env: 'SPAWN_RATE',\n arg: 'spawn-rate',\n },\n showPageLog: {\n doc: `If \\`true\\`, the pages console logs will be shown on console. Set to false to disable the page logs.`,\n format: 'Boolean',\n default: false,\n env: 'SHOW_PAGE_LOG',\n arg: 'show-page-log',\n },\n pageLogFilter: {\n doc: `If set, only the logs with the matching text will be printed \\\non the console. Regexp string allowed.`,\n format: String,\n default: '',\n nullable: true,\n env: 'PAGE_LOG_FILTER',\n arg: 'page-log-filter',\n },\n pageLogPath: {\n doc: `If set, the page console logs will be saved on the selected file path.`,\n format: String,\n default: '',\n nullable: true,\n env: 'PAGE_LOG_PATH',\n arg: 'page-log-path',\n },\n enableBrowserLogging: {\n doc: `It enables the Chromium browser logging for the specified session indexes. It requires the pageLogPath option to be set.`,\n format: 'index',\n nullable: true,\n default: '',\n env: 'ENABLE_BROWSER_LOGGING',\n arg: 'enable-browser-logging',\n },\n enableRtpDump: {\n doc: `It enables the RTP dump for the specified session indexes. It requires the enableBrowserLogging option to be set. The text2pcap utility is required to convert the RTP dump to pcap format.`,\n format: 'index',\n nullable: true,\n default: '',\n env: 'ENABLE_RTP_DUMP',\n arg: 'enable-rtp-dump',\n },\n userAgent: {\n doc: `The user agent override.`,\n format: String,\n default: `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${puppeteer.PUPPETEER_REVISIONS.chrome} Safari/537.36`,\n nullable: true,\n env: 'USER_AGENT',\n arg: 'user-agent',\n },\n scriptPath: {\n doc: `One or more JavaScript file paths (comma-separated). \\\nIf set, the files contents will be executed inside each opened tab page; \\\nthe following global variables will be attached to the \\`webrtcperf\\` global object: \\\n\\`WEBRTC_PERF_SESSION\\` the session number (0-indexed); \\\n\\`WEBRTC_PERF_TAB\\` the tab number inside the same session (0-indexed); \\\n\\`WEBRTC_PERF_INDEX\\` the page absolute index (0-indexed).\nSuggested values for automated testing:\n- meet.google.com: https://raw.githubusercontent.com/vpalmisano/webrtcperf/refs/heads/devel/examples/google-meet.js\n- meet.livekit.io: https://raw.githubusercontent.com/vpalmisano/webrtcperf/refs/heads/devel/examples/livekit.js\n`,\n format: String,\n default: '',\n env: 'SCRIPT_PATH',\n arg: 'script-path',\n },\n scriptParams: {\n doc: `Additional parameters (in JSON format) that will be exposed into\nthe page context as \\`webrtcperf.params\\`.`,\n format: String,\n nullable: true,\n default: '',\n env: 'SCRIPT_PARAMS',\n arg: 'script-params',\n },\n disabledVideoCodecs: {\n doc: `A string with the video codecs to disable (comma-separated); e.g. \\`vp9,av1\\``,\n format: String,\n nullable: true,\n default: '',\n env: 'DISABLED_VIDEO_CODECS',\n arg: 'disabled-video-codecs',\n },\n localStorage: {\n doc: `A JSON string with the \\`localStorage\\` object to be set on page \\\nload.`,\n format: String,\n nullable: true,\n default: '',\n env: 'LOCAL_STORAGE',\n arg: 'local-storage',\n },\n sessionStorage: {\n doc: `A JSON string with the \\`sessionStorage\\` object to be set on page \\\nload.`,\n format: String,\n nullable: true,\n default: '',\n env: 'SESSION_STORAGE',\n arg: 'session-storage',\n },\n clearCookies: {\n doc: `If true, all the page cookies are cleared.`,\n format: 'Boolean',\n default: false,\n env: 'CLEAR_COOKIES',\n arg: 'clear-cookies',\n },\n enableGpu: {\n doc: `It enables the GPU acceleration (experimental). Set to \"desktop\" to \\\nuse the host X server instance.`,\n format: String,\n nullable: true,\n default: '',\n env: 'ENABLE_GPU',\n arg: 'enable-gpu',\n },\n blockedUrls: {\n doc: `A comma-separated list of request URLs that will be automatically \\\nblocked.`,\n format: String,\n nullable: true,\n default: '',\n env: 'BLOCKED_URLS',\n arg: 'blocked-urls',\n },\n extraHeaders: {\n doc: `A dictionary of headers keyed by the url in JSON5 format (e.g. \\\n\\`{ \"https://url.com/*\": { \"header-name\": \"value\" } }\\`).`,\n format: String,\n nullable: true,\n default: '',\n env: 'EXTRA_HEADERS',\n arg: 'extra-headers',\n },\n responseModifiers: {\n doc: `A dictionary of content replacements keyed by the url in JSON5 format.\nExamples:\n- replace strings using a regular expression:\n \\`{ \"https://url.com/*\": [{ search: \"searchString\": replace: \"anotherString\" }] }\\`\n- completely replace the content:\n \\`{ \"https://url.com/file.js\": [{ file: \"path/to/newFile.js\" }] }\\`\n`,\n format: String,\n nullable: true,\n default: '',\n env: 'RESPONSE_MODIFIERS',\n arg: 'response-modifiers',\n },\n downloadResponses: {\n doc: `An array of url responses that will be saved to the disk, keyed by the url in JSON5 format.\nExample: \\`[{ urlPattern: \"https://url.com/*\", output: \"save/directory\" }]\\`\n`,\n format: String,\n nullable: true,\n default: '',\n env: 'DOWNLOAD_RESPONSES',\n arg: 'download-responses',\n },\n extraCSS: {\n doc: `A string with a CSS styles to inject into each page. \\\nRules containing \"important\" will be replaced with \"!important\".`,\n format: String,\n nullable: true,\n default: '',\n env: 'EXTRA_CSS',\n arg: 'extra-css',\n },\n cookies: {\n doc: `A string with an array of [CookieParam](https://pptr.dev/api/puppeteer.cookieparam) to set into each page in JSON5 format.`,\n format: String,\n nullable: true,\n default: '',\n env: 'COOKIES',\n arg: 'cookies',\n },\n overridePermissions: {\n doc: `A comma-separated list of permissions to grant to the opened url.`,\n format: String,\n nullable: true,\n default: '',\n env: 'OVERRIDE_PERMISSIONS',\n arg: 'override-permissions',\n },\n hardwareConcurrency: {\n doc: `When set, it overrides the navigator.hardwareConcurrency property.`,\n format: 'nat',\n default: 0,\n env: 'HARDWARE_CONCURRENCY',\n arg: 'hardware-concurrency',\n },\n debuggingPort: {\n doc: `The chrome debugging port. If this value != 0, the chrome instance \\\nwill listen on the provided port + the start-session-id value.`,\n format: 'nat',\n default: 0,\n env: 'DEBUGGING_PORT',\n arg: 'debugging-port',\n },\n debuggingAddress: {\n doc: `The chrome debugging listening address. If unset, the network default interface address will be used.`,\n format: String,\n nullable: true,\n default: '127.0.0.1',\n env: 'DEBUGGING_ADDRESS',\n arg: 'debugging-address',\n },\n emulateCpuThrottling: {\n doc: `The emulated CPU throttling factor. If set, the page will be throttled to the specified factor.`,\n format: 'nat',\n default: 0,\n env: 'EMULATE_CPU_THROTTLING',\n arg: 'emulate-cpu-throttling',\n },\n // stats config\n showStats: {\n doc: `If the statistics should be displayed on the console output.`,\n format: 'Boolean',\n default: true,\n env: 'SHOW_STATS',\n arg: 'show-stats',\n },\n statsPath: {\n doc: `The log file path; if set, the stats will be written in \\\na .csv file inside that file.`,\n format: String,\n default: '',\n env: 'STATS_PATH',\n arg: 'stats-path',\n },\n detailedStatsPath: {\n doc: `The log file path; if set, the detailed stats will be written in \\\na .csv file inside that file. \\\nUse \\`webrtcperf --plot <detailed-stats-file> <output-file>.html\\` to generate a HTML plot.`,\n format: String,\n default: '',\n env: 'DETAILED_STATS_PATH',\n arg: 'detailed-stats-path',\n },\n statsInterval: {\n doc: `The stats collect interval in seconds. It should be lower than the \\\nPrometheus scraping interval.`,\n format: 'nat',\n default: 15,\n env: 'STATS_INTERVAL',\n arg: 'stats-interval',\n },\n rtcStatsTimeout: {\n doc: `The timeout in seconds after which the RTC stats coming from inactive\\\n hosts are removed. It should be higher than the \\`statsInterval\\` value.`,\n format: 'nat',\n default: 60,\n env: 'RTC_STATS_TIMEOUT',\n arg: 'rtc-stats-timeout',\n },\n customMetrics: {\n doc: `A dictionary of custom metrics keys in JSON5 format (e.g. \\\n'{ statName1: { labels: [\"label1\"] } }').`,\n format: String,\n nullable: true,\n default: '',\n env: 'CUSTOM_METRICS',\n arg: 'custom-metrics',\n },\n //\n prometheusPushgateway: {\n doc: `If set, logs are sent to the specified Prometheus Pushgateway \\\nservice (example: \"http://127.0.0.1:9091\").`,\n format: 'String',\n default: '',\n nullable: true,\n env: 'PROMETHEUS_PUSHGATEWAY',\n arg: 'prometheus-pushgateway',\n },\n prometheusPushgatewayJobName: {\n doc: `The Prometheus Pushgateway job name.`,\n format: 'String',\n default: 'default',\n env: 'PROMETHEUS_PUSHGATEWAY_JOB_NAME',\n arg: 'prometheus-pushgateway-job-name',\n },\n prometheusPushgatewayAuth: {\n doc: `The Prometheus Pushgateway basic auth (username:password).`,\n format: 'String',\n default: '',\n nullable: true,\n env: 'PROMETHEUS_PUSHGATEWAY_AUTH',\n arg: 'prometheus-pushgateway-auth',\n },\n prometheusPushgatewayGzip: {\n doc: `Allows to use gzip encoded pushgateway requests.`,\n format: 'Boolean',\n default: true,\n env: 'PROMETHEUS_PUSHGATEWAY_GZIP',\n arg: 'prometheus-pushgateway-gzip',\n },\n //\n alertRules: {\n doc: `Alert rules definition (in JSON format).`,\n format: String,\n nullable: true,\n default: '',\n env: 'ALERT_RULES',\n arg: 'alert-rules',\n },\n alertRulesOutput: {\n doc: `The alert rules report output filename. If the file ends with .log extension, a detailed log will be generated, otherwise a JSON report will be generated.`,\n format: String,\n nullable: true,\n default: '',\n env: 'ALERT_RULES_OUTPUT',\n arg: 'alert-rules-output',\n },\n alertRulesFailPercentile: {\n doc: `The alert rules report fails percentile (0-100). With the default value the \\\nalert will be successful only when at least 95% of the checks pass.`,\n format: 'nat',\n nullable: false,\n default: 95,\n env: 'ALERT_RULES_FAIL_PERCENTILE',\n arg: 'alert-rules-fail-percentile',\n },\n pushStatsUrl: {\n doc: `The URL to push the collected stats.`,\n format: String,\n nullable: true,\n default: '',\n env: 'PUSH_STATS_URL',\n arg: 'push-stats-url',\n },\n pushStatsId: {\n doc: `The ID of the collected stats to push.`,\n format: String,\n nullable: true,\n default: 'default',\n env: 'PUSH_STATS_ID',\n arg: 'push-stats-id',\n },\n // server config\n serverPort: {\n doc: `The HTTP server listening port.`,\n format: 'nat',\n nullable: true,\n default: 0,\n env: 'SERVER_PORT',\n arg: 'server-port',\n },\n serverSecret: {\n doc: `The HTTP server basic auth secret. The auth user name is set to \\`admin\\` by default.`,\n format: String,\n default: 'secret',\n env: 'SERVER_SECRET',\n arg: 'server-secret',\n },\n serverUseHttps: {\n doc: `If true, the server will use the HTTPS protocol.`,\n format: 'Boolean',\n default: false,\n env: 'SERVER_USE_HTTPS',\n arg: 'server-use-https',\n },\n serverData: {\n doc: `An optional path that the HTTP server will expose with the /data endpoint.`,\n format: String,\n nullable: true,\n default: '',\n env: 'SERVER_DATA',\n arg: 'server-data',\n },\n // VMAF config\n vmafPath: {\n doc: `When set, it runs the VMAF calculator for the video files saved under the provided directory path.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_PATH',\n arg: 'vmaf-path',\n },\n vmafPreview: {\n doc: `If true, for each VMAF comparison it creates a side-by-side video with \\\nthe reference and degraded versions.`,\n format: 'Boolean',\n default: false,\n env: 'VMAF_PREVIEW',\n arg: 'vmaf-preview',\n },\n vmafKeepIntermediateFiles: {\n doc: `If true, the VMAF intermediate files will not be deleted.`,\n format: 'Boolean',\n default: false,\n env: 'VMAF_KEEP_INTERMEDIATE_FILES',\n arg: 'vmaf-keep-intermediate-files',\n },\n vmafKeepSourceFiles: {\n doc: `If true, the VMAF source files will not be deleted.`,\n format: 'Boolean',\n default: true,\n env: 'VMAF_KEEP_SOURCE_FILES',\n arg: 'vmaf-keep-source-files',\n },\n vmafSkipDuplicated: {\n doc: `If true, the VMAF will skip duplicated recognized frames.`,\n format: 'Boolean',\n default: false,\n env: 'VMAF_SKIP_DUPLICATED',\n arg: 'vmaf-skip-duplicated',\n },\n vmafCrop: {\n doc: `If set, the reference and degraded videos will be cropped using the specified configuration in JSON5 format. \\\nCrop configuration should be expressed using the ffmpeg crop filter syntax (https://ffmpeg.org/ffmpeg-filters.html#crop). \\\nE.g. \\`{ \"Participant-000001_recv-by_Participant-000000\": { ref: { w: \"iw-10\", h: \"ih-5\" }, deg: { w: \"200\", h: \"200\" } } }\\``,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_CROP',\n arg: 'vmaf-crop',\n },\n vmafPrepareVideo: {\n doc: `When set, it prepares the selected video applying a timestamp overlay on top of it. \\\nThe filename must be provided in the format \\`<video path>,<ID>\\`, where the selected ID will be used unique video identifier in the overlay.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_PREPARE_VIDEO',\n arg: 'vmaf-prepare-video',\n },\n vmafProcessVideo: {\n doc: `When set, it runs the VMAF video preprocessor, that converts a video file into the IVF format with timestamps matching the overlay recognition. \\\nThe filename must contain a \\`recv\\` or \\`send\\` string to identify if the video was a reference (send) or a degraded version (recv), e.g. \\`Participant1_recv.mp4\\`.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_PROCESS_VIDEO',\n arg: 'vmaf-process-video',\n },\n vmafVideoCrop: {\n doc: `If set, the vmaf prepared/processed video will be cropped using the specified configuration in JSON5 format. \\\nCrop configuration should be expressed using the ffmpeg crop filter syntax (https://ffmpeg.org/ffmpeg-filters.html#crop). \\\nE.g. \\`{ w: \"iw-10\", h: \"ih-5\", x: \"10\", y: '5' }\\``,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_VIDEO_CROP',\n arg: 'vmaf-video-crop',\n },\n // VISQOL config\n visqolPath: {\n doc: `When set, it runs the visqol calculator for the audio files saved under the provided directory path.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VISQOL_PATH',\n arg: 'visqol-path',\n },\n visqolKeepSourceFiles: {\n doc: `If true, the visqol source files will not be deleted.`,\n format: 'Boolean',\n default: true,\n env: 'VISQOL_KEEP_SOURCE_FILES',\n arg: 'visqol-keep-source-files',\n },\n}\n\ntype ConfigDocs = Record<string, { doc: string; format: string; default: string }>\n\n/**\n * Formats the schema documentation, calling the same function recursively.\n * @param docs the documentation object to extend\n * @param property the root property\n * @param schema the config schema fragment\n * @return the documentation object\n */\nfunction formatDocs(\n docs: ConfigDocs,\n property: string | null,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: any,\n): ConfigDocs {\n if (schema._cvtProperties) {\n Object.entries(schema._cvtProperties).forEach(([name, value]) => {\n formatDocs(docs, `${property ? `${property}.` : ''}${name}`, value)\n })\n return docs\n }\n\n if (property) {\n docs[property] = {\n doc: schema.doc,\n format: JSON.stringify(schema.format, null, 2),\n default: JSON.stringify(schema.default, null, 2),\n }\n }\n return docs\n}\n\n/**\n * It returns the formatted configuration docs.\n */\nexport function getConfigDocs(): ConfigDocs {\n return formatDocs({}, null, convict(configSchema).getSchema())\n}\n\n/**\n * Returns a Zod schema for the config object, with all parameters optional and described.\n * Uses the config default values when a field is omitted. Useful for MCP tools and other\n * consumers that need validated partial config.\n */\nexport function getConfigZodSchema(): z.ZodObject<Record<string, z.ZodTypeAny>> {\n const schema = convict(configSchema).getSchema()\n const shape: Record<string, z.ZodTypeAny> = {}\n for (const [key, value] of Object.entries(schema._cvtProperties)) {\n const prop = value as SchemaObj & { doc?: string; format?: unknown; default?: unknown }\n const doc = prop.doc ?? key\n const def = prop.default\n const format = prop.format\n let zodType: z.ZodTypeAny\n if (format === String || format === 'string') {\n zodType = z.string()\n } else if (format === 'nat' || format === Number) {\n zodType = z.number()\n } else if (format === 'float') {\n zodType = z.number()\n } else if (format === 'Boolean' || format === 'boolean') {\n zodType = z.boolean()\n } else if (format === 'index') {\n zodType = z.union([z.string(), z.number(), z.boolean()])\n } else if (Array.isArray(format)) {\n zodType = z.enum(format as [string, ...string[]])\n } else {\n zodType = z.union([z.string(), z.number(), z.boolean()])\n }\n shape[key] = def !== undefined ? zodType.default(def).describe(doc) : zodType.optional().describe(doc)\n }\n return z.object(shape)\n}\n\nconst _schemaProperties = convict(configSchema).getProperties()\n\n/** [[include:config.md]] */\nexport type Config = typeof _schemaProperties\n\n/**\n * Loads the config object.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function loadConfig(filePath?: string, values?: any): Promise<Config[]> {\n const configs: Config[] = []\n if (filePath) {\n if (filePath.startsWith('http')) {\n log.debug(`Loading config from url: ${filePath}`)\n const res = await downloadUrl(filePath)\n if (!res?.data) {\n throw new Error(`Failed to download configuration from: ${filePath}`)\n }\n values =\n res.contentType === 'application/x-yaml'\n ? yaml.parse(res.data)\n : res.contentType === 'application/toml'\n ? toml.parse(res.data)\n : json5.parse(res.data)\n } else {\n if (!existsSync(filePath)) {\n throw new Error(`Config file not found: ${filePath}`)\n }\n log.debug(`Loading config from local file: ${filePath}`)\n if (filePath.endsWith('.js') || filePath.endsWith('.mjs')) {\n const module = await import(/* webpackIgnore: true */ path.resolve(filePath))\n values = await module.default(process.argv)\n } else {\n const data = String(await fs.promises.readFile(filePath))\n values =\n filePath.endsWith('.yml') || filePath.endsWith('.yaml')\n ? yaml.parse(data)\n : filePath.endsWith('.toml')\n ? toml.parse(data)\n : json5.parse(data)\n }\n }\n }\n if (!Array.isArray(values)) {\n values = [values || {}]\n }\n for (const value of values) {\n const schema = convict(configSchema)\n schema.load(value || {})\n schema.validate({ allowed: 'strict' })\n configs.push(schema.getProperties())\n }\n log.debug('Using config:', configs)\n return configs\n}\n\nfunction getFunctionDeclaration() {\n const properties: Record<string, { type: string; description: string; nullable?: boolean }> = {}\n const required: string[] = []\n const schema = convict(configSchema).getSchema()\n\n Object.entries(schema._cvtProperties).forEach(([name, value]) => {\n const { format, doc, nullable } = value as SchemaObj\n properties[name] = {\n type: format as string,\n description: doc as string,\n nullable,\n }\n })\n\n return {\n name: 'webrtcperf',\n description: 'Starts a webrtcperf test.',\n parameters: {\n type: 'object',\n properties,\n required,\n },\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst { GoogleGenAI } = require('@google/genai')\n\nexport async function loadConfigFromPrompt(prompt: string) {\n log.debug(`loadConfigFromPrompt: \"${prompt}\"`)\n if (!process.env.GEMINI_API_KEY) {\n throw new Error('GEMINI_API_KEY environment variable is not set. Please set it to use the Google GenAI API.')\n }\n const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY })\n const response = await ai.models.generateContent({\n model: 'gemini-2.5-flash',\n contents: prompt,\n config: {\n tools: [\n {\n functionDeclarations: [getFunctionDeclaration()],\n },\n ],\n thinkingConfig: {\n thinkingBudget: 0,\n },\n },\n })\n if (response.functionCalls && response.functionCalls.length > 0) {\n const functionCall = response.functionCalls[0]\n log.debug('Using function call:', functionCall.name, functionCall.args)\n return functionCall.args\n } else {\n throw new Error('No function call found in the response. Please check the prompt and try again.')\n }\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAq5BA,sCAEC;A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AG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAA;IAClE,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC;QAC/C,KAAK,EAAE,kBAAkB;QACzB,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE;YACN,KAAK,EAAE;gBACL;oBACE,oBAAoB,EAAE,CAAC,sBAAsB,EAAE,CAAC;iBACjD;aACF;YACD,cAAc,EAAE;gBACd,cAAc,EAAE,CAAC;aAClB;SACF;KACF,CAAC,CAAA;IACF,IAAI,QAAQ,CAAC,aAAa,IAAI,QAAQ,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChE,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;QAC9C,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAA;QACvE,OAAO,YAAY,CAAC,IAAI,CAAA;IAC1B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;IACnG,CAAC;AACH,CAAC","sourcesContent":["import convict, { addFormats, SchemaObj } from 'convict'\nimport { z } from 'zod'\nimport { ipaddress, url } from 'convict-format-with-validator'\nimport { existsSync } from 'fs'\nimport os from 'os'\nimport path, { join } from 'path'\nimport json5 from 'json5'\nimport yaml from 'yaml'\nimport toml from 'toml'\nimport fs from 'fs'\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst puppeteer = require('puppeteer-core')\n\nimport { downloadUrl, logger } from './utils'\nconst log = logger('webrtcperf:config')\n\nconst float = {\n name: 'float',\n coerce: (v: string) => parseFloat(v),\n validate: (v: number) => {\n if (!Number.isFinite(v)) throw new Error(`Invalid float: ${v}`)\n },\n}\n\nconst index = {\n name: 'index',\n coerce: (v: unknown) => v,\n validate: (v: boolean | string | number) => {\n if (typeof v === 'string') {\n if (v === 'true' || v === 'false' || v === '') return\n if (v.includes('-')) {\n v.split('-').forEach(n => {\n if (isNaN(parseInt(n)) || !isFinite(parseInt(n))) throw new Error(`Invalid string index: ${n}`)\n })\n return\n }\n if (v.includes(',')) {\n v.split(',').forEach(n => {\n if (isNaN(parseInt(n)) || !isFinite(parseInt(n))) throw new Error(`Invalid string index: ${n}`)\n })\n return\n }\n if (isNaN(parseInt(v)) || !isFinite(parseInt(v))) throw new Error(`Invalid string index: ${v}`)\n return\n } else if (typeof v === 'number' || typeof v === 'boolean') {\n return\n }\n throw new Error(`Invalid index: \"${v}\" (type: ${typeof v})`)\n },\n}\n\naddFormats({ ipaddress, url, float, index })\n\nconvict.addParser([\n { extension: 'json', parse: json5.parse },\n { extension: ['yml', 'yaml'], parse: yaml.parse },\n { extension: 'toml', parse: toml.parse },\n])\n\nconst configSchema = {\n url: {\n doc: `The page url to load.`,\n format: String,\n default: '',\n nullable: true,\n env: 'URL',\n arg: 'url',\n },\n urlQuery: {\n doc: `The query string to append to the page url; the following template \\\nvariables are replaced: \\`$p\\` the process pid, \\`$s\\` the session index, \\\n\\`$S\\` the total sessions, \\`$t\\` the tab index, \\`$T\\` the total tabs per \\\nsession, \\`$i\\` the tab absolute index.`,\n format: String,\n default: '',\n nullable: true,\n env: 'URL_QUERY',\n arg: 'url-query',\n },\n customUrlHandler: {\n doc: `This argument specifies the file path for the custom page URL handler that will be exported by default. \\\nThe custom page URL handler allows you to define custom URLs that can be used to open your application. \\\nThe handler function will be called with the following variables: \\\n- sessions: the total number of sessions; \\\n- tabsPerSession: the total number of tabs per session; \\\n- id: the session global index (0-indexed); \\\n- index: the tab global index (0-indexed); \\\n- tabIndex: the tab index in the current session (0-indexed); \\\n- pid: the process pid; \\\n- env: the environment variables object; \\\n- params: the script parameters object. \\\nYou can use these variables to create custom URL schemes that suit your application's needs.`,\n format: String,\n default: '',\n nullable: true,\n env: 'CUSTOM_URL_HANDLER',\n arg: 'custom-url-handler',\n },\n // fake video/audio\n videoPath: {\n doc: `The fake video path; if set, the video will be used as fake \\\nmedia source. It accepts a single path or a comma-separated list of videos \\\npaths that will be used in round-robin by the started sessions. \\\nThe docker pre-built image contains a 2 minutes video sequence stored at \\\n\\`/app/video.mp4\\`. \\\nIt accepts a local file, an http endpoint or a string starting with\n\\`generate:\\` (example: \\`generate:null\\` will generate a black video with \\\nsilent audio). \\\nThe temporary files containing the raw video and audio will be stored at \\\n\\`\\${VIDEO_CACHE_PATH}/video.\\${VIDEO_FORMAT}\\` and \\\n\\`\\${VIDEO_CACHE_PATH}/audio.wav\\`.`,\n format: String,\n default: 'https://github.com/vpalmisano/webrtcperf/releases/download/videos-1.0/kt.mp4',\n env: 'VIDEO_PATH',\n arg: 'video-path',\n },\n videoWidth: {\n doc: `The fake video resize width.`,\n format: 'nat',\n default: 1280,\n env: 'VIDEO_WIDTH',\n arg: 'video-width',\n },\n videoHeight: {\n doc: `The fake video resize height.`,\n format: 'nat',\n default: 720,\n env: 'VIDEO_HEIGHT',\n arg: 'video-height',\n },\n videoFramerate: {\n doc: `The fake video framerate.`,\n format: 'nat',\n default: 25,\n env: 'VIDEO_FRAMERATE',\n arg: 'video-framerate',\n },\n videoSeek: {\n doc: `The fake audio/video seek position in seconds.`,\n format: 'nat',\n default: 0,\n env: 'VIDEO_SEEK',\n arg: 'video-seek',\n },\n videoDuration: {\n doc: `The fake audio/video duration in seconds.`,\n format: 'nat',\n default: 120,\n env: 'VIDEO_DURATION',\n arg: 'video-duration',\n },\n videoCacheRaw: {\n doc: `If the temporary video and audio raw files can be reused across \\\nmultiple runs.`,\n format: 'Boolean',\n default: true,\n env: 'VIDEO_CACHE_RAW',\n arg: 'video-cache-raw',\n },\n videoCachePath: {\n doc: `The path where the video and audio raw files are stored.`,\n format: String,\n default: join(os.homedir(), '.webrtcperf/cache'),\n env: 'VIDEO_CACHE_PATH',\n arg: 'video-cache-path',\n },\n videoFormat: {\n doc: `The fake video file format presented to the browser.`,\n format: ['y4m', 'mjpeg'],\n default: 'y4m',\n env: 'VIDEO_FORMAT',\n arg: 'video-format',\n },\n useFakeMedia: {\n doc: `If true, the audio/video/screenshare will be generated using the browser fake device.\nOtherwise, the audio and video streams will be captured from a video element attached to the page, \nwhile the screenshare will be captured from a new browser tab.`,\n format: 'Boolean',\n default: true,\n env: 'USE_FAKE_MEDIA',\n arg: 'use-fake-media',\n },\n //\n runDuration: {\n doc: `If greater than 0, the test will stop after the provided number of \\\nseconds.`,\n format: 'nat',\n default: 0,\n env: 'RUN_DURATION',\n arg: 'run-duration',\n },\n throttleConfig: {\n doc: `A JSON5 string with a valid throttler configuration (https://github.com/vpalmisano/throttler). \\\nExample: \\\n\n \\`\\`\\`javascript\n [{\n sessions: '0-1',\n device: 'eth0',\n protocol: 'udp',\n skipSourcePorts: \"443\",\n skipDestinationPorts: \"443\",\n filter: \"--sports 443 --dports 443\",\n match: 'nbyte(\"ababa\" at 12 layer 1)',\n capture: 'capture.pcap',\n up: {\n rate: 1000,\n delay: 50,\n loss: 5,\n queue: 10,\n },\n down: [\n { rate: 2000, delay: 50, delayJitter: 10, delayJitterCorrelation: 25, loss: 2, lossBurst: 2, queue: 20 },\n { rate: 1000, delay: 50, loss: 2, queue: 20, at: 60 },\n ]\n }]\n \\`\\`\\`\n- The sessions field represents the sessions IDs range that will be affected by the rule, e.g.: \"0-10\", \"2,4\" or simply \"2\".\n- The device, protocol, up, down fields are optional. When device is not set, the default route device will be used. If protocol is specified ('udp' or 'tcp'), \\\nonly the packets with the specified protocol will be affected by the shaping rules.\n- The capture field is optional and specifies the pcap file to save the captured packets.\n- With skipSourcePorts and skipDestinationPorts you can specify a comma-separated list of ports that will not be affected by the shaping rules.\n- The filter field is optional and specifies the additional IPTables filter to apply for filtering the packets.\n- The match field is optional and specifies the additional match rule to apply for filtering the packets (https://man7.org/linux/man-pages/man8/tc-ematch.8.html).\n- The up and down fields are optional and they specify the upstream and downstream shaping rules. The possible options for the up and down rules could be:\n - rate: the shaping rate in Kbps;\n - delay: the shaping delay in milliseconds;\n - delayJitter: the shaping delay jitter in milliseconds;\n - delayJitterCorrelation: the shaping delay jitter correlation in milliseconds;\n - loss: the packet loss percentage;\n - lossBurst: the packet loss burst percentage;\n - queue: the shaping queue size in packets;\n - at: the time in seconds when the shaping rule will be applied (default: 0).\nThe up and down rules can be specified as a single object or an array of objects.\nWhen using an array of objects, specify a different \"at\" value for each of them, in order to apply a sequence of actions; please note that only the specified properties will override previous ones, so you can omit the values that you don't want to change. \\\n \\\n `,\n format: String,\n nullable: true,\n default: '',\n env: 'THROTTLE_CONFIG',\n arg: 'throttle-config',\n },\n useBrowserThrottling: {\n doc: `If true, the network will be throttled using the browser internal throttling mechanism.`,\n format: 'Boolean',\n default: os.platform() !== 'linux',\n env: 'USE_BROWSER_THROTTLING',\n arg: 'use-browser-throttling',\n },\n randomAudioPeriod: {\n doc: `If not zero, it specifies the maximum period in seconds after which \\\na new random active session is selected, enabling the getUserMedia audio tracks in \\\nthat session and disabling all of the others.`,\n format: 'nat',\n default: 0,\n env: 'RANDOM_AUDIO_PERIOD',\n arg: 'random-audio-period',\n },\n randomAudioProbability: {\n doc: `When using random audio period, it defines the probability % that \\\nthe selected audio will be activated (value: 0-100).`,\n format: 'nat',\n default: 100,\n env: 'RANDOM_AUDIO_PROBABILITY',\n arg: 'random-audio-probability',\n },\n randomAudioRange: {\n doc: `When using random audio period, it defines the session indexes \\\nto be included into the random selection (default: include all the sessions).`,\n format: 'index',\n default: 'true',\n nullable: true,\n env: 'RANDOM_AUDIO_RANGE',\n arg: 'random-audio-range',\n },\n // Session config\n chromiumPath: {\n doc: `The Chromium executable path.`,\n format: String,\n nullable: true,\n default: '',\n env: 'CHROMIUM_PATH',\n arg: 'chromium-path',\n },\n chromiumVersion: {\n doc: `The Chromium version. It will be downloaded if the chromium \\\npath is not provided.`,\n format: String,\n nullable: false,\n default: puppeteer.PUPPETEER_REVISIONS.chrome,\n env: 'CHROMIUM_VERSION',\n arg: 'chromium-version',\n },\n chromiumUrl: {\n doc: `The remote Chromium URL (\\`http://HOST:PORT\\`).\nIf provided, the remote instance will be used instead of running a local\nchromium process.`,\n format: String,\n default: '',\n nullable: true,\n env: 'CHROMIUM_URL',\n arg: 'chromium-url',\n },\n chromiumFieldTrials: {\n doc: `Chromium additional field trials.`,\n format: String,\n nullable: true,\n default: '',\n env: 'CHROMIUM_FIELD_TRIALS',\n arg: 'chromium-field-trials',\n },\n windowWidth: {\n doc: `The browser window width.`,\n format: 'nat',\n default: 1920,\n env: 'WINDOW_WIDTH',\n arg: 'window-width',\n },\n windowHeight: {\n doc: `The browser window height.`,\n format: 'nat',\n default: 1080,\n env: 'WINDOW_HEIGHT',\n arg: 'window-height',\n },\n deviceScaleFactor: {\n doc: `The browser device scale factor.`,\n format: 'float',\n default: 1,\n env: 'DEVICE_SCALE_FACTOR',\n arg: 'device-scale-factor',\n },\n maxVideoDecoders: {\n doc: `Specifies the maximum number of concurrent WebRTC video decoder \\\ninstances that can be created on the same host.\nIf set it will disable the received video resolution and jitter buffer stats. \\\nThis option is supported only when using the custom chromium build. \\\nThe total decoders count is stored into the virtual file \\`/dev/shm/chromium-video-decoders\\``,\n format: Number,\n default: -1,\n env: 'MAX_VIDEO_DECODERS',\n arg: 'max-video-decoders',\n },\n maxVideoDecodersRange: {\n doc: `It applies the max video decoders option to the sessions included into this list (default: include all the sessions)`,\n format: 'index',\n default: 'true',\n nullable: true,\n env: 'MAX_VIDEO_DECODERS_RANGE',\n arg: 'max-video-decoders-range',\n },\n incognito: {\n doc: `Runs the browser in incognito mode.`,\n format: 'Boolean',\n default: false,\n env: 'INCOGNITO',\n arg: 'incognito',\n },\n display: {\n doc: `If unset, the browser will run in headless mode, otherwise it will run in normal windowed mode.\nWhen running on MacOS or Windows, set it to any not-empty string.\nOn Linux, set it to a valid X server \\`DISPLAY\\` string (e.g. \\`:0\\`).`,\n format: String,\n default: '',\n nullable: true,\n arg: 'display',\n },\n /* audioRedForOpus: {\n doc: `Enables RED for OPUS codec (experimental).`,\n format: 'Boolean',\n default: false,\n env: 'AUDIO_RED_FOR_OPUS',\n arg: 'audio-red-for-opus',\n }, */\n sessions: {\n doc: `The number of browser sessions to start.`,\n format: 'nat',\n default: 0,\n env: 'SESSIONS',\n arg: 'sessions',\n },\n tabsPerSession: {\n doc: `The number of tabs to open in each browser session.`,\n format: 'nat',\n default: 1,\n env: 'TABS_PER_SESSION',\n arg: 'tabs-per-session',\n },\n startSessionId: {\n doc: `The starting ID assigned to sessions.`,\n format: 'nat',\n default: 0,\n env: 'START_SESSION_ID',\n arg: 'start-session-id',\n },\n startTimestamp: {\n doc: `The start timestamp (in milliseconds). If 0, the value will be \\\ncalculated using \\`Date.now()\\``,\n format: 'nat',\n default: 0,\n env: 'START_TIMESTAMP',\n arg: 'start-timestamp',\n },\n enableDetailedStats: {\n doc: `If detailed participant metrics values should be collected.`,\n format: 'index',\n default: '0-24',\n nullable: true,\n env: 'ENABLE_DETAILED_STATS',\n arg: 'enable-detailed-stats',\n },\n spawnRate: {\n doc: `The pages spawn rate (pages/s).`,\n format: 'float',\n default: 1,\n env: 'SPAWN_RATE',\n arg: 'spawn-rate',\n },\n showPageLog: {\n doc: `If \\`true\\`, the pages console logs will be shown on console. Set to false to disable the page logs.`,\n format: 'Boolean',\n default: false,\n env: 'SHOW_PAGE_LOG',\n arg: 'show-page-log',\n },\n pageLogFilter: {\n doc: `If set, only the logs with the matching text will be printed \\\non the console. Regexp string allowed.`,\n format: String,\n default: '',\n nullable: true,\n env: 'PAGE_LOG_FILTER',\n arg: 'page-log-filter',\n },\n pageLogPath: {\n doc: `If set, the page console logs will be saved on the selected file path.`,\n format: String,\n default: '',\n nullable: true,\n env: 'PAGE_LOG_PATH',\n arg: 'page-log-path',\n },\n enableBrowserLogging: {\n doc: `It enables the Chromium browser logging for the specified session indexes. It requires the pageLogPath option to be set.`,\n format: 'index',\n nullable: true,\n default: '',\n env: 'ENABLE_BROWSER_LOGGING',\n arg: 'enable-browser-logging',\n },\n enableRtpDump: {\n doc: `It enables the RTP dump for the specified session indexes. It requires the enableBrowserLogging option to be set. The text2pcap utility is required to convert the RTP dump to pcap format.`,\n format: 'index',\n nullable: true,\n default: '',\n env: 'ENABLE_RTP_DUMP',\n arg: 'enable-rtp-dump',\n },\n userAgent: {\n doc: `The user agent override.`,\n format: String,\n default: `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${puppeteer.PUPPETEER_REVISIONS.chrome} Safari/537.36`,\n nullable: true,\n env: 'USER_AGENT',\n arg: 'user-agent',\n },\n scriptPath: {\n doc: `One or more JavaScript file paths (comma-separated). \\\nIf set, the files contents will be executed inside each opened tab page; \\\nthe following global variables will be attached to the \\`webrtcperf\\` global object: \\\n\\`WEBRTC_PERF_SESSION\\` the session number (0-indexed); \\\n\\`WEBRTC_PERF_TAB\\` the tab number inside the same session (0-indexed); \\\n\\`WEBRTC_PERF_INDEX\\` the page absolute index (0-indexed).\nSuggested values for automated testing:\n- meet.google.com: https://raw.githubusercontent.com/vpalmisano/webrtcperf/refs/heads/devel/examples/google-meet.js\n- meet.livekit.io: https://raw.githubusercontent.com/vpalmisano/webrtcperf/refs/heads/devel/examples/livekit.js\n`,\n format: String,\n default: '',\n env: 'SCRIPT_PATH',\n arg: 'script-path',\n },\n scriptParams: {\n doc: `Additional parameters (in JSON format) that will be exposed into\nthe page context as \\`webrtcperf.params\\`.`,\n format: String,\n nullable: true,\n default: '',\n env: 'SCRIPT_PARAMS',\n arg: 'script-params',\n },\n disabledVideoCodecs: {\n doc: `A string with the video codecs to disable (comma-separated); e.g. \\`vp9,av1\\``,\n format: String,\n nullable: true,\n default: '',\n env: 'DISABLED_VIDEO_CODECS',\n arg: 'disabled-video-codecs',\n },\n localStorage: {\n doc: `A JSON string with the \\`localStorage\\` object to be set on page \\\nload.`,\n format: String,\n nullable: true,\n default: '',\n env: 'LOCAL_STORAGE',\n arg: 'local-storage',\n },\n sessionStorage: {\n doc: `A JSON string with the \\`sessionStorage\\` object to be set on page \\\nload.`,\n format: String,\n nullable: true,\n default: '',\n env: 'SESSION_STORAGE',\n arg: 'session-storage',\n },\n clearCookies: {\n doc: `If true, all the page cookies are cleared.`,\n format: 'Boolean',\n default: false,\n env: 'CLEAR_COOKIES',\n arg: 'clear-cookies',\n },\n enableGpu: {\n doc: `It enables the GPU acceleration (experimental). Set to \"desktop\" to \\\nuse the host X server instance.`,\n format: String,\n nullable: true,\n default: '',\n env: 'ENABLE_GPU',\n arg: 'enable-gpu',\n },\n blockedUrls: {\n doc: `A comma-separated list of request URLs that will be automatically \\\nblocked.`,\n format: String,\n nullable: true,\n default: '',\n env: 'BLOCKED_URLS',\n arg: 'blocked-urls',\n },\n extraHeaders: {\n doc: `A dictionary of headers keyed by the url in JSON5 format (e.g. \\\n\\`{ \"https://url.com/*\": { \"header-name\": \"value\" } }\\`).`,\n format: String,\n nullable: true,\n default: '',\n env: 'EXTRA_HEADERS',\n arg: 'extra-headers',\n },\n responseModifiers: {\n doc: `A dictionary of content replacements keyed by the url in JSON5 format.\nExamples:\n- replace strings using a regular expression:\n \\`{ \"https://url.com/*\": [{ search: \"searchString\": replace: \"anotherString\" }] }\\`\n- completely replace the content:\n \\`{ \"https://url.com/file.js\": [{ file: \"path/to/newFile.js\" }] }\\`\n`,\n format: String,\n nullable: true,\n default: '',\n env: 'RESPONSE_MODIFIERS',\n arg: 'response-modifiers',\n },\n downloadResponses: {\n doc: `An array of url responses that will be saved to the disk, keyed by the url in JSON5 format.\nExample: \\`[{ urlPattern: \"https://url.com/*\", output: \"save/directory\" }]\\`\n`,\n format: String,\n nullable: true,\n default: '',\n env: 'DOWNLOAD_RESPONSES',\n arg: 'download-responses',\n },\n extraCSS: {\n doc: `A string with a CSS styles to inject into each page. \\\nRules containing \"important\" will be replaced with \"!important\".`,\n format: String,\n nullable: true,\n default: '',\n env: 'EXTRA_CSS',\n arg: 'extra-css',\n },\n cookies: {\n doc: `A string with an array of [CookieParam](https://pptr.dev/api/puppeteer.cookieparam) to set into each page in JSON5 format.`,\n format: String,\n nullable: true,\n default: '',\n env: 'COOKIES',\n arg: 'cookies',\n },\n overridePermissions: {\n doc: `A comma-separated list of permissions to grant to the opened url.`,\n format: String,\n nullable: true,\n default: '',\n env: 'OVERRIDE_PERMISSIONS',\n arg: 'override-permissions',\n },\n hardwareConcurrency: {\n doc: `When set, it overrides the navigator.hardwareConcurrency property.`,\n format: 'nat',\n default: 0,\n env: 'HARDWARE_CONCURRENCY',\n arg: 'hardware-concurrency',\n },\n debuggingPort: {\n doc: `The chrome debugging port. If this value != 0, the chrome instance \\\nwill listen on the provided port + the start-session-id value.`,\n format: 'nat',\n default: 0,\n env: 'DEBUGGING_PORT',\n arg: 'debugging-port',\n },\n debuggingAddress: {\n doc: `The chrome debugging listening address. If unset, the network default interface address will be used.`,\n format: String,\n nullable: true,\n default: '127.0.0.1',\n env: 'DEBUGGING_ADDRESS',\n arg: 'debugging-address',\n },\n emulateCpuThrottling: {\n doc: `The emulated CPU throttling factor. If set, the page will be throttled to the specified factor.`,\n format: 'nat',\n default: 0,\n env: 'EMULATE_CPU_THROTTLING',\n arg: 'emulate-cpu-throttling',\n },\n // stats config\n showStats: {\n doc: `If the statistics should be displayed on the console output.`,\n format: 'Boolean',\n default: true,\n env: 'SHOW_STATS',\n arg: 'show-stats',\n },\n statsPath: {\n doc: `The log file path; if set, the stats will be written in \\\na .csv file inside that file.`,\n format: String,\n default: '',\n env: 'STATS_PATH',\n arg: 'stats-path',\n },\n detailedStatsPath: {\n doc: `The log file path; if set, the detailed stats will be written in \\\na .csv file inside that file. \\\nUse \\`webrtcperf --plot <detailed-stats-file> <output-file>.html\\` to generate a HTML plot.`,\n format: String,\n default: '',\n env: 'DETAILED_STATS_PATH',\n arg: 'detailed-stats-path',\n },\n statsInterval: {\n doc: `The stats collect interval in seconds. It should be lower than the \\\nPrometheus scraping interval.`,\n format: 'nat',\n default: 15,\n env: 'STATS_INTERVAL',\n arg: 'stats-interval',\n },\n rtcStatsTimeout: {\n doc: `The timeout in seconds after which the RTC stats coming from inactive\\\n hosts are removed. It should be higher than the \\`statsInterval\\` value.`,\n format: 'nat',\n default: 60,\n env: 'RTC_STATS_TIMEOUT',\n arg: 'rtc-stats-timeout',\n },\n customMetrics: {\n doc: `A dictionary of custom metrics keys in JSON5 format (e.g. \\\n'{ statName1: { labels: [\"label1\"] } }').`,\n format: String,\n nullable: true,\n default: '',\n env: 'CUSTOM_METRICS',\n arg: 'custom-metrics',\n },\n //\n prometheusPushgateway: {\n doc: `If set, logs are sent to the specified Prometheus Pushgateway \\\nservice (example: \"http://127.0.0.1:9091\").`,\n format: 'String',\n default: '',\n nullable: true,\n env: 'PROMETHEUS_PUSHGATEWAY',\n arg: 'prometheus-pushgateway',\n },\n prometheusPushgatewayJobName: {\n doc: `The Prometheus Pushgateway job name.`,\n format: 'String',\n default: 'default',\n env: 'PROMETHEUS_PUSHGATEWAY_JOB_NAME',\n arg: 'prometheus-pushgateway-job-name',\n },\n prometheusPushgatewayAuth: {\n doc: `The Prometheus Pushgateway basic auth (username:password).`,\n format: 'String',\n default: '',\n nullable: true,\n env: 'PROMETHEUS_PUSHGATEWAY_AUTH',\n arg: 'prometheus-pushgateway-auth',\n },\n prometheusPushgatewayGzip: {\n doc: `Allows to use gzip encoded pushgateway requests.`,\n format: 'Boolean',\n default: true,\n env: 'PROMETHEUS_PUSHGATEWAY_GZIP',\n arg: 'prometheus-pushgateway-gzip',\n },\n //\n alertRules: {\n doc: `Alert rules definition (in JSON format).`,\n format: String,\n nullable: true,\n default: '',\n env: 'ALERT_RULES',\n arg: 'alert-rules',\n },\n alertRulesOutput: {\n doc: `The alert rules report output filename. If the file ends with .log extension, a detailed log will be generated, otherwise a JSON report will be generated.`,\n format: String,\n nullable: true,\n default: '',\n env: 'ALERT_RULES_OUTPUT',\n arg: 'alert-rules-output',\n },\n alertRulesFailPercentile: {\n doc: `The alert rules report fails percentile (0-100). With the default value the \\\nalert will be successful only when at least 95% of the checks pass.`,\n format: 'nat',\n nullable: false,\n default: 95,\n env: 'ALERT_RULES_FAIL_PERCENTILE',\n arg: 'alert-rules-fail-percentile',\n },\n pushStatsUrl: {\n doc: `The URL to push the collected stats.`,\n format: String,\n nullable: true,\n default: '',\n env: 'PUSH_STATS_URL',\n arg: 'push-stats-url',\n },\n pushStatsId: {\n doc: `The ID of the collected stats to push.`,\n format: String,\n nullable: true,\n default: 'default',\n env: 'PUSH_STATS_ID',\n arg: 'push-stats-id',\n },\n // server config\n serverPort: {\n doc: `The HTTP server listening port.`,\n format: 'nat',\n nullable: true,\n default: 0,\n env: 'SERVER_PORT',\n arg: 'server-port',\n },\n serverSecret: {\n doc: `The HTTP server basic auth secret. The auth user name is set to \\`admin\\` by default.`,\n format: String,\n default: 'secret',\n nullable: true,\n env: 'SERVER_SECRET',\n arg: 'server-secret',\n },\n serverUseHttps: {\n doc: `If true, the server will use the HTTPS protocol.`,\n format: 'Boolean',\n default: false,\n env: 'SERVER_USE_HTTPS',\n arg: 'server-use-https',\n },\n serverData: {\n doc: `An optional path that the HTTP server will expose with the /data endpoint.`,\n format: String,\n nullable: true,\n default: '',\n env: 'SERVER_DATA',\n arg: 'server-data',\n },\n // VMAF config\n vmafPath: {\n doc: `When set, it runs the VMAF calculator for the video files saved under the provided directory path.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_PATH',\n arg: 'vmaf-path',\n },\n vmafPreview: {\n doc: `If true, for each VMAF comparison it creates a side-by-side video with \\\nthe reference and degraded versions.`,\n format: 'Boolean',\n default: false,\n env: 'VMAF_PREVIEW',\n arg: 'vmaf-preview',\n },\n vmafKeepIntermediateFiles: {\n doc: `If true, the VMAF intermediate files will not be deleted.`,\n format: 'Boolean',\n default: false,\n env: 'VMAF_KEEP_INTERMEDIATE_FILES',\n arg: 'vmaf-keep-intermediate-files',\n },\n vmafKeepSourceFiles: {\n doc: `If true, the VMAF source files will not be deleted.`,\n format: 'Boolean',\n default: true,\n env: 'VMAF_KEEP_SOURCE_FILES',\n arg: 'vmaf-keep-source-files',\n },\n vmafSkipDuplicated: {\n doc: `If true, the VMAF will skip duplicated recognized frames.`,\n format: 'Boolean',\n default: false,\n env: 'VMAF_SKIP_DUPLICATED',\n arg: 'vmaf-skip-duplicated',\n },\n vmafCrop: {\n doc: `If set, the reference and degraded videos will be cropped using the specified configuration in JSON5 format. \\\nCrop configuration should be expressed using the ffmpeg crop filter syntax (https://ffmpeg.org/ffmpeg-filters.html#crop). \\\nE.g. \\`{ \"Participant-000001_recv-by_Participant-000000\": { ref: { w: \"iw-10\", h: \"ih-5\" }, deg: { w: \"200\", h: \"200\" } } }\\``,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_CROP',\n arg: 'vmaf-crop',\n },\n vmafPrepareVideo: {\n doc: `When set, it prepares the selected video applying a timestamp overlay on top of it. \\\nThe filename must be provided in the format \\`<video path>,<ID>\\`, where the selected ID will be used unique video identifier in the overlay.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_PREPARE_VIDEO',\n arg: 'vmaf-prepare-video',\n },\n vmafProcessVideo: {\n doc: `When set, it runs the VMAF video preprocessor, that converts a video file into the IVF format with timestamps matching the overlay recognition. \\\nThe filename must contain a \\`recv\\` or \\`send\\` string to identify if the video was a reference (send) or a degraded version (recv), e.g. \\`Participant1_recv.mp4\\`.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_PROCESS_VIDEO',\n arg: 'vmaf-process-video',\n },\n vmafVideoCrop: {\n doc: `If set, the vmaf prepared/processed video will be cropped using the specified configuration in JSON5 format. \\\nCrop configuration should be expressed using the ffmpeg crop filter syntax (https://ffmpeg.org/ffmpeg-filters.html#crop). \\\nE.g. \\`{ w: \"iw-10\", h: \"ih-5\", x: \"10\", y: '5' }\\``,\n format: String,\n nullable: true,\n default: '',\n env: 'VMAF_VIDEO_CROP',\n arg: 'vmaf-video-crop',\n },\n // VISQOL config\n visqolPath: {\n doc: `When set, it runs the visqol calculator for the audio files saved under the provided directory path.`,\n format: String,\n nullable: true,\n default: '',\n env: 'VISQOL_PATH',\n arg: 'visqol-path',\n },\n visqolKeepSourceFiles: {\n doc: `If true, the visqol source files will not be deleted.`,\n format: 'Boolean',\n default: true,\n env: 'VISQOL_KEEP_SOURCE_FILES',\n arg: 'visqol-keep-source-files',\n },\n}\n\ntype ConfigDocs = Record<string, { doc: string; format: string; default: string }>\n\n/**\n * Formats the schema documentation, calling the same function recursively.\n * @param docs the documentation object to extend\n * @param property the root property\n * @param schema the config schema fragment\n * @return the documentation object\n */\nfunction formatDocs(\n docs: ConfigDocs,\n property: string | null,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: any,\n): ConfigDocs {\n if (schema._cvtProperties) {\n Object.entries(schema._cvtProperties).forEach(([name, value]) => {\n formatDocs(docs, `${property ? `${property}.` : ''}${name}`, value)\n })\n return docs\n }\n\n if (property) {\n docs[property] = {\n doc: schema.doc,\n format: JSON.stringify(schema.format, null, 2),\n default: JSON.stringify(schema.default, null, 2),\n }\n }\n return docs\n}\n\n/**\n * It returns the formatted configuration docs.\n */\nexport function getConfigDocs(): ConfigDocs {\n return formatDocs({}, null, convict(configSchema).getSchema())\n}\n\n/**\n * Returns a Zod schema for the config object, with all parameters optional and described.\n * Uses the config default values when a field is omitted. Useful for MCP tools and other\n * consumers that need validated partial config.\n */\nexport function getConfigZodSchema(): z.ZodObject<Record<string, z.ZodTypeAny>> {\n const schema = convict(configSchema).getSchema()\n const shape: Record<string, z.ZodTypeAny> = {}\n for (const [key, value] of Object.entries(schema._cvtProperties)) {\n const prop = value as SchemaObj & { doc?: string; format?: unknown; default?: unknown }\n const doc = prop.doc ?? key\n const def = prop.default\n const format = prop.format\n let zodType: z.ZodTypeAny\n if (format === String || format === 'string') {\n zodType = z.string()\n } else if (format === 'nat' || format === Number) {\n zodType = z.number()\n } else if (format === 'float') {\n zodType = z.number()\n } else if (format === 'Boolean' || format === 'boolean') {\n zodType = z.boolean()\n } else if (format === 'index') {\n zodType = z.union([z.string(), z.number(), z.boolean()])\n } else if (Array.isArray(format)) {\n zodType = z.enum(format as [string, ...string[]])\n } else {\n zodType = z.union([z.string(), z.number(), z.boolean()])\n }\n shape[key] = def !== undefined ? zodType.default(def).describe(doc) : zodType.optional().describe(doc)\n }\n return z.object(shape)\n}\n\nconst _schemaProperties = convict(configSchema).getProperties()\n\n/** [[include:config.md]] */\nexport type Config = typeof _schemaProperties\n\n/**\n * Loads the config object.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function loadConfig(filePath?: string, values?: any): Promise<Config[]> {\n const configs: Config[] = []\n if (filePath) {\n if (filePath.startsWith('http')) {\n log.debug(`Loading config from url: ${filePath}`)\n const res = await downloadUrl(filePath)\n if (!res?.data) {\n throw new Error(`Failed to download configuration from: ${filePath}`)\n }\n values =\n res.contentType === 'application/x-yaml'\n ? yaml.parse(res.data)\n : res.contentType === 'application/toml'\n ? toml.parse(res.data)\n : json5.parse(res.data)\n } else {\n if (!existsSync(filePath)) {\n throw new Error(`Config file not found: ${filePath}`)\n }\n log.debug(`Loading config from local file: ${filePath}`)\n if (filePath.endsWith('.js') || filePath.endsWith('.mjs')) {\n const module = await import(/* webpackIgnore: true */ path.resolve(filePath))\n values = await module.default(process.argv)\n } else {\n const data = String(await fs.promises.readFile(filePath))\n values =\n filePath.endsWith('.yml') || filePath.endsWith('.yaml')\n ? yaml.parse(data)\n : filePath.endsWith('.toml')\n ? toml.parse(data)\n : json5.parse(data)\n }\n }\n }\n if (!Array.isArray(values)) {\n values = [values || {}]\n }\n for (const value of values) {\n const schema = convict(configSchema)\n schema.load(value || {})\n schema.validate({ allowed: 'strict' })\n configs.push(schema.getProperties())\n }\n log.debug('Using config:', configs)\n return configs\n}\n\nfunction getFunctionDeclaration() {\n const properties: Record<string, { type: string; description: string; nullable?: boolean }> = {}\n const required: string[] = []\n const schema = convict(configSchema).getSchema()\n\n Object.entries(schema._cvtProperties).forEach(([name, value]) => {\n const { format, doc, nullable } = value as SchemaObj\n properties[name] = {\n type: format as string,\n description: doc as string,\n nullable,\n }\n })\n\n return {\n name: 'webrtcperf',\n description: 'Starts a webrtcperf test.',\n parameters: {\n type: 'object',\n properties,\n required,\n },\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst { GoogleGenAI } = require('@google/genai')\n\nexport async function loadConfigFromPrompt(prompt: string) {\n log.debug(`loadConfigFromPrompt: \"${prompt}\"`)\n if (!process.env.GEMINI_API_KEY) {\n throw new Error('GEMINI_API_KEY environment variable is not set. Please set it to use the Google GenAI API.')\n }\n const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY })\n const response = await ai.models.generateContent({\n model: 'gemini-2.5-flash',\n contents: prompt,\n config: {\n tools: [\n {\n functionDeclarations: [getFunctionDeclaration()],\n },\n ],\n thinkingConfig: {\n thinkingBudget: 0,\n },\n },\n })\n if (response.functionCalls && response.functionCalls.length > 0) {\n const functionCall = response.functionCalls[0]\n log.debug('Using function call:', functionCall.name, functionCall.args)\n return functionCall.args\n } else {\n throw new Error('No function call found in the response. Please check the prompt and try again.')\n }\n}\n"]}
@@ -105,7 +105,7 @@ class Server {
105
105
  limit: '10mb',
106
106
  }));
107
107
  this.app.use((req, res, next) => {
108
- if (req.query.auth === this.serverSecret) {
108
+ if (!this.serverSecret || req.query.auth === this.serverSecret) {
109
109
  return next();
110
110
  }
111
111
  const credentials = (0, basic_auth_1.default)(req);
@@ -139,7 +139,7 @@ class Server {
139
139
  log.error(`mkdir ${this.serverData} error: ${err.message}`);
140
140
  });
141
141
  this.app.get('/data', this.getDataArchive.bind(this));
142
- this.app.get('/data/:path', this.getData.bind(this));
142
+ this.app.get('/data/*filepath', this.getData.bind(this));
143
143
  }
144
144
  if (this.videoCachePath) {
145
145
  log.debug(`using videoCachePath: ${this.videoCachePath}`);
@@ -442,7 +442,9 @@ class Server {
442
442
  * content in tar.gz format.
443
443
  */
444
444
  getData(req, res, next) {
445
- const paramPath = path_1.default.normalize(req.params.path).replace(/^(\.\.(\/|\\|$))+/, '');
445
+ const requestPath = req.params.filepath;
446
+ const filepath = Array.isArray(requestPath) ? requestPath.join('/') : requestPath;
447
+ const paramPath = path_1.default.normalize(filepath).replace(/^(\.\.(\/|\\|$))+/, '');
446
448
  log.debug(`GET /data/${paramPath}`, req.query);
447
449
  const fpath = path_1.default.resolve(this.serverData, paramPath);
448
450
  if (!fs_1.default.existsSync(fpath)) {
@@ -451,6 +453,9 @@ class Server {
451
453
  if (req.query.range && !req.headers.range) {
452
454
  req.headers.range = `bytes=${req.query.range}`;
453
455
  }
456
+ if (['.js', '.mjs', '.cjs'].includes(path_1.default.extname(fpath).toLowerCase())) {
457
+ res.type('application/javascript');
458
+ }
454
459
  res.sendFile(fpath, { dotfiles: 'allow' });
455
460
  }
456
461
  getDataArchive(req, res, next) {
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAqC;AACrC,mCAAwC;AACxC,mDAAuC;AACvC,4CAAmB;AACnB,+BAAyD;AACzD,iCAA4E;AAC5E,4CAAmB;AACnB,gDAAuB;AACvB,oDAAwB;AACxB,2BAAoC;AACpC,gDAAuB;AACvB,4DAA6B;AAE7B,qCAA6C;AAC7C,uCAAkD;AAElD,mCAAoE;AACpE,qDAA+D;AAC/D,mCAAqD;AAErD,MAAM,GAAG,GAAG,IAAA,cAAM,EAAC,mBAAmB,CAAC,CAAA;AAEvC;;;;GAIG;AACH,MAAa,MAAM;IACjB,iCAAiC;IACxB,UAAU,CAAQ;IAC3B,6BAA6B;IACpB,YAAY,CAAQ;IAC7B,wCAAwC;IAC/B,cAAc,CAAS;IAChC,iFAAiF;IACjF,UAAU,CAAQ;IAClB,gFAAgF;IAChF,WAAW,CAAQ;IACnB,mEAAmE;IACnE,cAAc,CAAQ;IACtB,sCAAsC;IACtC,KAAK,CAAO;IAEJ,GAA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AC,KAAK,CAAC,MAAM,CAAC,CAAA;YACjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;YACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACpB,CAAC;IACH,CAAC;CACF;AA7nBD,wBA6nBC","sourcesContent":["import compression from 'compression'\nimport { timingSafeEqual } from 'crypto'\nimport express, { json } from 'express'\nimport fs from 'fs'\nimport { Server as HttpServer, createServer } from 'http'\nimport { Server as HttpsServer, createServer as _createServer } from 'https'\nimport os from 'os'\nimport path from 'path'\nimport tar from 'tar-fs'\nimport { WebSocketServer } from 'ws'\nimport zlib from 'zlib'\nimport auth from 'basic-auth'\n\nimport { Config, loadConfig } from './config'\nimport { Session, SessionParams } from './session'\nimport { Stats } from './stats'\nimport { logger, runShellCommand, getDockerLogsPath } from './utils'\nimport { getSessionThrottleIndex } from '@vpalmisano/throttler'\nimport { MediaPath, prepareFakeMedia } from './media'\n\nconst log = logger('webrtcperf:server')\n\n/**\n * An HTTP server instance that allows to control the tool using a REST\n * interface. Moreover, it allows to aggregate stats data coming from multiple\n * running tool instances.\n */\nexport class Server {\n /** The server listening port. */\n readonly serverPort: number\n /** The basic auth secret. */\n readonly serverSecret: string\n /** If HTTPS protocol should be used. */\n readonly serverUseHttps: boolean\n /** An optional path that the HTTP server will expose with the /data endpoint. */\n serverData: string\n /** The file path that will be used to serve the \\`/view/page.log\\` requests. */\n pageLogPath: string\n /** The path that will be used to serve the \\`/cache\\` requests. */\n videoCachePath: string\n /** A {@link Stats} class instance. */\n stats: Stats\n\n private app: express.Express\n private server: HttpServer | HttpsServer | null = null\n private wss: WebSocketServer | null = null\n\n /**\n * Server instance.\n * All the HTTP endpoints are protected by basic authentication with user\n * `admin` and password {@link Server.serverSecret}.\n * @param serverPort The server listening port.\n * @param serverSecret The basic auth secret.\n * @param serverUseHttps If HTTPS protocol should be used.\n * @param serverData An optional path that the HTTP server will expose with the /data endpoint.\n * @param pageLogPath The file path that will be used to serve the \\`/view/page.log\\` requests.\n * @param videoCachePath The path that will be used to serve the \\`/cache\\` requests.\n * @param stats A {@link Stats} class instance.\n */\n constructor(\n {\n serverPort = 5000,\n serverSecret = 'secret',\n serverUseHttps = false,\n serverData = '',\n pageLogPath = '',\n videoCachePath = '',\n } = {},\n stats: Stats,\n ) {\n this.serverPort = serverPort\n this.serverSecret = serverSecret\n this.serverUseHttps = serverUseHttps\n this.serverData = serverData\n this.pageLogPath = pageLogPath\n this.videoCachePath = videoCachePath\n this.stats = stats\n //\n this.app = express()\n this.app.use(compression())\n this.app.use(\n json({\n limit: '10mb',\n }),\n )\n\n this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {\n if (req.query.auth === this.serverSecret) {\n return next()\n }\n const credentials = auth(req)\n if (!credentials || credentials.name !== 'admin' || credentials.pass !== this.serverSecret) {\n res.setHeader('WWW-Authenticate', 'Basic realm=\"Restricted Area\"')\n res.status(401).send('Unauthorized')\n return\n }\n next()\n })\n\n this.app.get('/', (_req, res) => {\n res.send('')\n })\n\n this.app.get('/stats', this.getStats.bind(this))\n this.app.get('/collected-stats', this.getCollectedStats.bind(this))\n this.app.get('/screenshot/:sessionId', this.getScreenshot.bind(this))\n this.app.put('/collected-stats', this.putCollectedStats.bind(this))\n this.app.put('/session', this.putSession.bind(this))\n this.app.put('/sessions', this.putSessions.bind(this))\n this.app.delete('/session', this.deleteSession.bind(this))\n this.app.delete('/sessions', this.deleteSessions.bind(this))\n this.app.get('/view/page.log', this.getPageLog.bind(this))\n this.app.get('/view/docker.log', this.getDockerLog.bind(this))\n this.app.get('/download/alert-rules', this.getAlertRules.bind(this))\n this.app.get('/download/stats', this.getStatsFile.bind(this))\n this.app.get('/download/detailed-stats', this.getDetailedStatsFile.bind(this))\n this.app.get('/empty-page', this.getEmptyPage.bind(this))\n if (this.serverData) {\n log.debug(`using serverData: ${this.serverData}`)\n fs.promises.mkdir(this.serverData, { recursive: true }).catch(err => {\n log.error(`mkdir ${this.serverData} error: ${err.message}`)\n })\n this.app.get('/data', this.getDataArchive.bind(this))\n this.app.get('/data/:path', this.getData.bind(this))\n }\n if (this.videoCachePath) {\n log.debug(`using videoCachePath: ${this.videoCachePath}`)\n fs.promises.mkdir(this.videoCachePath, { recursive: true }).catch(err => {\n log.error(`mkdir ${this.videoCachePath} error: ${err.message}`)\n })\n this.app.get('/cache/:path', this.getCache.bind(this))\n }\n\n this.app.use((err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {\n log.error(`request path=${req.path} error:`, err.stack)\n if (res.headersSent) {\n return next(err)\n }\n res.status(500).send(err.message)\n })\n }\n\n /*\n * onConnection\n * @param {Socket} socket\n */\n /* onConnection(socket) {\n log.debug('onConnection', socket);\n\n socket.on('disconnect', () => {\n log.debug('io socket disconnected');\n });\n\n socket.on('message', (msg) => {\n log.debug('message', msg);\n });\n } */\n\n /**\n * GET /stats endpoint.\n *\n * Returns a JSON array of the last statistics for each running Session.\n */\n private async getStats(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`GET /stats`)\n const stats = []\n try {\n for (const session of this.stats.sessions.values()) {\n stats.push(session.stats)\n }\n res.json(stats)\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /download/stats endpoint.\n *\n * Returns the {@link Stats.statsWriter} file content.\n */\n private getStatsFile(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`/download/stats`, req.query)\n if (!this.stats.statsWriter) {\n return next(new Error('statsPath not set'))\n }\n res.download(this.stats.statsPath)\n }\n\n /**\n * GET /download/detailed-stats endpoint.\n *\n * Returns the {@link Stats.detailedStatsWriter} file content.\n */\n private getDetailedStatsFile(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`/download/detailed-stats`, req.query)\n if (!this.stats.detailedStatsWriter) {\n return next(new Error('detailedStatsPath not set'))\n }\n res.download(this.stats.detailedStatsPath)\n }\n\n /**\n * GET /collected-stats endpoint.\n *\n * Returns a JSON array of the last statistics collected from external running\n * tools.\n */\n private getCollectedStats(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /collected-stats`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stats: Record<string, any> = {}\n try {\n for (const [key, stat] of Object.entries(this.stats.collectedStats)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stats[key] = (stat as any).data\n }\n res.json(stats)\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /screenshot/<sessionID> endpoint.\n *\n * Returns the page screenshot running inside the {@link Session} identified\n * by `sessionID`.\n * Additional query params:\n * - `page`: the page number (starting from `0`) running inside the {@link Session}.\n * - `format`: the image format (`jpeg`, `png`, `webp`). Default: `webp`.\n */\n private async getScreenshot(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n const sessionId = parseInt(req.params.sessionId)\n const pageId = parseInt((req.query.page as string) || '0')\n const format = (req.query.format as string) || 'webp'\n log.debug(`GET /screenshot/${sessionId} page=${pageId} format=${format}`)\n try {\n const session = this.stats.sessions.get(sessionId)\n if (!session) {\n throw new Error(`Session not found: \"${sessionId}\"`)\n }\n const filePath = await session.pageScreenshot(pageId, format)\n res.sendFile(path.resolve(filePath), { dotfiles: 'allow' })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * PUT /collected-stats endpoint.\n *\n * Allows to inject {@link Stats} metrics coming from an external tool.\n */\n private putCollectedStats(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`PUT /collected-stats`)\n const { id, stats, config } = req.body\n try {\n this.stats.addExternalCollectedStats(id, stats, config)\n res.json({\n message: `Collected stats added`,\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * PUT /session endpoint.\n *\n * Starts a new {@link Session}.\n * The request body format will be parsed as a {@link SessionParams} object.\n */\n private async putSession(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`PUT /session`, req.body)\n try {\n const config = req.body as Config\n const id = this.stats.consumeSessionId(config.tabsPerSession)\n await this.startLocalSession(id, req.body)\n res.json({\n message: `Session created`,\n data: { id },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * PUT /sessions endpoint.\n *\n * Starts multiple {@link Session} instances as specified into the\n * `body.sessions` value.\n * The request body will be parsed as a {@link SessionParams} object.\n */\n private async putSessions(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`PUT /sessions`, req.body)\n try {\n const { sessions, tabsPerSession } = req.body as Config\n const sessionsIds = []\n for (let i = 0; i < sessions; i++) {\n const id = this.stats.consumeSessionId(tabsPerSession)\n await this.startLocalSession(id, req.body)\n sessionsIds.push(id)\n }\n res.json({\n message: `${sessions} sessions created`,\n data: { ids: sessionsIds },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * DELETE /session endpoint.\n *\n * Delete the {@link Session} instance identified by the `body.id` param.\n */\n private async deleteSession(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`DELETE /session`, req.body)\n try {\n const { id } = req.body\n await this.stopLocalSession(id)\n res.json({\n message: `Session deleted`,\n data: { id },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * DELETE /sessions endpoint.\n *\n * Delete the {@link Session} instances specified by the `body.ids` array.\n */\n private async deleteSessions(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`DELETE /sessions`, req.body)\n try {\n const { ids } = req.body\n for (const id of ids) {\n await this.stopLocalSession(id)\n }\n res.json({\n message: `${ids.length} sessions deleted`,\n data: { ids },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /view/page.log endpoint.\n *\n * Returns the page log file content as specified in {@link Config} `pageLogPath`.\n */\n private getPageLog(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /view/page.log`, req.query)\n if (!this.pageLogPath) {\n return next(new Error('pageLogPath not set'))\n }\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(path.resolve(this.pageLogPath), { dotfiles: 'allow' })\n }\n\n /**\n * GET /view/docker.log endpoint.\n *\n * Returns the Docker logs related to the container running the tool.\n * It requires to run the Docker container with the following options:\n * ```\n --cidfile /tmp/docker.id\n -v /tmp/docker.id:/root/.webrtcperf/docker.id:ro\n -v /var/lib/docker:/var/lib/docker:ro\n * ```\n */\n private async getDockerLog(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`GET /view/docker.log`, req.query)\n try {\n const logPath = await getDockerLogsPath()\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(path.resolve(logPath), { dotfiles: 'allow' })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /download/alert-rules endpoint.\n *\n * Downloads the alert rules report stored into the {@link Stats.alertRulesOutput}.\n */\n private getAlertRules(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /download/alert-rules`, req.query)\n if (!this.stats.alertRulesOutput) {\n return next(new Error('Stats alertRulesOutput not set'))\n }\n res.download(this.stats.alertRulesOutput)\n }\n\n /**\n * GET /empty-page endpoint.\n *\n * Returns an empty HTML page. Useful for running tests with raw Javascript\n * content without any DOM rendering.\n */\n private getEmptyPage(req: express.Request, res: express.Response): void {\n log.debug(`GET /empty-page`, req.query)\n const title = req.query.title || 'EmptyPage'\n res.send(`<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>${title}</title>\n</head>\n<body></body>\n</html>`)\n }\n\n /**\n * GET /data/* endpoint.\n *\n * Returns the file content relative to the {@link Config} `serverData` path.\n * If the requested path points to a directory, it returns the directory\n * content in tar.gz format.\n */\n private getData(req: express.Request, res: express.Response, next: express.NextFunction): void {\n const paramPath = path.normalize(req.params.path).replace(/^(\\.\\.(\\/|\\\\|$))+/, '')\n log.debug(`GET /data/${paramPath}`, req.query)\n const fpath = path.resolve(this.serverData, paramPath)\n if (!fs.existsSync(fpath)) {\n return next(new Error(`${paramPath} not found`))\n }\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(fpath, { dotfiles: 'allow' })\n }\n\n private getDataArchive(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /data`, req.query)\n const fpath = path.resolve(this.serverData)\n if (!fs.lstatSync(fpath).isDirectory()) {\n return next(new Error(`${fpath} is not a directory`))\n }\n res.header('Content-Disposition', `attachment; filename=\"${path.basename(fpath)}.tar.gz\"`)\n res.setHeader('content-type', 'application/gzip')\n tar.pack(fpath).pipe(zlib.createGzip()).pipe(res)\n }\n\n private getCache(req: express.Request, res: express.Response, next: express.NextFunction): void {\n const paramPath = path.normalize(req.params.path).replace(/^(\\.\\.(\\/|\\\\|$))+/, '')\n log.debug(`GET /cache/${paramPath}`, req.query)\n const fpath = path.resolve(this.videoCachePath, paramPath)\n if (!fs.existsSync(fpath)) {\n return next(new Error(`${paramPath} not found`))\n }\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(fpath, { dotfiles: 'allow' })\n }\n\n /**\n * Starts a new {@link Session} instance.\n * @param id The session unique id.\n * @param config The session configuration.\n */\n private async startLocalSession(id: number, config: SessionParams): Promise<Session> {\n const configs = await loadConfig(undefined, config)\n const sessionConfig = configs[0]\n const throttleIndex = getSessionThrottleIndex(id)\n const spawnPeriod = 1000 / sessionConfig.spawnRate\n\n // Prepare fake video and audio.\n const mediaPaths: MediaPath[] = []\n if (sessionConfig.videoPath) {\n for (const videoPath of sessionConfig.videoPath.split(',')) {\n const ret = await prepareFakeMedia({ ...sessionConfig, videoPath })\n mediaPaths.push(ret)\n }\n }\n const mediaPath = mediaPaths.length ? mediaPaths[id % mediaPaths.length] : undefined\n\n const session = new Session({ ...sessionConfig, throttleIndex, spawnPeriod, mediaPath, id })\n session.once('stop', () => {\n console.warn(`Session ${id} stopped, reloading...`)\n setTimeout(this.startLocalSession.bind(this), spawnPeriod, id, config)\n })\n this.stats.addSession(session)\n try {\n await session.start()\n } catch (err) {\n this.stats.removeSession(session.id)\n throw err\n }\n return session\n }\n\n /**\n * Stops a new {@link Session} instance.\n * @param {number} id The session unique id.\n */\n private async stopLocalSession(id: number): Promise<void> {\n const session = this.stats.sessions.get(id)\n if (!session) {\n log.warn(`stopLocalSession session ${id} not found`)\n return\n }\n session.removeAllListeners()\n this.stats.removeSession(id)\n await session.stop()\n }\n\n /**\n * Starts the {@link Server} instance.\n */\n async start(): Promise<void> {\n log.debug('start')\n if (this.serverUseHttps) {\n const destDir = path.join(os.homedir(), '.webrtcperf/ssl')\n const keyPath = path.join(destDir, 'domain.key')\n const crtPath = path.join(destDir, 'domain.crt')\n if (!fs.existsSync(keyPath) || !fs.existsSync(crtPath)) {\n await runShellCommand(\n `mkdir -p ${destDir} && openssl req -newkey rsa:2048 -nodes -keyout ${keyPath} -x509 -days 365 -out ${crtPath} -subj \"/C=EU/ST=London/L=London/O=Global Security/OU=IT Department/CN=example.com\"`,\n )\n }\n this.server = _createServer(\n {\n key: fs.readFileSync(keyPath),\n cert: fs.readFileSync(crtPath),\n },\n this.app,\n )\n } else {\n this.server = createServer(this.app)\n }\n\n // WebSocket endpoint.\n const wss = new WebSocketServer({ noServer: true })\n wss.on('connection', (ws, request) => {\n try {\n const query = new URLSearchParams(request.url?.split('?')[1] || '')\n const action = query.get('action') || ''\n log.debug(`ws connection from ${request.socket.remoteAddress} action: ${action}`)\n switch (action) {\n case 'write-stream': {\n if (!this.serverData) {\n throw new Error('serverData option not set')\n }\n const filename = query.get('filename') || ''\n if (!filename) {\n throw new Error('filename not set')\n }\n const paramPath = path.normalize(filename).replace(/^(\\.\\.(\\/|\\\\|$))+/, '')\n\n log.debug(`ws write-stream ${paramPath}`)\n const fpath = path.resolve(this.serverData, paramPath)\n if (fs.existsSync(fpath)) {\n throw new Error(`file already exists: ${fpath}`)\n }\n const stream = fs.createWriteStream(fpath)\n\n let headerWritten = false\n let framesWritten = 0\n\n const close = async () => {\n stream.close()\n ws.close()\n\n try {\n if (!framesWritten) {\n await fs.promises.unlink(fpath)\n }\n } catch (err) {\n log.error(`ws write-stream close error: ${(err as Error).message}`)\n }\n }\n\n stream.on('error', (err: Error) => {\n log.error(`ws write-stream error: ${err.message}`)\n void close()\n })\n\n ws.on('error', (err: Error) => {\n log.error(`ws write-stream error: ${err.message}`)\n void close()\n })\n\n ws.on('close', () => {\n log.debug(`ws write-stream close`)\n void close()\n })\n\n ws.on('message', (data: Uint8Array) => {\n if (!data?.byteLength) return\n if (!headerWritten) {\n stream.write(data)\n headerWritten = true\n return\n }\n stream.write(data)\n framesWritten++\n })\n\n break\n }\n default:\n throw new Error(`invalid action: ${action}`)\n }\n } catch (err) {\n log.error(`ws connection error: ${(err as Error).message}`)\n ws.close()\n }\n })\n this.wss = wss\n\n this.server.on('upgrade', (request, socket, head) => {\n log.debug(`ws upgrade ${request.url}`)\n try {\n const query = new URLSearchParams(request.url?.split('?')[1] || '')\n const auth = query.get('auth')\n if (!auth || !timingSafeEqual(Buffer.from(auth), Buffer.from(this.serverSecret))) {\n throw new Error('invalid auth')\n }\n } catch (err) {\n log.error(`ws upgrade error: ${(err as Error).message}`)\n socket.write('HTTP/1.1 401 Unauthorized\\r\\n\\r\\n')\n socket.destroy()\n return\n }\n\n wss.handleUpgrade(request, socket, head, ws => {\n wss.emit('connection', ws, request)\n })\n })\n\n this.server.listen(this.serverPort, () => {\n log.debug(`HTTPS server listening on port ${this.serverPort}`)\n })\n }\n\n /**\n * Stops the {@link Server} instance.\n */\n stop(): void {\n if (this.wss) {\n this.wss.close()\n this.wss = null\n }\n if (this.server) {\n log.debug('stop')\n this.server.close()\n this.server = null\n }\n }\n}\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAqC;AACrC,mCAAwC;AACxC,mDAAuC;AACvC,4CAAmB;AACnB,+BAAyD;AACzD,iCAA4E;AAC5E,4CAAmB;AACnB,gD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CAAC;oBACjF,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;gBACjC,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,GAAG,CAAC,KAAK,CAAC,qBAAsB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAA;gBACxD,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;gBACjD,MAAM,CAAC,OAAO,EAAE,CAAA;gBAChB,OAAM;YACR,CAAC;YAED,GAAG,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE;gBAC5C,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;YACrC,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YACvC,GAAG,CAAC,KAAK,CAAC,kCAAkC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QAChE,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;YAChB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;QACjB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YACjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;YACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACpB,CAAC;IACH,CAAC;CACF;AAloBD,wBAkoBC","sourcesContent":["import compression from 'compression'\nimport { timingSafeEqual } from 'crypto'\nimport express, { json } from 'express'\nimport fs from 'fs'\nimport { Server as HttpServer, createServer } from 'http'\nimport { Server as HttpsServer, createServer as _createServer } from 'https'\nimport os from 'os'\nimport path from 'path'\nimport tar from 'tar-fs'\nimport { WebSocketServer } from 'ws'\nimport zlib from 'zlib'\nimport auth from 'basic-auth'\n\nimport { Config, loadConfig } from './config'\nimport { Session, SessionParams } from './session'\nimport { Stats } from './stats'\nimport { logger, runShellCommand, getDockerLogsPath } from './utils'\nimport { getSessionThrottleIndex } from '@vpalmisano/throttler'\nimport { MediaPath, prepareFakeMedia } from './media'\n\nconst log = logger('webrtcperf:server')\n\n/**\n * An HTTP server instance that allows to control the tool using a REST\n * interface. Moreover, it allows to aggregate stats data coming from multiple\n * running tool instances.\n */\nexport class Server {\n /** The server listening port. */\n readonly serverPort: number\n /** The basic auth secret. */\n readonly serverSecret: string\n /** If HTTPS protocol should be used. */\n readonly serverUseHttps: boolean\n /** An optional path that the HTTP server will expose with the /data endpoint. */\n serverData: string\n /** The file path that will be used to serve the \\`/view/page.log\\` requests. */\n pageLogPath: string\n /** The path that will be used to serve the \\`/cache\\` requests. */\n videoCachePath: string\n /** A {@link Stats} class instance. */\n stats: Stats\n\n private app: express.Express\n private server: HttpServer | HttpsServer | null = null\n private wss: WebSocketServer | null = null\n\n /**\n * Server instance.\n * All the HTTP endpoints are protected by basic authentication with user\n * `admin` and password {@link Server.serverSecret}.\n * @param serverPort The server listening port.\n * @param serverSecret The basic auth secret.\n * @param serverUseHttps If HTTPS protocol should be used.\n * @param serverData An optional path that the HTTP server will expose with the /data endpoint.\n * @param pageLogPath The file path that will be used to serve the \\`/view/page.log\\` requests.\n * @param videoCachePath The path that will be used to serve the \\`/cache\\` requests.\n * @param stats A {@link Stats} class instance.\n */\n constructor(\n {\n serverPort = 5000,\n serverSecret = 'secret',\n serverUseHttps = false,\n serverData = '',\n pageLogPath = '',\n videoCachePath = '',\n } = {},\n stats: Stats,\n ) {\n this.serverPort = serverPort\n this.serverSecret = serverSecret\n this.serverUseHttps = serverUseHttps\n this.serverData = serverData\n this.pageLogPath = pageLogPath\n this.videoCachePath = videoCachePath\n this.stats = stats\n //\n this.app = express()\n this.app.use(compression())\n this.app.use(\n json({\n limit: '10mb',\n }),\n )\n\n this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {\n if (!this.serverSecret || req.query.auth === this.serverSecret) {\n return next()\n }\n const credentials = auth(req)\n if (!credentials || credentials.name !== 'admin' || credentials.pass !== this.serverSecret) {\n res.setHeader('WWW-Authenticate', 'Basic realm=\"Restricted Area\"')\n res.status(401).send('Unauthorized')\n return\n }\n next()\n })\n\n this.app.get('/', (_req, res) => {\n res.send('')\n })\n\n this.app.get('/stats', this.getStats.bind(this))\n this.app.get('/collected-stats', this.getCollectedStats.bind(this))\n this.app.get('/screenshot/:sessionId', this.getScreenshot.bind(this))\n this.app.put('/collected-stats', this.putCollectedStats.bind(this))\n this.app.put('/session', this.putSession.bind(this))\n this.app.put('/sessions', this.putSessions.bind(this))\n this.app.delete('/session', this.deleteSession.bind(this))\n this.app.delete('/sessions', this.deleteSessions.bind(this))\n this.app.get('/view/page.log', this.getPageLog.bind(this))\n this.app.get('/view/docker.log', this.getDockerLog.bind(this))\n this.app.get('/download/alert-rules', this.getAlertRules.bind(this))\n this.app.get('/download/stats', this.getStatsFile.bind(this))\n this.app.get('/download/detailed-stats', this.getDetailedStatsFile.bind(this))\n this.app.get('/empty-page', this.getEmptyPage.bind(this))\n if (this.serverData) {\n log.debug(`using serverData: ${this.serverData}`)\n fs.promises.mkdir(this.serverData, { recursive: true }).catch(err => {\n log.error(`mkdir ${this.serverData} error: ${err.message}`)\n })\n this.app.get('/data', this.getDataArchive.bind(this))\n this.app.get('/data/*filepath', this.getData.bind(this))\n }\n if (this.videoCachePath) {\n log.debug(`using videoCachePath: ${this.videoCachePath}`)\n fs.promises.mkdir(this.videoCachePath, { recursive: true }).catch(err => {\n log.error(`mkdir ${this.videoCachePath} error: ${err.message}`)\n })\n this.app.get('/cache/:path', this.getCache.bind(this))\n }\n\n this.app.use((err: Error, req: express.Request, res: express.Response, next: express.NextFunction) => {\n log.error(`request path=${req.path} error:`, err.stack)\n if (res.headersSent) {\n return next(err)\n }\n res.status(500).send(err.message)\n })\n }\n\n /*\n * onConnection\n * @param {Socket} socket\n */\n /* onConnection(socket) {\n log.debug('onConnection', socket);\n\n socket.on('disconnect', () => {\n log.debug('io socket disconnected');\n });\n\n socket.on('message', (msg) => {\n log.debug('message', msg);\n });\n } */\n\n /**\n * GET /stats endpoint.\n *\n * Returns a JSON array of the last statistics for each running Session.\n */\n private async getStats(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`GET /stats`)\n const stats = []\n try {\n for (const session of this.stats.sessions.values()) {\n stats.push(session.stats)\n }\n res.json(stats)\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /download/stats endpoint.\n *\n * Returns the {@link Stats.statsWriter} file content.\n */\n private getStatsFile(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`/download/stats`, req.query)\n if (!this.stats.statsWriter) {\n return next(new Error('statsPath not set'))\n }\n res.download(this.stats.statsPath)\n }\n\n /**\n * GET /download/detailed-stats endpoint.\n *\n * Returns the {@link Stats.detailedStatsWriter} file content.\n */\n private getDetailedStatsFile(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`/download/detailed-stats`, req.query)\n if (!this.stats.detailedStatsWriter) {\n return next(new Error('detailedStatsPath not set'))\n }\n res.download(this.stats.detailedStatsPath)\n }\n\n /**\n * GET /collected-stats endpoint.\n *\n * Returns a JSON array of the last statistics collected from external running\n * tools.\n */\n private getCollectedStats(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /collected-stats`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stats: Record<string, any> = {}\n try {\n for (const [key, stat] of Object.entries(this.stats.collectedStats)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stats[key] = (stat as any).data\n }\n res.json(stats)\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /screenshot/<sessionID> endpoint.\n *\n * Returns the page screenshot running inside the {@link Session} identified\n * by `sessionID`.\n * Additional query params:\n * - `page`: the page number (starting from `0`) running inside the {@link Session}.\n * - `format`: the image format (`jpeg`, `png`, `webp`). Default: `webp`.\n */\n private async getScreenshot(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n const sessionId = parseInt(req.params.sessionId)\n const pageId = parseInt((req.query.page as string) || '0')\n const format = (req.query.format as string) || 'webp'\n log.debug(`GET /screenshot/${sessionId} page=${pageId} format=${format}`)\n try {\n const session = this.stats.sessions.get(sessionId)\n if (!session) {\n throw new Error(`Session not found: \"${sessionId}\"`)\n }\n const filePath = await session.pageScreenshot(pageId, format)\n res.sendFile(path.resolve(filePath), { dotfiles: 'allow' })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * PUT /collected-stats endpoint.\n *\n * Allows to inject {@link Stats} metrics coming from an external tool.\n */\n private putCollectedStats(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`PUT /collected-stats`)\n const { id, stats, config } = req.body\n try {\n this.stats.addExternalCollectedStats(id, stats, config)\n res.json({\n message: `Collected stats added`,\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * PUT /session endpoint.\n *\n * Starts a new {@link Session}.\n * The request body format will be parsed as a {@link SessionParams} object.\n */\n private async putSession(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`PUT /session`, req.body)\n try {\n const config = req.body as Config\n const id = this.stats.consumeSessionId(config.tabsPerSession)\n await this.startLocalSession(id, req.body)\n res.json({\n message: `Session created`,\n data: { id },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * PUT /sessions endpoint.\n *\n * Starts multiple {@link Session} instances as specified into the\n * `body.sessions` value.\n * The request body will be parsed as a {@link SessionParams} object.\n */\n private async putSessions(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`PUT /sessions`, req.body)\n try {\n const { sessions, tabsPerSession } = req.body as Config\n const sessionsIds = []\n for (let i = 0; i < sessions; i++) {\n const id = this.stats.consumeSessionId(tabsPerSession)\n await this.startLocalSession(id, req.body)\n sessionsIds.push(id)\n }\n res.json({\n message: `${sessions} sessions created`,\n data: { ids: sessionsIds },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * DELETE /session endpoint.\n *\n * Delete the {@link Session} instance identified by the `body.id` param.\n */\n private async deleteSession(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`DELETE /session`, req.body)\n try {\n const { id } = req.body\n await this.stopLocalSession(id)\n res.json({\n message: `Session deleted`,\n data: { id },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * DELETE /sessions endpoint.\n *\n * Delete the {@link Session} instances specified by the `body.ids` array.\n */\n private async deleteSessions(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`DELETE /sessions`, req.body)\n try {\n const { ids } = req.body\n for (const id of ids) {\n await this.stopLocalSession(id)\n }\n res.json({\n message: `${ids.length} sessions deleted`,\n data: { ids },\n })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /view/page.log endpoint.\n *\n * Returns the page log file content as specified in {@link Config} `pageLogPath`.\n */\n private getPageLog(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /view/page.log`, req.query)\n if (!this.pageLogPath) {\n return next(new Error('pageLogPath not set'))\n }\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(path.resolve(this.pageLogPath), { dotfiles: 'allow' })\n }\n\n /**\n * GET /view/docker.log endpoint.\n *\n * Returns the Docker logs related to the container running the tool.\n * It requires to run the Docker container with the following options:\n * ```\n --cidfile /tmp/docker.id\n -v /tmp/docker.id:/root/.webrtcperf/docker.id:ro\n -v /var/lib/docker:/var/lib/docker:ro\n * ```\n */\n private async getDockerLog(req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> {\n log.debug(`GET /view/docker.log`, req.query)\n try {\n const logPath = await getDockerLogsPath()\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(path.resolve(logPath), { dotfiles: 'allow' })\n } catch (err) {\n next(err)\n }\n }\n\n /**\n * GET /download/alert-rules endpoint.\n *\n * Downloads the alert rules report stored into the {@link Stats.alertRulesOutput}.\n */\n private getAlertRules(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /download/alert-rules`, req.query)\n if (!this.stats.alertRulesOutput) {\n return next(new Error('Stats alertRulesOutput not set'))\n }\n res.download(this.stats.alertRulesOutput)\n }\n\n /**\n * GET /empty-page endpoint.\n *\n * Returns an empty HTML page. Useful for running tests with raw Javascript\n * content without any DOM rendering.\n */\n private getEmptyPage(req: express.Request, res: express.Response): void {\n log.debug(`GET /empty-page`, req.query)\n const title = req.query.title || 'EmptyPage'\n res.send(`<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>${title}</title>\n</head>\n<body></body>\n</html>`)\n }\n\n /**\n * GET /data/* endpoint.\n *\n * Returns the file content relative to the {@link Config} `serverData` path.\n * If the requested path points to a directory, it returns the directory\n * content in tar.gz format.\n */\n private getData(req: express.Request, res: express.Response, next: express.NextFunction): void {\n const requestPath = req.params.filepath as string | string[]\n const filepath = Array.isArray(requestPath) ? requestPath.join('/') : requestPath\n const paramPath = path.normalize(filepath).replace(/^(\\.\\.(\\/|\\\\|$))+/, '')\n log.debug(`GET /data/${paramPath}`, req.query)\n const fpath = path.resolve(this.serverData, paramPath)\n if (!fs.existsSync(fpath)) {\n return next(new Error(`${paramPath} not found`))\n }\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n if (['.js', '.mjs', '.cjs'].includes(path.extname(fpath).toLowerCase())) {\n res.type('application/javascript')\n }\n res.sendFile(fpath, { dotfiles: 'allow' })\n }\n\n private getDataArchive(req: express.Request, res: express.Response, next: express.NextFunction): void {\n log.debug(`GET /data`, req.query)\n const fpath = path.resolve(this.serverData)\n if (!fs.lstatSync(fpath).isDirectory()) {\n return next(new Error(`${fpath} is not a directory`))\n }\n res.header('Content-Disposition', `attachment; filename=\"${path.basename(fpath)}.tar.gz\"`)\n res.setHeader('content-type', 'application/gzip')\n tar.pack(fpath).pipe(zlib.createGzip()).pipe(res)\n }\n\n private getCache(req: express.Request, res: express.Response, next: express.NextFunction): void {\n const paramPath = path.normalize(req.params.path).replace(/^(\\.\\.(\\/|\\\\|$))+/, '')\n log.debug(`GET /cache/${paramPath}`, req.query)\n const fpath = path.resolve(this.videoCachePath, paramPath)\n if (!fs.existsSync(fpath)) {\n return next(new Error(`${paramPath} not found`))\n }\n if (req.query.range && !req.headers.range) {\n req.headers.range = `bytes=${req.query.range}`\n }\n res.sendFile(fpath, { dotfiles: 'allow' })\n }\n\n /**\n * Starts a new {@link Session} instance.\n * @param id The session unique id.\n * @param config The session configuration.\n */\n private async startLocalSession(id: number, config: SessionParams): Promise<Session> {\n const configs = await loadConfig(undefined, config)\n const sessionConfig = configs[0]\n const throttleIndex = getSessionThrottleIndex(id)\n const spawnPeriod = 1000 / sessionConfig.spawnRate\n\n // Prepare fake video and audio.\n const mediaPaths: MediaPath[] = []\n if (sessionConfig.videoPath) {\n for (const videoPath of sessionConfig.videoPath.split(',')) {\n const ret = await prepareFakeMedia({ ...sessionConfig, videoPath })\n mediaPaths.push(ret)\n }\n }\n const mediaPath = mediaPaths.length ? mediaPaths[id % mediaPaths.length] : undefined\n\n const session = new Session({ ...sessionConfig, throttleIndex, spawnPeriod, mediaPath, id })\n session.once('stop', () => {\n console.warn(`Session ${id} stopped, reloading...`)\n setTimeout(this.startLocalSession.bind(this), spawnPeriod, id, config)\n })\n this.stats.addSession(session)\n try {\n await session.start()\n } catch (err) {\n this.stats.removeSession(session.id)\n throw err\n }\n return session\n }\n\n /**\n * Stops a new {@link Session} instance.\n * @param {number} id The session unique id.\n */\n private async stopLocalSession(id: number): Promise<void> {\n const session = this.stats.sessions.get(id)\n if (!session) {\n log.warn(`stopLocalSession session ${id} not found`)\n return\n }\n session.removeAllListeners()\n this.stats.removeSession(id)\n await session.stop()\n }\n\n /**\n * Starts the {@link Server} instance.\n */\n async start(): Promise<void> {\n log.debug('start')\n if (this.serverUseHttps) {\n const destDir = path.join(os.homedir(), '.webrtcperf/ssl')\n const keyPath = path.join(destDir, 'domain.key')\n const crtPath = path.join(destDir, 'domain.crt')\n if (!fs.existsSync(keyPath) || !fs.existsSync(crtPath)) {\n await runShellCommand(\n `mkdir -p ${destDir} && openssl req -newkey rsa:2048 -nodes -keyout ${keyPath} -x509 -days 365 -out ${crtPath} -subj \"/C=EU/ST=London/L=London/O=Global Security/OU=IT Department/CN=example.com\"`,\n )\n }\n this.server = _createServer(\n {\n key: fs.readFileSync(keyPath),\n cert: fs.readFileSync(crtPath),\n },\n this.app,\n )\n } else {\n this.server = createServer(this.app)\n }\n\n // WebSocket endpoint.\n const wss = new WebSocketServer({ noServer: true })\n wss.on('connection', (ws, request) => {\n try {\n const query = new URLSearchParams(request.url?.split('?')[1] || '')\n const action = query.get('action') || ''\n log.debug(`ws connection from ${request.socket.remoteAddress} action: ${action}`)\n switch (action) {\n case 'write-stream': {\n if (!this.serverData) {\n throw new Error('serverData option not set')\n }\n const filename = query.get('filename') || ''\n if (!filename) {\n throw new Error('filename not set')\n }\n const paramPath = path.normalize(filename).replace(/^(\\.\\.(\\/|\\\\|$))+/, '')\n\n log.debug(`ws write-stream ${paramPath}`)\n const fpath = path.resolve(this.serverData, paramPath)\n if (fs.existsSync(fpath)) {\n throw new Error(`file already exists: ${fpath}`)\n }\n const stream = fs.createWriteStream(fpath)\n\n let headerWritten = false\n let framesWritten = 0\n\n const close = async () => {\n stream.close()\n ws.close()\n\n try {\n if (!framesWritten) {\n await fs.promises.unlink(fpath)\n }\n } catch (err) {\n log.error(`ws write-stream close error: ${(err as Error).message}`)\n }\n }\n\n stream.on('error', (err: Error) => {\n log.error(`ws write-stream error: ${err.message}`)\n void close()\n })\n\n ws.on('error', (err: Error) => {\n log.error(`ws write-stream error: ${err.message}`)\n void close()\n })\n\n ws.on('close', () => {\n log.debug(`ws write-stream close`)\n void close()\n })\n\n ws.on('message', (data: Uint8Array) => {\n if (!data?.byteLength) return\n if (!headerWritten) {\n stream.write(data)\n headerWritten = true\n return\n }\n stream.write(data)\n framesWritten++\n })\n\n break\n }\n default:\n throw new Error(`invalid action: ${action}`)\n }\n } catch (err) {\n log.error(`ws connection error: ${(err as Error).message}`)\n ws.close()\n }\n })\n this.wss = wss\n\n this.server.on('upgrade', (request, socket, head) => {\n log.debug(`ws upgrade ${request.url}`)\n try {\n const query = new URLSearchParams(request.url?.split('?')[1] || '')\n const auth = query.get('auth')\n if (!auth || !timingSafeEqual(Buffer.from(auth), Buffer.from(this.serverSecret))) {\n throw new Error('invalid auth')\n }\n } catch (err) {\n log.error(`ws upgrade error: ${(err as Error).message}`)\n socket.write('HTTP/1.1 401 Unauthorized\\r\\n\\r\\n')\n socket.destroy()\n return\n }\n\n wss.handleUpgrade(request, socket, head, ws => {\n wss.emit('connection', ws, request)\n })\n })\n\n this.server.listen(this.serverPort, () => {\n log.debug(`HTTPS server listening on port ${this.serverPort}`)\n })\n }\n\n /**\n * Stops the {@link Server} instance.\n */\n stop(): void {\n if (this.wss) {\n this.wss.close()\n this.wss = null\n }\n if (this.server) {\n log.debug('stop')\n this.server.close()\n this.server = null\n }\n }\n}\n"]}
@@ -449,7 +449,8 @@ class Session extends events_1.default {
449
449
  '--window-size',
450
450
  ];
451
451
  log.debug(`[session ${this.id}] Using args:\n ${args.join('\n ')}`);
452
- log.debug(`[session ${this.id}] Default args:\n ${puppeteer_core_1.default.defaultArgs().join('\n ')}`);
452
+ const defaultArgs = await puppeteer_core_1.default.defaultArgs();
453
+ log.debug(`[session ${this.id}] Default args:\n ${defaultArgs.join('\n ')}`);
453
454
  try {
454
455
  this.browser = await puppeteer_core_1.default.launch({
455
456
  browser: 'chrome',
@@ -1292,10 +1293,10 @@ mv ${logFilePath}.tmp ${logFilePath};
1292
1293
  collectedStats.usedCpu = systemStats.usedCpu;
1293
1294
  collectedStats.usedMemory = systemStats.usedMemory;
1294
1295
  collectedStats.usedGpu = systemStats.usedGpu;
1295
- if (collectedStats.usedCpu > 80) {
1296
+ if (collectedStats.usedCpu > 90) {
1296
1297
  log.warn(`High system CPU usage: ${collectedStats.usedCpu.toFixed(2)}%`);
1297
1298
  }
1298
- if (collectedStats.usedMemory > 80) {
1299
+ if (collectedStats.usedMemory > 90) {
1299
1300
  log.warn(`High system memory usage: ${collectedStats.usedMemory.toFixed(2)}%`);
1300
1301
  }
1301
1302
  }