Compare commits
1
Commits
04c7348e7a
...
3c59c3e927
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c59c3e927 |
No files matched your search
@@ -1,4 +1,4 @@
|
||||
name: Build Docker Image for Pull Request
|
||||
name: Build Docker Images for Pull Request
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@@ -25,3 +25,13 @@ jobs:
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
|
||||
- name: Build monolith Docker image
|
||||
uses: docker/build-push-action@v6.13.0
|
||||
with:
|
||||
context: .
|
||||
tags: ${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ github.event.repository.name }}-monolith:latest
|
||||
file: ./Monolith.Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
REGISTRY_URL: gitea.kobim.cloud
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository actions
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Docker Environment
|
||||
uses: ./.github/actions/setup-docker-environment
|
||||
|
||||
- name: Log in to Docker registry
|
||||
uses: docker/login-action@v3.3.0
|
||||
with:
|
||||
registry: ${{ env.REGISTRY_URL }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6.13.0
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ env.REGISTRY_URL }}/${{ github.repository_owner }}/${{ github.event.repository.name }}-monolith:latest
|
||||
file: ./Monolith.Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
@@ -297,3 +297,10 @@ __pycache__/
|
||||
test/
|
||||
venv/
|
||||
.venv/
|
||||
|
||||
# Node.js
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
yarn-debug.log*
|
||||
background.bundle.js
|
||||
+4
-8
@@ -1,19 +1,15 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
# Install Python
|
||||
RUN apt-get update && apt-get install -y python3 python3-pip python3-venv
|
||||
# Install Python and curl
|
||||
RUN apt-get update && apt-get install -y python3 python3-pip python3-venv curl
|
||||
|
||||
# Install dependencies with venv
|
||||
# Create and activate a virtual environment
|
||||
RUN python3 -m venv /app/venv
|
||||
ENV PATH="/app/venv/bin:$PATH"
|
||||
|
||||
# Install dependencies with venv
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN /app/venv/bin/pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
# Install curl
|
||||
RUN apt-get update && apt-get install -y curl
|
||||
RUN /app/venv/bin/pip install -r /app/requirements.txt
|
||||
|
||||
# Copy the application
|
||||
COPY main.py /app
|
||||
@@ -24,4 +20,4 @@ WORKDIR /app
|
||||
CMD ["/app/venv/bin/python", "main.py"]
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD curl -f http://localhost/healthcheck || exit 1
|
||||
HEALTHCHECK --interval=5s --timeout=10s --retries=5 --start-period=5s CMD curl -f http://localhost:9092/heartbeat || exit 1
|
||||
@@ -0,0 +1,52 @@
|
||||
FROM node:22.14.0-bookworm-slim AS build
|
||||
|
||||
# Copy the webrtc-internals-exporter files
|
||||
COPY webrtc-internals-exporter /tmp/webrtc-internals-exporter
|
||||
|
||||
WORKDIR /tmp/webrtc-internals-exporter/webpack
|
||||
|
||||
# Install dependencies
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm install
|
||||
|
||||
# Build the project
|
||||
RUN npm run build
|
||||
|
||||
FROM selenium/standalone-chromium:129.0
|
||||
|
||||
# Install Python-virtualenv
|
||||
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
|
||||
sudo apt-get update && sudo sudo apt-get install -y python3-venv
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
# Install Telegraf
|
||||
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
|
||||
wget -q https://repos.influxdata.com/influxdata-archive_compat.key && \
|
||||
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && \
|
||||
cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null && \
|
||||
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list && \
|
||||
sudo apt-get update && sudo apt-get install -y telegraf
|
||||
|
||||
# Create and activate a virtual environment
|
||||
RUN python3 -m venv ./venv
|
||||
ENV PATH="/tmp/venv/bin:$PATH"
|
||||
|
||||
# Install dependencies with venv
|
||||
COPY requirements.txt ./requirements.txt
|
||||
RUN ./venv/bin/pip install -r ./requirements.txt
|
||||
|
||||
# Copy the application
|
||||
COPY main.py .
|
||||
COPY utils/ ./utils
|
||||
COPY telegraf.conf ./telegraf.conf
|
||||
COPY webrtc-internals-exporter /tmp/webrtc-internals-exporter
|
||||
COPY --from=build /tmp/webrtc-internals-exporter/background.bundle.js /tmp/webrtc-internals-exporter/background.bundle.js
|
||||
COPY --chown="${SEL_UID}:${SEL_GID}" monolith-entrypoint.sh /opt/bin/collector.sh
|
||||
|
||||
# Run the entrypoint
|
||||
RUN chmod +x /opt/bin/collector.sh
|
||||
ENTRYPOINT ["/opt/bin/collector.sh"]
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=5s --timeout=10s --retries=5 --start-period=5s CMD curl -f http://localhost:9092/heartbeat || exit 1
|
||||
+32
-6
@@ -3,7 +3,7 @@ services:
|
||||
container_name: selenium-standalone-chromium
|
||||
image: selenium/standalone-chromium:129.0
|
||||
volumes:
|
||||
- ./webrtc-internals-exporter:/tmp/webrtc-internals-exporter:ro
|
||||
- build-extension:/tmp/webrtc-internals-exporter
|
||||
shm_size: "2g"
|
||||
attach: false
|
||||
depends_on:
|
||||
@@ -15,7 +15,10 @@ services:
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
pull_policy: always
|
||||
network_mode: host
|
||||
ports:
|
||||
- "7900:7900"
|
||||
networks:
|
||||
- backend
|
||||
|
||||
telegraf:
|
||||
container_name: telegraf
|
||||
@@ -34,6 +37,25 @@ services:
|
||||
pull_policy: always
|
||||
networks:
|
||||
- backend
|
||||
build-extension:
|
||||
container_name: build-extension
|
||||
image: node:22.14.0-bookworm-slim
|
||||
volumes:
|
||||
- ./webrtc-internals-exporter:/tmp/webrtc-internals-exporter:ro
|
||||
- build-extension:/tmp/webrtc-internals-exporter-build
|
||||
working_dir: /tmp/webrtc-internals-exporter-build/webpack
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
cp -r /tmp/webrtc-internals-exporter/* /tmp/webrtc-internals-exporter-build
|
||||
npm install
|
||||
npm run build
|
||||
environment:
|
||||
- WEBRTC_INTERNALS_EXPORTER_URL=http://collector
|
||||
pull_policy: always
|
||||
networks:
|
||||
- backend
|
||||
|
||||
collector:
|
||||
container_name: collector
|
||||
@@ -46,12 +68,13 @@ services:
|
||||
condition: service_healthy
|
||||
telegraf:
|
||||
condition: service_healthy
|
||||
build-extension:
|
||||
condition: service_completed_successfully
|
||||
environment:
|
||||
- VIDEO_URL=${VIDEO_URL:?"Video URL is required"}
|
||||
ports:
|
||||
- "9092:9092"
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
- SOCKET_URL=telegraf
|
||||
- HUB_URL=http://selenium:4444
|
||||
- WEBRTC_INTERNALS_PATH=/tmp/webrtc-internals-exporter
|
||||
pull_policy: always
|
||||
networks:
|
||||
- backend
|
||||
@@ -61,3 +84,6 @@ networks:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.100.0.0/16
|
||||
|
||||
volumes:
|
||||
build-extension:
|
||||
@@ -4,11 +4,13 @@ import time
|
||||
import socket
|
||||
import logging
|
||||
import os
|
||||
import argparse
|
||||
from yaspin import yaspin
|
||||
from functools import partial
|
||||
from http.server import HTTPServer
|
||||
from utils.PostHandler import Handler
|
||||
from utils.ColoredFormatter import ColoredFormatter
|
||||
from utils.Convenience import *
|
||||
from bs4 import BeautifulSoup as bs
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
@@ -18,10 +20,11 @@ from selenium.webdriver.support.wait import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as ec
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
args = None
|
||||
|
||||
def setupLogger():
|
||||
logging_format = "[%(asctime)s] (%(levelname)s) %(module)s - %(funcName)s: %(message)s"
|
||||
logging.basicConfig(level=logging.INFO, format=logging_format)
|
||||
logging.basicConfig(level=firstValid(args.log_level, os.getenv('LOG_LEVEL'), default='INFO'), format=logging_format) # type: ignore
|
||||
(logger := logging.getLogger(__name__)).setLevel(logging.INFO)
|
||||
logger.propagate = False
|
||||
(logger_handler := logging.StreamHandler()).setFormatter(
|
||||
@@ -29,6 +32,18 @@ def setupLogger():
|
||||
)
|
||||
logger.addHandler(logger_handler)
|
||||
|
||||
|
||||
def setupArgParser():
|
||||
parser = argparse.ArgumentParser(description='Collector for PeerTube stats.')
|
||||
parser.add_argument('-u', '--url', type=str, help='URL of the video to collect stats for.')
|
||||
parser.add_argument('--socket-url', type=str, help='URL of the socket to send the stats to. Default: localhost')
|
||||
parser.add_argument('--socket-port', type=int, help='Port of the socket to send the stats to. Default: 8094')
|
||||
parser.add_argument('--hub-url', type=str, help='URL of the Selenium hub to connect to. If not provided, local Chrome driver will be used.')
|
||||
parser.add_argument('--webrtc-internals-path', type=str, help='Path to the WebRTC internals extension.')
|
||||
parser.add_argument('--log-level', type=str, help='Log level to use. Default: INFO')
|
||||
|
||||
return parser
|
||||
|
||||
def interrupt_handler(signum, driver: webdriver.Remote):
|
||||
logger.info(f'Handling signal {signum} ({signal.Signals(signum).name}).')
|
||||
|
||||
@@ -36,37 +51,40 @@ def interrupt_handler(signum, driver: webdriver.Remote):
|
||||
raise SystemExit
|
||||
|
||||
@yaspin()
|
||||
def setupChromeDriver():
|
||||
def setupChromeDriver(command_executor: str | None, webrtc_internals_path: str) -> webdriver.Remote | webdriver.Chrome:
|
||||
logger.log(logging.INFO, 'Setting up Chrome driver.')
|
||||
chrome_options = Options()
|
||||
#chrome_options.add_argument("--headless")
|
||||
chrome_options.add_argument("--no-sandbox")
|
||||
chrome_options.add_argument("--mute-audio")
|
||||
chrome_options.add_argument("--window-size=1280,720")
|
||||
#chrome_options.add_argument("--disable-dev-shm-usage")
|
||||
chrome_options.add_argument("--no-default-browser-check")
|
||||
chrome_options.add_argument("--disable-features=WebRtcHideLocalIpsWithMdns")
|
||||
#chrome_options.add_argument(f"--load-extension={os.path.abspath(os.path.join(os.path.dirname(__file__), 'webrtc-internals-exporter'))}")
|
||||
chrome_options.add_argument("--load-extension=/tmp/webrtc-internals-exporter")
|
||||
chrome_options.add_argument(f"--load-extension={webrtc_internals_path}")
|
||||
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
|
||||
|
||||
#driver = webdriver.Chrome(options=chrome_options)
|
||||
driver = webdriver.Remote(command_executor='http://host.docker.internal:4444', options=chrome_options)
|
||||
if command_executor is not None:
|
||||
driver = webdriver.Remote(command_executor=command_executor, options=chrome_options)
|
||||
logger.warning(f'Using Selenium hub at {command_executor}.')
|
||||
else:
|
||||
driver = webdriver.Chrome(options=chrome_options)
|
||||
logger.warning('No Selenium hub URL provided, using local Chrome driver.')
|
||||
|
||||
logger.log(logging.INFO, 'Chrome driver setup complete.')
|
||||
|
||||
return driver
|
||||
|
||||
def saveStats(stats: list):
|
||||
def saveStats(stats: list, socket_url: str, socket_port: int):
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
logger.log(logging.DEBUG, f'Saving stats: {json.dumps(stats, indent=4)}')
|
||||
sock.sendto(json.dumps(stats).encode(), ('telegraf', 8094))
|
||||
sock.sendto(json.dumps(stats).encode(), (socket_url, socket_port))
|
||||
sock.close()
|
||||
logger.log(logging.DEBUG, 'Sent stats to socket.')
|
||||
except socket.error as e:
|
||||
logger.error(f'Got socket error: {e}')
|
||||
|
||||
def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
||||
def downloadStats(driver: webdriver.Remote | webdriver.Chrome, peersDict: dict, socket_url: str, socket_port: int):
|
||||
html = driver.find_element(By.CLASS_NAME ,'vjs-stats-list').get_attribute('innerHTML')
|
||||
if html is not None:
|
||||
htmlBS = bs(html, 'html.parser')
|
||||
@@ -157,7 +175,7 @@ def downloadStats(driver: webdriver.Chrome, peersDict: dict):
|
||||
'session': driver.session_id
|
||||
}
|
||||
|
||||
saveStats([stats])
|
||||
saveStats([stats], socket_url, socket_port)
|
||||
|
||||
def convert_to_bytes(down, downUnit):
|
||||
return float(down) * (1024 ** {'B': 0, 'KB': 1, 'MB': 2, 'GB': 3}[downUnit])
|
||||
@@ -189,19 +207,30 @@ def setupStats(driver: webdriver.Remote, url: str):
|
||||
return driver
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = setupArgParser().parse_args()
|
||||
|
||||
setupLogger()
|
||||
|
||||
driver = setupChromeDriver()
|
||||
command_executor = firstValid(args.hub_url, os.getenv('HUB_URL'), default=None)
|
||||
webrtc_internals_path = firstValid(
|
||||
args.webrtc_internals_path,
|
||||
os.getenv('WEBRTC_INTERNALS_PATH'),
|
||||
default=os.path.abspath(os.path.join(os.path.dirname(__file__), 'webrtc-internals-exporter'))
|
||||
)
|
||||
|
||||
driver = setupChromeDriver(command_executor, webrtc_internals_path)
|
||||
|
||||
signal.signal(signal.SIGINT, lambda signum, frame: interrupt_handler(signum, driver))
|
||||
|
||||
url = os.getenv('VIDEO_URL')
|
||||
url = firstValid(args.url, os.getenv('VIDEO_URL'), default=None)
|
||||
if url is None:
|
||||
logger.error('VIDEO_URL environment variable is not set.')
|
||||
logger.error('VIDEO_URL environment variable or --url argument is required.')
|
||||
raise SystemExit(1)
|
||||
|
||||
setupStats(driver, url)
|
||||
|
||||
socket_url = firstValid(args.socket_url, os.getenv('SOCKET_URL'), default='localhost')
|
||||
socket_port = firstValid(args.socket_port, os.getenv('SOCKET_PORT'), default=8094)
|
||||
logger.info('Starting server collector.')
|
||||
httpd = HTTPServer(('', 9092), partial(Handler, downloadStats, driver, logger))
|
||||
httpd = HTTPServer(('', 9092), partial(Handler, downloadStats, driver, logger, socket_url, socket_port))
|
||||
httpd.serve_forever()
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$TELEGRAF_HOSTNAME" ]; then
|
||||
echo "Error: TELEGRAF_HOSTNAME is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$TELEGRAF_MONGODB_DSN" ]; then
|
||||
echo "Error: TELEGRAF_MONGODB_DSN is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$TELEGRAF_MONGODB_DATABASE" ]; then
|
||||
echo "Error: TELEGRAF_MONGODB_DATABASE is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$VIDEO_URL" ]; then
|
||||
echo "Error: VIDEO_URL is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set the environment variables
|
||||
export DSN=$TELEGRAF_MONGODB_DSN
|
||||
export DATABASE=$TELEGRAF_MONGODB_DATABASE
|
||||
export HOSTNAME=$TELEGRAF_HOSTNAME
|
||||
|
||||
# Start the Selenium hub
|
||||
/opt/bin/entry_point.sh > /dev/null 2>&1 &
|
||||
|
||||
# Wait for Selenium hub to be ready
|
||||
printf 'Waiting for Selenium standalone to be ready'
|
||||
timeout=30
|
||||
while ! curl -sSL "http://localhost:4444/wd/hub/status" 2>/dev/null | jq -e '.value.ready' | grep -q true; do
|
||||
printf '.'
|
||||
sleep 1
|
||||
((timeout--))
|
||||
if [ $timeout -le 0 ]; then
|
||||
echo "Error: Selenium standalone did not become ready in time. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
printf '\n'
|
||||
|
||||
# Start the Telegraf agent and the main script
|
||||
telegraf --config ./telegraf.conf &
|
||||
./venv/bin/python main.py
|
||||
@@ -0,0 +1,5 @@
|
||||
def firstValid(*args, default):
|
||||
for arg in args:
|
||||
if arg is not None:
|
||||
return arg
|
||||
return default
|
||||
@@ -3,10 +3,12 @@ import logging
|
||||
from http.server import BaseHTTPRequestHandler
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def __init__(self, custom_func, driver, logger, *args, **kwargs):
|
||||
def __init__(self, custom_func, driver, logger, socket_url, socket_port, *args, **kwargs):
|
||||
self._custom_func = custom_func
|
||||
self.logger = logger
|
||||
self.driver = driver
|
||||
self._socket_url = socket_url
|
||||
self._socket_port = socket_port
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def do_POST(self):
|
||||
@@ -14,7 +16,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
content_length = int(self.headers['Content-Length'])
|
||||
post_data = self.rfile.read(content_length)
|
||||
self.logger.log(logging.DEBUG, f"POST request,\nPath: {self.path}\nHeaders:\n{self.headers}\n\nBody:\n{post_data.decode('utf-8')}")
|
||||
self._custom_func(self.driver, json.loads(post_data.decode('utf-8')))
|
||||
self._custom_func(self.driver, json.loads(post_data.decode('utf-8')), self._socket_url, self._socket_port)
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
self.wfile.write(b'POST request received')
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
(()=>{var t={751:function(t,e){!function(t){"use strict";function e(t){let e=t.length;for(;--e>=0;)t[e]=0}const a=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),n=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),i=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),s=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r=new Array(576);e(r);const o=new Array(60);e(o);const l=new Array(512);e(l);const h=new Array(256);e(h);const d=new Array(29);e(d);const _=new Array(30);function c(t,e,a,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let u,f,w;function g(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}e(_);const m=t=>t<256?l[t]:l[256+(t>>>7)],b=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},p=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,b(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)},k=(t,e,a)=>{p(t,a[2*e],a[2*e+1])},v=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},y=(t,e,a)=>{const n=new Array(16);let i,s,r=0;for(i=1;i<=15;i++)r=r+a[i-1]<<1,n[i]=r;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=v(n[e]++,e))}},x=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},z=t=>{t.bi_valid>8?b(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},A=(t,e,a,n)=>{const i=2*e,s=2*a;return t[i]<t[s]||t[i]===t[s]&&n[e]<=n[a]},E=(t,e,a)=>{const n=t.heap[a];let i=a<<1;for(;i<=t.heap_len&&(i<t.heap_len&&A(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!A(e,n,t.heap[i],t.depth));)t.heap[a]=t.heap[i],a=i,i<<=1;t.heap[a]=n},R=(t,e,i)=>{let s,r,o,l,c=0;if(0!==t.sym_next)do{s=255&t.pending_buf[t.sym_buf+c++],s+=(255&t.pending_buf[t.sym_buf+c++])<<8,r=t.pending_buf[t.sym_buf+c++],0===s?k(t,r,e):(o=h[r],k(t,o+256+1,e),l=a[o],0!==l&&(r-=d[o],p(t,r,l)),s--,o=m(s),k(t,o,i),l=n[o],0!==l&&(s-=_[o],p(t,s,l)))}while(c<t.sym_next);k(t,256,e)},Z=(t,e)=>{const a=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let r,o,l,h=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<s;r++)0!==a[2*r]?(t.heap[++t.heap_len]=h=r,t.depth[r]=0):a[2*r+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=h<2?++h:0,a[2*l]=1,t.depth[l]=0,t.opt_len--,i&&(t.static_len-=n[2*l+1]);for(e.max_code=h,r=t.heap_len>>1;r>=1;r--)E(t,a,r);l=s;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],E(t,a,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,a[2*l]=a[2*r]+a[2*o],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,a[2*r+1]=a[2*o+1]=l,t.heap[1]=l++,E(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,d,_,c,u,f,w=0;for(c=0;c<=15;c++)t.bl_count[c]=0;for(a[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)d=t.heap[h],c=a[2*a[2*d+1]+1]+1,c>l&&(c=l,w++),a[2*d+1]=c,d>n||(t.bl_count[c]++,u=0,d>=o&&(u=r[d-o]),f=a[2*d],t.opt_len+=f*(c+u),s&&(t.static_len+=f*(i[2*d+1]+u)));if(0!==w){do{for(c=l-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[l]--,w-=2}while(w>0);for(c=l;0!==c;c--)for(d=t.bl_count[c];0!==d;)_=t.heap[--h],_>n||(a[2*_+1]!==c&&(t.opt_len+=(c-a[2*_+1])*a[2*_],a[2*_+1]=c),d--)}})(t,e),y(a,h,t.bl_count)},U=(t,e,a)=>{let n,i,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),e[2*(a+1)+1]=65535,n=0;n<=a;n++)i=r,r=e[2*(n+1)+1],++o<l&&i===r||(o<h?t.bl_tree[2*i]+=o:0!==i?(i!==s&&t.bl_tree[2*i]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,s=i,0===r?(l=138,h=3):i===r?(l=6,h=3):(l=7,h=4))},S=(t,e,a)=>{let n,i,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),n=0;n<=a;n++)if(i=r,r=e[2*(n+1)+1],!(++o<l&&i===r)){if(o<h)do{k(t,i,t.bl_tree)}while(0!=--o);else 0!==i?(i!==s&&(k(t,i,t.bl_tree),o--),k(t,16,t.bl_tree),p(t,o-3,2)):o<=10?(k(t,17,t.bl_tree),p(t,o-3,3)):(k(t,18,t.bl_tree),p(t,o-11,7));o=0,s=i,0===r?(l=138,h=3):i===r?(l=6,h=3):(l=7,h=4)}};let T=!1;const O=(t,e,a,n)=>{p(t,0+(n?1:0),3),z(t),b(t,a),b(t,~a),a&&t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a};var D={_tr_init:t=>{T||((()=>{let t,e,s,g,m;const b=new Array(16);for(s=0,g=0;g<28;g++)for(d[g]=s,t=0;t<1<<a[g];t++)h[s++]=g;for(h[s-1]=g,m=0,g=0;g<16;g++)for(_[g]=m,t=0;t<1<<n[g];t++)l[m++]=g;for(m>>=7;g<30;g++)for(_[g]=m<<7,t=0;t<1<<n[g]-7;t++)l[256+m++]=g;for(e=0;e<=15;e++)b[e]=0;for(t=0;t<=143;)r[2*t+1]=8,t++,b[8]++;for(;t<=255;)r[2*t+1]=9,t++,b[9]++;for(;t<=279;)r[2*t+1]=7,t++,b[7]++;for(;t<=287;)r[2*t+1]=8,t++,b[8]++;for(y(r,287,b),t=0;t<30;t++)o[2*t+1]=5,o[2*t]=v(t,5);u=new c(r,a,257,286,15),f=new c(o,n,0,30,15),w=new c(new Array(0),i,0,19,7)})(),T=!0),t.l_desc=new g(t.dyn_ltree,u),t.d_desc=new g(t.dyn_dtree,f),t.bl_desc=new g(t.bl_trLine truncated
|
||||
@@ -6,17 +6,17 @@ function log(...args) {
|
||||
|
||||
log("loaded");
|
||||
|
||||
import "/assets/pako.min.js";
|
||||
import "./assets/pako.min.js";
|
||||
|
||||
const DEFAULT_OPTIONS = {
|
||||
url: "http://localhost:9092",
|
||||
url: process.env.WEBRTC_INTERNALS_EXPORTER_URL + ":9092",
|
||||
username: "",
|
||||
password: "",
|
||||
updateInterval: 2,
|
||||
gzip: false,
|
||||
job: "webrtc-internals-exporter",
|
||||
enabledOrigins: { },
|
||||
enabledStats: ["data-channel", "local-candidate", "remote-candidate"]
|
||||
enabledOrigins: {},
|
||||
enabledStats: ["data-channel", "local-candidate", "remote-candidate", "candidate-pair"]
|
||||
};
|
||||
|
||||
const options = {};
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
],
|
||||
"background": {
|
||||
"service_worker": "background.js",
|
||||
"service_worker": "background.bundle.js",
|
||||
"type": "module"
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
shouldPrintComment: () => false
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
const { execSync } = require('child_process');
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
let url = '';
|
||||
|
||||
args.forEach((arg, index) => {
|
||||
if (arg === '-u' || arg === '--url') {
|
||||
url = args[index + 1];
|
||||
} else if (arg === '-h' || arg === '--help') {
|
||||
console.log('Usage: npm run build -- [-u|--url <url>]');
|
||||
console.log('Options:');
|
||||
console.log(' -u, --url <url> URL to use for the extension collector server');
|
||||
console.log(' -h, --help Display this help message');
|
||||
process.exit(0);
|
||||
} else if (arg.startsWith('-')) {
|
||||
console.error(`Unrecognized argument: ${arg}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
if (url) {
|
||||
console.log(`Building with URL: ${url}`);
|
||||
execSync(`webpack --env URL=${url}`, { stdio: 'inherit' });
|
||||
} else {
|
||||
execSync('webpack', { stdio: 'inherit' });
|
||||
}
|
||||
+9355
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "webrtc-internals-exporter",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "node build.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Mirko Milovanovic",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"babel-loader": "^8.2.2",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"copy-webpack-plugin": "^12.0.2",
|
||||
"file-loader": "^6.2.0",
|
||||
"html-webpack-plugin": "^5.3.1",
|
||||
"mini-css-extract-plugin": "^1.6.0",
|
||||
"postcss": "^8.2.14",
|
||||
"postcss-loader": "^5.2.0",
|
||||
"postcss-preset-env": "^10.1.4",
|
||||
"sass": "^1.32.12",
|
||||
"sass-loader": "^11.0.1",
|
||||
"serve": "^14.2.4",
|
||||
"style-loader": "^2.0.0",
|
||||
"terser-webpack-plugin": "^5.1.1",
|
||||
"ts-loader": "^9.1.2",
|
||||
"typescript": "^4.2.4",
|
||||
"webpack": "^5.38.1",
|
||||
"webpack-cli": "^4.7.2",
|
||||
"webpack-dev-server": "^5.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
const path = require('path');
|
||||
const { EnvironmentPlugin } = require('webpack');
|
||||
|
||||
module.exports = (env) => {
|
||||
const url = env.URL || 'http://localhost';
|
||||
|
||||
return {
|
||||
entry: '../background.js',
|
||||
target: 'web',
|
||||
mode: 'production',
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js?$/,
|
||||
use: 'babel-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: { extensions: ['.tsx', '.ts', '.js'] },
|
||||
output: {
|
||||
filename: 'background.bundle.js',
|
||||
path: path.resolve(__dirname, '../'),
|
||||
publicPath: '',
|
||||
},
|
||||
plugins: [
|
||||
new EnvironmentPlugin({
|
||||
WEBRTC_INTERNALS_EXPORTER_URL: url,
|
||||
}),
|
||||
],
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user