texas2step 2.4.2__tar.gz → 2.4.3__tar.gz

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.
Files changed (66) hide show
  1. {texas2step-2.4.2 → texas2step-2.4.3}/PKG-INFO +1 -1
  2. {texas2step-2.4.2 → texas2step-2.4.3}/docs/configuration.md +8 -4
  3. {texas2step-2.4.2 → texas2step-2.4.3}/docs/roadmap.md +7 -10
  4. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/__init__.py +1 -1
  5. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/api/measure.py +4 -1
  6. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/app.py +4 -2
  7. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/page.py +11 -0
  8. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/app.js +1 -1
  9. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/index.html +1 -1
  10. {texas2step-2.4.2 → texas2step-2.4.3}/.gitignore +0 -0
  11. {texas2step-2.4.2 → texas2step-2.4.3}/LICENSE.md +0 -0
  12. {texas2step-2.4.2 → texas2step-2.4.3}/README.md +0 -0
  13. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/nginx/texas2step-http.conf +0 -0
  14. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/nginx/texas2step-log.conf +0 -0
  15. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/nginx/texas2step-speedtest.conf +0 -0
  16. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/nginx/texas2step.conf +0 -0
  17. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/texas2step-update.service +0 -0
  18. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/texas2step-update.timer +0 -0
  19. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/texas2step.default +0 -0
  20. {texas2step-2.4.2 → texas2step-2.4.3}/deploy/texas2step.service +0 -0
  21. {texas2step-2.4.2 → texas2step-2.4.3}/docs/access.md +0 -0
  22. {texas2step-2.4.2 → texas2step-2.4.3}/docs/api.md +0 -0
  23. {texas2step-2.4.2 → texas2step-2.4.3}/docs/development.md +0 -0
  24. {texas2step-2.4.2 → texas2step-2.4.3}/docs/experience.md +0 -0
  25. {texas2step-2.4.2 → texas2step-2.4.3}/docs/images/hero-dark.jpg +0 -0
  26. {texas2step-2.4.2 → texas2step-2.4.3}/docs/images/results-dark.jpg +0 -0
  27. {texas2step-2.4.2 → texas2step-2.4.3}/docs/images/results-light.jpg +0 -0
  28. {texas2step-2.4.2 → texas2step-2.4.3}/docs/images/upload-light.jpg +0 -0
  29. {texas2step-2.4.2 → texas2step-2.4.3}/docs/install.md +0 -0
  30. {texas2step-2.4.2 → texas2step-2.4.3}/docs/methodology.md +0 -0
  31. {texas2step-2.4.2 → texas2step-2.4.3}/docs/security.md +0 -0
  32. {texas2step-2.4.2 → texas2step-2.4.3}/docs/traffic.md +0 -0
  33. {texas2step-2.4.2 → texas2step-2.4.3}/legacy/README.md +0 -0
  34. {texas2step-2.4.2 → texas2step-2.4.3}/pyproject.toml +0 -0
  35. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/__main__.py +0 -0
  36. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/access.py +0 -0
  37. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/api/__init__.py +0 -0
  38. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/api/access.py +0 -0
  39. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/api/meta.py +0 -0
  40. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/api/results.py +0 -0
  41. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/api/wire.py +0 -0
  42. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/cli.py +0 -0
  43. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/cluster.py +0 -0
  44. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/config.py +0 -0
  45. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/config_edit.py +0 -0
  46. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/config_merge.py +0 -0
  47. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/config_template.toml +0 -0
  48. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/engine.py +0 -0
  49. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/iface.py +0 -0
  50. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/lockouts.py +0 -0
  51. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/logs.py +0 -0
  52. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/payload.py +0 -0
  53. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/quality.py +0 -0
  54. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/rtc.py +0 -0
  55. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/app.css +0 -0
  56. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/swagger/LICENSE +0 -0
  57. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/swagger/NOTICE +0 -0
  58. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/swagger/swagger-ui-bundle.js +0 -0
  59. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/swagger/swagger-ui-bundle.js.LICENSE.txt +0 -0
  60. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/assets/swagger/swagger-ui.css +0 -0
  61. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/static/favicon.svg +0 -0
  62. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/stats.py +0 -0
  63. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/store.py +0 -0
  64. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/traffic.py +0 -0
  65. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/update.py +0 -0
  66. {texas2step-2.4.2 → texas2step-2.4.3}/src/texas2step/words.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: texas2step
3
- Version: 2.4.2
3
+ Version: 2.4.3
4
4
  Summary: Web-centric throughput, latency, jitter and packet-loss measurement between endpoints.
5
5
  Project-URL: Homepage, https://github.com/robert-patrick-texas/texas2step
6
6
  Project-URL: Documentation, https://robert-patrick-texas.github.io/texas2step/
@@ -167,11 +167,15 @@ url = "https://www.acme.example/accessibility"
167
167
  paragraph. The text is plain, but `[label](url)` makes a link of the label, by the same
168
168
  rules as the other links below. A URL ends at the first `)`. HTML isn't allowed, so it
169
169
  shows as typed. In TOML, `"""` lets the text run over several lines. The API explorer
170
- (`/api/docs`) is a separate page and has no footer of yours.
170
+ (`/api/docs`) is a separate page and has no footer of yours; it takes the name, as
171
+ "NetCheck API", and the logo as its icon.
171
172
  * **Logo.** SVG, PNG, JPEG, WebP or GIF, about 30 px tall on screen; wide logos keep their
172
- shape, up to 180 px wide. The `texas2step` service user must be able to read the file
173
- (`/etc/texas2step/` is a good place). If the file is missing or unreadable, the server
174
- logs a warning and keeps the star.
173
+ shape, up to 180 px wide. It is the browser tab's icon too, which browsers draw in a
174
+ small square, where a square logo works best. The `texas2step` service user must be
175
+ able to read the file (`/etc/texas2step/` is a good place). If the file is missing or
176
+ unreadable, the server logs a warning and keeps the star.
177
+ * **The command line.** The API tab's examples and History's hint name the `texas2step`
178
+ command, as it must be typed, on renamed sites too.
175
179
  * **Links** must start with `https://`, `http://`, `mailto:` or `tel:`, in
176
180
  `[[brand_links]]`, `[[brand_footer_links]]` and `brand_footer` alike. Anything else
177
181
  stops the server at startup with an error naming the setting. `[[brand_links]]` and
@@ -51,16 +51,6 @@ is. Call quality, responsiveness, one stream and Monitor's call profiles came in
51
51
  name that shares its IP address and is covered by the same certificate, and a wildcard
52
52
  certificate makes that likely.
53
53
 
54
- ### Branding
55
-
56
- The [branding settings](configuration.md#branding-and-themes) replace the name, logo,
57
- links and footer credit. Three places still say texas2step:
58
-
59
- - [ ] **The browser tab's icon** is the texas2step star, even with `brand_logo` set. It
60
- could use that logo.
61
- - [ ] **The API explorer** (`/api/docs`) is titled "texas2step - Swagger UI".
62
- - [ ] **The API tab's command-line examples** name the `texas2step` CLI.
63
-
64
54
  ### Security
65
55
 
66
56
  - [ ] **DTLS 1.3 for the UDP probe.** The probe's data channel uses DTLS 1.2
@@ -122,6 +112,13 @@ links and footer credit. Three places still say texas2step:
122
112
 
123
113
  Newest first. Each release's notes have the details and its upgrade steps.
124
114
 
115
+ ### [2.4.3](https://github.com/robert-patrick-texas/texas2step/releases/tag/v2.4.3) (2026-10-26)
116
+
117
+ - [x] With `brand_logo` set, the logo is the browser tab's icon, in the API explorer too.
118
+ - [x] The API explorer takes `brand_name`, in its title and heading.
119
+ - [x] The API tab's command-line examples keep the `texas2step` command, which they need
120
+ to work, and install it from PyPI.
121
+
125
122
  ### [2.4.2](https://github.com/robert-patrick-texas/texas2step/releases/tag/v2.4.2) (2026-10-26)
126
123
 
127
124
  - [x] The journal files each line at its level, so `journalctl -u texas2step -p warning`
@@ -1,3 +1,3 @@
1
1
  """texas2step: web-centric throughput, latency, jitter and packet-loss measurement."""
2
2
 
3
- __version__ = "2.4.2"
3
+ __version__ = "2.4.3"
@@ -28,7 +28,10 @@ _slots = asyncio.Semaphore(2)
28
28
 
29
29
  class Target(BaseModel):
30
30
  model_config = ConfigDict(str_strip_whitespace=True)
31
- target: str = Field(description="Base URL of a texas2step server, e.g. https://peer.example")
31
+ target: str = Field(
32
+ description="Base URL of the server to measure toward, e.g. https://peer.example: "
33
+ "one in [[locations]], unless allow_any_target is set"
34
+ )
32
35
 
33
36
 
34
37
  class LatencyRequest(Target):
@@ -10,6 +10,7 @@ import logging
10
10
  import re
11
11
  from collections.abc import AsyncGenerator
12
12
  from contextlib import asynccontextmanager
13
+ from html import escape
13
14
  from pathlib import Path
14
15
  from typing import ClassVar
15
16
  from urllib.parse import urlsplit
@@ -512,6 +513,7 @@ def create_app(settings: Settings | None = None) -> FastAPI:
512
513
  # FastAPI would record the first prefix it sees in "servers" for good. Set it per
513
514
  # request instead, so "Try it out" targets the address the explorer was opened at.
514
515
  spec = {**app.openapi(), "servers": [{"url": request.scope.get("root_path", "") or "/"}]}
516
+ spec["info"] = {**spec["info"], "title": settings.brand_name} # the explorer's heading
515
517
  if not shows_version(request): # as the page has it: not for visitors who need a code
516
518
  spec["info"] = {**spec["info"], "version": ""}
517
519
  return JSONResponse(spec)
@@ -524,10 +526,10 @@ def create_app(settings: Settings | None = None) -> FastAPI:
524
526
  assets = f"{root}/assets/swagger"
525
527
  explorer = get_swagger_ui_html(
526
528
  openapi_url=root + "/api/openapi.json",
527
- title=f"{app.title} - Swagger UI",
529
+ title=escape(f"{settings.brand_name} API"), # FastAPI writes it in as it is
528
530
  swagger_js_url=f"{assets}/swagger-ui-bundle.js?v={stamps.get('swagger-ui-bundle.js')}",
529
531
  swagger_css_url=f"{assets}/swagger-ui.css?v={stamps.get('swagger-ui.css')}",
530
- swagger_favicon_url=f"{root}/favicon.svg",
532
+ swagger_favicon_url=f"{root}/{shell.icon}",
531
533
  )
532
534
  explorer.headers["Content-Security-Policy"] = content_policy(
533
535
  bytes(explorer.body).decode(), []
@@ -65,6 +65,12 @@ class Shell:
65
65
  def __init__(self, settings: Settings, logo: Path | None) -> None:
66
66
  self.settings = settings
67
67
  self.logo_version = hashlib.sha256(logo.read_bytes()).hexdigest()[:10] if logo else None
68
+ self.logo_type = LOGO_TYPES[logo.suffix.lower()] if logo else None
69
+
70
+ @property
71
+ def icon(self) -> str:
72
+ """The browser tab's icon, relative to the site: the logo, or texas2step's star."""
73
+ return f"brand/logo?v={self.logo_version}" if self.logo_version else "favicon.svg"
68
74
 
69
75
  def render(
70
76
  self, template: str, root_path: str, version: str, hide: frozenset[str] = frozenset()
@@ -106,6 +112,11 @@ class Shell:
106
112
  if self.logo_version:
107
113
  mark = f'<img class="brand-mark" src="brand/logo?v={self.logo_version}" alt="" />'
108
114
  page = _fill(page, "mark", mark)
115
+ page = page.replace(
116
+ '<link rel="icon" href="favicon.svg" type="image/svg+xml" />',
117
+ f'<link rel="icon" href="{self.icon}" type="{self.logo_type}" />',
118
+ 1,
119
+ )
109
120
  if s.brand_notice:
110
121
  notice = f'<div class="notice" role="note">{escape(s.brand_notice)}</div>'
111
122
  page = _fill(page, "notice", notice)
@@ -1,4 +1,4 @@
1
- var Ln="/api/v1",Ee=new URL(document.baseURI).pathname.replace(/\/+$/,"");function W(r){return Ee+r}function Pe(r){return r.startsWith(Ee)?r.slice(Ee.length)||"/":r}var pe="",ps="texas2step",Pn=`${ps}.pass.`,hs=null,us=null,$t=new Set;function We(r){pe=r,$t.clear()}function ms(r){hs=r}function fs(r){us=r}var Le=class extends Error{},N=class{constructor(e,t=null){this.family=t;this.base=(e||window.location.origin+Ee).replace(/\/+$/,"")}family;base;get own(){return this.base===`${window.location.origin}${Ee}`.replace(/\/+$/,"")}url(e,t={}){let s=new URL(this.base+Ln+e);for(let[n,i]of Object.entries(t))s.searchParams.set(n,String(i));return pe&&!this.own&&s.searchParams.set("pass",pe),s.href}wsUrl(e){return this.url(e).replace(/^http/,"ws")}wsProtocols(){return pe&&this.own?[ps,Pn+pe]:[]}headers(){return pe&&this.own?{Authorization:`Bearer ${pe}`}:{}}init(e={}){let t=this.headers();if(!Object.keys(t).length)return e;let s=new Headers(e.headers);for(let[n,i]of Object.entries(t))s.set(n,i);return{...e,headers:s}}get needsCode(){return $t.has(this.base)}async refused(){return this.own?(hs?.(),!1):($t.add(this.base),await us?.(this)??!1)}async json(e,t={}){let s=await fetch(this.url(e),this.init({cache:"no-store",...t}));if(s.status===401&&await this.refused())return this.json(e,t);if(!s.ok){let n=s.statusText;try{n=(await s.json()).detail??n}catch{}throw new(s.status===401?Le:Error)(`${s.status} ${n}`)}return await s.json()}post(e,t){return this.json(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)})}info(){return this.json("/info")}whoami(){return this.json("/whoami")}async locations(){return(await this.json("/locations")).locations}},he="Testing temporarily disabled.",ne=class extends Error{url;constructor(e,t=null){super(e),this.url=t}};function Ct(r){try{let e=JSON.parse(r);return new ne(e.message??he,e.url??null)}catch{return new ne(he)}}function ue(){return Math.random().toString(36).slice(2,10)}var G=r=>new Promise(e=>setTimeout(e,r));performance.setResourceTimingBufferSize?.(4e3);async function gs(r){for(let e=0;e<6;e++){let t=performance.getEntriesByName(r,"resource"),s=t[t.length-1];if(s)return s;await G(e===0?0:5)}}function Rt(r,e="app"){if(!r)return 0;if(typeof r!="string")return r.serverTiming?.find(t=>t.name===e)?.duration??0;for(let t of r.split(",")){let[s,...n]=t.split(";").map(i=>i.trim());if(s===e){for(let i of n)if(i.startsWith("dur="))return Number(i.slice(4))||0}}return 0}function qe(){performance.clearResourceTimings()}function $e(r,e){let t=new AbortController;if(r&&(r.aborted?t.abort(r.reason):r.addEventListener("abort",()=>t.abort(r.reason),{once:!0})),e){let s=setTimeout(()=>t.abort(new DOMException("timeout","TimeoutError")),e);t.signal.addEventListener("abort",()=>clearTimeout(s),{once:!0})}return t}function l(r,e={},...t){let s=document.createElement(r);return bs(s,e),vs(s,t),s}var $n="http://www.w3.org/2000/svg";function y(r,e={},...t){let s=document.createElementNS($n,r);return bs(s,e),vs(s,t),s}function bs(r,e){for(let[t,s]of Object.entries(e))s==null||s===!1||(typeof s=="function"?r.addEventListener(t.replace(/^on/,""),s):t==="class"?r.setAttribute("class",String(s)):r.setAttribute(t,s===!0?"":String(s)))}function vs(r,e){for(let t of e)t==null||t===!1||r.append(t instanceof Node?t:String(t))}function L(r){for(;r.firstChild;)r.firstChild.remove()}function k(r,e){r&&r.textContent!==e&&(r.textContent=e)}function q(r,e=document){let t=e.querySelector(r);if(!t)throw new Error(`missing ${r}`);return t}var be=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches;function H(r,e){let t=-1,s=new ResizeObserver(([n])=>{let i=Math.round(n.contentRect.width);i!==t&&i>0&&(t=i,e(i))});return s.observe(r),()=>s.disconnect()}function B(r,e,t){let s=e.getBoundingClientRect(),n=s.width?t/s.width:1;return{x:(r.clientX-s.left)*n,y:(r.clientY-s.top)*n}}function P(r,e=document.documentElement){return getComputedStyle(e).getPropertyValue(r).trim()}function me(r,e){try{let t=localStorage.getItem(r);return t?{...e,...JSON.parse(t)}:e}catch{return e}}function re(r,e){try{localStorage.setItem(r,JSON.stringify(e))}catch{}}var ws="wakeLock"in navigator,Cn="Keeps the screen from dimming or turning off while Monitor or Diag is open and while a test runs, so the browser keeps measuring. Switching to another app or tab lets it sleep as usual.",Ve=class{constructor(e){this.enabled=e;document.addEventListener("visibilitychange",()=>this.apply())}enabled;holders=new Set;lock=null;asking=!1;hold(e,t=!0){t?this.holders.add(e):this.holders.delete(e),this.apply()}apply(){if(!(ws&&this.enabled()&&this.holders.size>0&&document.visibilityState==="visible")){this.lock?.release(),this.lock=null;return}this.lock||this.asking||(this.asking=!0,navigator.wakeLock.request("screen").then(t=>{this.asking=!1,this.lock=t,t.addEventListener("release",()=>{this.lock===t&&(this.lock=null)}),this.apply()},t=>{this.asking=!1,console.info("the screen can't be kept on:",t)}))}};function ve(r){if(!ws)return null;let e=[[!0,"On"],[!1,"Off"]],t=l("div",{class:"seg",role:"radiogroup","aria-label":"Keep screen on"}),s=()=>e.forEach(([n],i)=>t.children[i]?.setAttribute("aria-checked",String(r.settings.keepAwake===n)));for(let[n,i]of e){let o=l("button",{type:"button",role:"radio"},i);o.addEventListener("click",()=>{r.settings.keepAwake=n,r.saveSettings(),r.awake.apply(),s()}),t.append(o)}return s(),{el:l("div",{class:"opt"},l("span",{class:"opt-label",title:Cn},"Keep screen on"),t),mark:s}}var Ht="t2s.pass",we=0,_t=!1,Ce=null,At="";function zt(){re(Ht,{pass:"",expires:0}),we=0}function Ge(){return we*1e3>Date.now()}async function xs(r){let e=me(Ht,{pass:"",expires:0});we=e.pass?e.expires:0,Ge()&&We(e.pass);let t;try{t=await r.json("/access")}catch{return null}return At=t.note??"",!t.required||t.pass?.valid||(We(""),we=0,await Rn(r,e.pass!=="")),t}function Rn(r,e){document.body.classList.add("gated");let t=q("#view");return L(t),new Promise(s=>{let n=e?"Access expired. Contact the service desk.":"Use of this system is limited to authorized users with an assigned access code.",{card:i,input:o}=ys(r,"h1",n,()=>{document.body.classList.remove("gated"),s()});t.append(l("section",{class:"gate"},i)),o.focus()})}function Dt(r,e,t=!1){if(Ce)return Ce;if(_t&&!t)return Promise.resolve(!1);let s=we>0&&!Ge(),n=It(e,s?"access expired. Contact the service desk.":"this function requires organization approval. Access is limited to authorized users.");return Ce=new Promise(i=>{let o=l("button",{class:"btn small",type:"button"},"Not now"),a=l("dialog",{class:"code-dialog","aria-labelledby":"access-title"}),{card:d,input:c}=ys(r,"h2",n,()=>{_t=!1,a.close("pass")},l("div",{class:"gate-later"},o));o.addEventListener("click",()=>a.close()),a.addEventListener("close",()=>{a.remove(),Ce=null;let p=a.returnValue==="pass";p||(_t=!0),i(p)}),a.append(d),document.body.append(a),a.showModal(),c.focus()}),Ce}function ys(r,e,t,s,...n){let i=l("input",{class:"code-input",id:"access-code",type:"text",name:"code",autocomplete:"off",autocapitalize:"none",autocorrect:"off",spellcheck:"false",enterkeyhint:"go",maxlength:100,"aria-describedby":"access-help",required:!0}),o=l("button",{class:"btn primary big",type:"submit"},"Continue"),a=l("p",{class:"gate-error",role:"alert"}),d=l("form",{class:"gate-form"},l("label",{class:"visually-hidden",for:"access-code"},"Access code"),i,o);return d.addEventListener("submit",p=>{p.preventDefault(),(async()=>{o.disabled=!0,a.textContent="";try{let h=await r.post("/access",{code:i.value});re(Ht,h),We(h.pass),we=h.expires,s()}catch(h){let u=h instanceof Error?h.message:String(h);a.textContent=u.startsWith("403")?"That isn't the current code. Check it with the service desk.":`The server didn't answer: ${u}`,i.select()}finally{o.disabled=!1}})()}),{card:l("div",{class:"card gate-card"},l(e,{id:"access-title"},"Enter access code"),l("p",{class:"lede",id:"access-help"},t),d,a,At?l("p",{class:"gate-note"},At):null,...n),input:i}}function It(r,e){return r?r+e:e.charAt(0).toUpperCase()+e.slice(1)}var Ot="t2s.size",Ft="t2s:size",ks=[.7,.8,.9,1,1.1,1.25];function Ts(){return parseFloat(getComputedStyle(document.body).zoom)||1}function Ss(r,e){let t=()=>r.isConnected?e():window.removeEventListener(Ft,t);window.addEventListener(Ft,t)}function _n(){try{let r=parseFloat(localStorage.getItem(Ot)??"");if(ks.includes(r))return r}catch{}return 1}function An(r){document.documentElement.style.setProperty("--ui-zoom",String(r));try{r===1?localStorage.removeItem(Ot):localStorage.setItem(Ot,String(r))}catch{}window.dispatchEvent(new Event(Ft))}function Ms(r){let e=_n(),t=l("select",{class:"picker-select","aria-label":"Page size"});for(let s of ks)t.append(l("option",{value:String(s),selected:s===e},`${Math.round(s*100)}%`));t.addEventListener("change",()=>An(parseFloat(t.value))),r.append(l("label",{class:"picker size-picker",title:"Page size"},l("span",{class:"picker-glyph","aria-hidden":"true"},"Aa"),t))}var Bt=[{id:"system",label:"Match system"},{id:"light",label:"Light"},{id:"dark",label:"Dark"},{id:"america",label:"America"},{id:"energy",label:"Energy"},{id:"federal",label:"Federal"},{id:"military",label:"Military"},{id:"texas",label:"Texas"}],Es="t2s.theme",jt="t2s:theme",Ut=r=>Bt.some(e=>e.id===r);function Hn(){let r=document.documentElement.dataset.defaultTheme;return Ut(r)?r:"system"}function zn(){try{let r=localStorage.getItem(Es);if(Ut(r))return r}catch{}return Hn()}function Dn(r){let e=document.documentElement;r==="system"?delete e.dataset.theme:e.dataset.theme=r;try{localStorage.setItem(Es,r)}catch{}}function Ke(){return getComputedStyle(document.documentElement).colorScheme==="dark"}function xe(r,e){let t=()=>r.isConnected?e():window.removeEventListener(jt,t);window.addEventListener(jt,t)}function In(){let r=()=>window.dispatchEvent(new Event(jt));new MutationObserver(r).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",r)}function On(r){return r==="system"?l("span",{class:"theme-swatch split","aria-hidden":"true"},l("span",{"data-theme":"light"}),l("span",{"data-theme":"dark"})):l("span",{class:"theme-swatch","data-theme":r,"aria-hidden":"true"})}var Fn="M12 3a9 9 0 1 0 0 18c1.2 0 1.8-.9 1.8-1.8 0-.5-.2-.9-.5-1.2-.3-.3-.5-.7-.5-1.2 0-1 .8-1.8 1.8-1.8H17a4 4 0 0 0 4-4C21 6.6 17 3 12 3z";function Ls(r){In();let e=()=>y("svg",{class:"theme-check",viewBox:"0 0 24 24","aria-hidden":"true"},y("path",{d:"M5 12.5l4.5 4.5L19 7.5"})),t=Bt.map(d=>l("button",{class:"theme-item",type:"button",role:"menuitemradio","data-value":d.id},On(d.id),l("span",{},d.label),e())),s=l("div",{class:"theme-pop",role:"menu",id:"theme-pop","aria-label":"Theme",hidden:!0},l("div",{class:"theme-pop-title","aria-hidden":"true"},"Theme"),...t),n=l("button",{class:"icon-btn",type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-controls":"theme-pop"},y("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},y("path",{d:Fn}),y("circle",{cx:"7.5",cy:"11",r:"1.2"}),y("circle",{cx:"10.5",cy:"7",r:"1.2"}),y("circle",{cx:"15",cy:"7.5",r:"1.2"})));r.append(n,s);let i=()=>{let d=zn(),c=Bt.find(p=>p.id===d).label;n.setAttribute("aria-label",`Theme: ${c}`),n.title=`Theme: ${c}`;for(let p of t)p.setAttribute("aria-checked",String(p.dataset.value===d))},o=d=>{s.hidden=!1,n.setAttribute("aria-expanded","true"),d&&(t.find(c=>c.getAttribute("aria-checked")==="true")??t[0]).focus()},a=d=>{s.hidden||(s.hidden=!0,n.setAttribute("aria-expanded","false"),d&&n.focus())};n.addEventListener("click",()=>s.hidden?o(!1):a(!1)),n.addEventListener("keydown",d=>{(d.key==="ArrowDown"||d.key==="ArrowUp")&&(d.preventDefault(),o(!0))});for(let d of t)d.addEventListener("click",()=>{let c=d.dataset.value;Ut(c)&&Dn(c),i(),a(!0)});s.addEventListener("keydown",d=>{if(d.key==="Tab")return a(!1);let c=t.indexOf(document.activeElement),p=h=>t[(h+t.length)%t.length].focus();if(d.key==="ArrowDown")p(c+1);else if(d.key==="ArrowUp")p(c-1);else if(d.key==="Home")p(0);else if(d.key==="End")p(t.length-1);else if(d.key==="Escape")a(!0);else return;d.preventDefault()}),document.addEventListener("click",d=>{r.contains(d.target)||a(!1)}),i()}var Ye=class{origin=new N("");ep=this.origin;info=null;whoami=null;locations=[];selected=null;desk=!0;access=null;settings;awake=new Ve(()=>this.settings.keepAwake);pages=new Set((document.documentElement.dataset.pages??"test monitor diag history api").split(" "));home=this.pages.has("test")?"/":`/${[...this.pages][0]}`;listeners=new Set;current=null;kept=new Map;routes=[];constructor(){this.settings=me("t2s.settings",{streams:4,seconds:10,packets:500,intervalMs:10,oneStream:null,family:"auto",keepAwake:!0})}route(e,t,s){return this.routes.push({page:e,pattern:t,make:s}),this}async start(){Ms(q("#size-picker")),Ls(q("#theme-menu"));for(let t of["resize","t2s:size"])window.addEventListener(t,()=>this.fitHeader());document.fonts?.ready.then(()=>this.fitHeader()),this.fitHeader(),ms(()=>{zt(),window.location.reload()}),fs(t=>this.refusedBy(t)),this.access=await xs(this.origin),this.desk=this.access?.desk??!0;let e=document.querySelector('meta[name="texas2step-version"]');if(e&&!e.content)try{e.content=(await this.origin.json("/info")).version??""}catch{}this.fitHeader(),document.addEventListener("click",t=>{let s=t.target.closest("a[data-link]");!s||t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),this.navigate(Pe(new URL(s.href).pathname)))}),window.addEventListener("popstate",()=>this.render()),L(q("#view")),this.render(),await this.loadLocations()}navigate(e,t=!1){let s=this.match(e),n=s&&s.page!==this.current?.name&&!Object.keys(s.params).length?this.kept.get(s.page):void 0;n&&(e=n.address),e!==this.address()&&(t?history.replaceState(null,"",W(e)):history.pushState(null,"",W(e)),this.render())}setAddress(e){let t=this.kept.get(this.match(e)?.page??"");t&&(t.address=e,t===this.current&&e!==this.address()&&history.replaceState(null,"",W(e)))}address(){return Pe(window.location.pathname)+window.location.search}match(e){let t=e.split("?")[0];for(let s of this.routes){let n=s.pattern.exec(t);if(n)return{...s,params:n.groups??{}}}return null}render(){let e=Pe(window.location.pathname);for(let o of document.querySelectorAll(".tabs a")){let a=Pe(new URL(o.href).pathname),d=a==="/"?e==="/"||e.startsWith("/r/"):e.startsWith(a);o.toggleAttribute("aria-current",d),d&&o.setAttribute("aria-current","page")}let t=this.match(e);if(!t)return this.navigate(this.home,!0);let s=this.address(),n=this.current,i=this.kept.get(t.page);if(!(i===n&&i?.address===s)){if(n&&n!==i&&(n.scroll=window.scrollY,n.view.hide?.(),n.el.hidden=!0),i&&i!==n&&i.address===s){this.current=i,i.el.hidden=!1,i.view.show?.(),window.scrollTo(0,i.scroll);return}i&&(i.view.unmount?.(),i.el.remove()),i={name:t.page,view:t.make(),el:l("div",{class:"page"}),address:s,scroll:0},this.kept.set(t.page,i),this.current=i,q("#view").append(i.el),i.view.mount(i.el,t.params),n&&n!==i&&window.scrollTo(0,0)}}saveSettings(){re("t2s.settings",this.settings)}onServer(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async loadLocations(){try{this.locations=await this.origin.locations()}catch{this.locations=[]}let e=me("t2s.server",{id:""}).id;this.selected=this.locations.find(t=>t.id===e)??this.locations[0]??null,this.renderPicker(),await this.select(this.selected)}familyFor(e){let t=this.settings.family;return t==="ipv4"&&e?.url_v4?"ipv4":t==="ipv6"&&e?.url_v6?"ipv6":null}endpointFor(e){let t=this.familyFor(e);return t==="ipv4"?new N(e.url_v4,t):t==="ipv6"?new N(e.url_v6,t):new N(e.url)}async refusedBy(e){return!this.takesCode||Ge()?!1:this.access?.required?(zt(),window.location.reload(),!1):Dt(this.origin,this.over(e))}get takesCode(){return this.access?.codes===!0}async enterCode(e){let t=await Dt(this.origin,this.over(e),!0);return t&&!this.info&&await this.refreshFamily(),t}over(e){return e.family?`Over ${e.family==="ipv4"?"IPv4":"IPv6"}, `:""}needsCodeText(e){return It(this.over(e),"this function is restricted.")}async select(e){this.selected=e,e&&re("t2s.server",{id:e.id}),this.ep=e?this.endpointFor(e):this.origin,this.renderFamily(),this.info=null,this.whoami=null;try{[this.info,this.whoami]=await Promise.all([this.ep.info(),this.ep.whoami()])}catch(n){console.warn("server unreachable",n)}k(document.querySelector("#footer-version"),this.info?.version?`texas2step ${this.info.version}`:"texas2step");let t=document.querySelector("#server-picker .picker-status"),s=!this.info&&this.ep.needsCode;t?.classList.toggle("down",!this.info&&!s),t?.classList.toggle("code",s);for(let n of this.listeners)n()}async refreshFamily(){await this.select(this.selected)}renderFamily(){let e=q("#family-picker");L(e);let t=this.selected;if(!t?.url_v4&&!t?.url_v6)return;let s=l("select",{class:"picker-select","aria-label":"Address family"}),n=this.familyFor(t)??"auto",i=[["auto","Auto",""],["ipv4","IPv4 only",t.url_v4],["ipv6","IPv6 only",t.url_v6]];for(let[o,a,d]of i)(o==="auto"||d)&&s.append(l("option",{value:o,selected:o===n},a));s.addEventListener("change",()=>{this.settings.family=s.value,this.saveSettings(),this.refreshFamily()}),e.append(l("label",{class:"picker family-picker",title:"Address family"},l("span",{class:"picker-glyph","aria-hidden":"true"},"IP"),s)),this.fitHeader()}fitHeader(){let e=document.querySelector(".topbar");e&&(e.classList.remove("wrapped"),e.classList.toggle("wrapped",e.scrollWidth>e.clientWidth+1))}renderPicker(){let e=q("#server-picker");if(L(e),this.locations.length<=1){let s=this.locations[0];e.append(l("div",{class:"picker single",title:"Test server"},l("span",{class:"picker-status"}),l("span",{class:"picker-name"},s?.name??"This server"),s?.location?l("span",{class:"picker-loc"},s.location):null));return}let t=l("select",{class:"picker-select","aria-label":"Test server"});for(let s of this.locations){let n=s.location?`${s.name} \u2014 ${s.location}`:s.name;t.append(l("option",{value:s.id,selected:s.id===this.selected?.id},n))}t.addEventListener("change",()=>{this.select(this.locations.find(s=>s.id===t.value)??null)}),e.append(l("label",{class:"picker"},l("span",{class:"picker-status"}),t)),this.fitHeader()}};var Bn=[{title:"Measurement primitives",about:"The wire endpoints every test is built from. Stable, tiny and safe to script against.",items:[{method:"GET",path:"/api/v1/ping",title:"Round-trip probe",about:"Minimal response with Server-Timing. Reuse the connection and time request \u2192 first byte.",example:r=>`curl -s -w '%{time_starttransfer}\\n' -o /dev/null ${r}/api/v1/ping`},{method:"GET",path:"/api/v1/down?bytes=N",title:"Download",about:"Streams N incompressible bytes from memory (no disk). Use ?seconds=S to stream for a fixed time instead.",example:r=>`curl -o /dev/null -w '%{speed_download} B/s\\n' '${r}/api/v1/down?bytes=1000000000'`},{method:"POST",path:"/api/v1/up",title:"Upload",about:"Reads and discards the body as it arrives; returns bytes received and the server-observed rate.",example:r=>`head -c 500000000 /dev/urandom | curl -s -X POST --data-binary @- ${r}/api/v1/up`},{method:"WS",path:"/api/v1/ws",title:"Echo socket",about:"Echoes every message unchanged. Used for latency under load and live monitoring.",example:r=>`websocat ${r.replace(/^http/,"ws")}/api/v1/ws`},{method:"POST",path:"/api/v1/rtc/offer",title:"UDP probe signalling",about:`Answers a WebRTC offer with a 'probe' channel (unordered, no retransmit) echoing packets, and a 'control' channel reporting server-side counters ({"op":"stats"}).`,example:r=>`texas2step loss ${r}`}]},{title:"Server-side measurements",about:"This server measures toward another texas2step endpoint and returns the result. Targets must be configured locations.",items:[{method:"POST",path:"/api/v1/measure/latency",title:"Latency",about:"Idle HTTP round-trip time and jitter.",example:r=>`curl -s -X POST ${r}/api/v1/measure/latency -H 'content-type: application/json' -d '{"target":"https://peer.example","count":20}'`},{method:"POST",path:"/api/v1/measure/download",title:"Download",about:"Multi-stream download from the target, with latency under load.",example:r=>`curl -s -X POST ${r}/api/v1/measure/download -H 'content-type: application/json' -d '{"target":"https://peer.example","seconds":10,"streams":4}'`},{method:"POST",path:"/api/v1/measure/upload",title:"Upload",about:"Multi-stream upload to the target.",example:r=>`curl -s -X POST ${r}/api/v1/measure/upload -H 'content-type: application/json' -d '{"target":"https://peer.example"}'`},{method:"POST",path:"/api/v1/measure/loss",title:"Packet loss",about:"UDP loss, RTT and jitter over WebRTC.",example:r=>`curl -s -X POST ${r}/api/v1/measure/loss -H 'content-type: application/json' -d '{"target":"https://peer.example","packets":500}'`},{method:"POST",path:"/api/v1/measure/full",title:"Everything",about:"Latency, download, upload and loss in one call.",example:r=>`curl -s -X POST ${r}/api/v1/measure/full -H 'content-type: application/json' -d '{"target":"https://peer.example"}'`}]},{title:"Discovery and results",about:"Who the server is, who you are, and saved test history.",items:[{method:"GET",path:"/api/v1/info",title:"Server info",about:"Identity, version, capabilities and limits.",example:r=>`curl -s ${r}/api/v1/info`},{method:"GET",path:"/api/v1/whoami",title:"Client view",about:"Your address and family as the server sees them.",example:r=>`curl -s ${r}/api/v1/whoami`},{method:"GET",path:"/api/v1/locations",title:"Locations",about:"Servers offered in the picker.",example:r=>`curl -s ${r}/api/v1/locations`},{method:"GET",path:"/api/v1/results",title:"Saved results",about:"Summaries, newest first. GET /api/v1/results/{id} returns one in full; POST stores one.",example:r=>`curl -s '${r}/api/v1/results?limit=10'`}]}],Xe=class{constructor(e){this.app=e}app;mount(e){let t=this.app.origin.base;e.append(l("section",{class:"page-head"},l("div",{},l("h1",{},"API"),l("p",{class:"lede"},"Every measurement the page makes is available to scripts, monitoring systems and other servers. All endpoints send CORS and Timing-Allow-Origin headers.")),l("div",{class:"head-actions"},l("a",{class:"btn",href:W("/api/docs")},"OpenAPI explorer"),l("a",{class:"btn",href:W("/api/openapi.json")},"openapi.json"))),l("section",{class:"card cli-card"},l("h2",{},"Command line"),l("p",{},"The Python package ships the same engine as a CLI. Results are comparable with browser runs."),Ps(`pip install . # from a texas2step checkout
1
+ var Ln="/api/v1",Ee=new URL(document.baseURI).pathname.replace(/\/+$/,"");function W(r){return Ee+r}function Pe(r){return r.startsWith(Ee)?r.slice(Ee.length)||"/":r}var pe="",ps="texas2step",Pn=`${ps}.pass.`,hs=null,us=null,$t=new Set;function We(r){pe=r,$t.clear()}function ms(r){hs=r}function fs(r){us=r}var Le=class extends Error{},N=class{constructor(e,t=null){this.family=t;this.base=(e||window.location.origin+Ee).replace(/\/+$/,"")}family;base;get own(){return this.base===`${window.location.origin}${Ee}`.replace(/\/+$/,"")}url(e,t={}){let s=new URL(this.base+Ln+e);for(let[n,i]of Object.entries(t))s.searchParams.set(n,String(i));return pe&&!this.own&&s.searchParams.set("pass",pe),s.href}wsUrl(e){return this.url(e).replace(/^http/,"ws")}wsProtocols(){return pe&&this.own?[ps,Pn+pe]:[]}headers(){return pe&&this.own?{Authorization:`Bearer ${pe}`}:{}}init(e={}){let t=this.headers();if(!Object.keys(t).length)return e;let s=new Headers(e.headers);for(let[n,i]of Object.entries(t))s.set(n,i);return{...e,headers:s}}get needsCode(){return $t.has(this.base)}async refused(){return this.own?(hs?.(),!1):($t.add(this.base),await us?.(this)??!1)}async json(e,t={}){let s=await fetch(this.url(e),this.init({cache:"no-store",...t}));if(s.status===401&&await this.refused())return this.json(e,t);if(!s.ok){let n=s.statusText;try{n=(await s.json()).detail??n}catch{}throw new(s.status===401?Le:Error)(`${s.status} ${n}`)}return await s.json()}post(e,t){return this.json(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)})}info(){return this.json("/info")}whoami(){return this.json("/whoami")}async locations(){return(await this.json("/locations")).locations}},he="Testing temporarily disabled.",ne=class extends Error{url;constructor(e,t=null){super(e),this.url=t}};function Ct(r){try{let e=JSON.parse(r);return new ne(e.message??he,e.url??null)}catch{return new ne(he)}}function ue(){return Math.random().toString(36).slice(2,10)}var G=r=>new Promise(e=>setTimeout(e,r));performance.setResourceTimingBufferSize?.(4e3);async function gs(r){for(let e=0;e<6;e++){let t=performance.getEntriesByName(r,"resource"),s=t[t.length-1];if(s)return s;await G(e===0?0:5)}}function Rt(r,e="app"){if(!r)return 0;if(typeof r!="string")return r.serverTiming?.find(t=>t.name===e)?.duration??0;for(let t of r.split(",")){let[s,...n]=t.split(";").map(i=>i.trim());if(s===e){for(let i of n)if(i.startsWith("dur="))return Number(i.slice(4))||0}}return 0}function qe(){performance.clearResourceTimings()}function $e(r,e){let t=new AbortController;if(r&&(r.aborted?t.abort(r.reason):r.addEventListener("abort",()=>t.abort(r.reason),{once:!0})),e){let s=setTimeout(()=>t.abort(new DOMException("timeout","TimeoutError")),e);t.signal.addEventListener("abort",()=>clearTimeout(s),{once:!0})}return t}function l(r,e={},...t){let s=document.createElement(r);return bs(s,e),vs(s,t),s}var $n="http://www.w3.org/2000/svg";function y(r,e={},...t){let s=document.createElementNS($n,r);return bs(s,e),vs(s,t),s}function bs(r,e){for(let[t,s]of Object.entries(e))s==null||s===!1||(typeof s=="function"?r.addEventListener(t.replace(/^on/,""),s):t==="class"?r.setAttribute("class",String(s)):r.setAttribute(t,s===!0?"":String(s)))}function vs(r,e){for(let t of e)t==null||t===!1||r.append(t instanceof Node?t:String(t))}function L(r){for(;r.firstChild;)r.firstChild.remove()}function k(r,e){r&&r.textContent!==e&&(r.textContent=e)}function q(r,e=document){let t=e.querySelector(r);if(!t)throw new Error(`missing ${r}`);return t}var be=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches;function H(r,e){let t=-1,s=new ResizeObserver(([n])=>{let i=Math.round(n.contentRect.width);i!==t&&i>0&&(t=i,e(i))});return s.observe(r),()=>s.disconnect()}function B(r,e,t){let s=e.getBoundingClientRect(),n=s.width?t/s.width:1;return{x:(r.clientX-s.left)*n,y:(r.clientY-s.top)*n}}function P(r,e=document.documentElement){return getComputedStyle(e).getPropertyValue(r).trim()}function me(r,e){try{let t=localStorage.getItem(r);return t?{...e,...JSON.parse(t)}:e}catch{return e}}function re(r,e){try{localStorage.setItem(r,JSON.stringify(e))}catch{}}var ws="wakeLock"in navigator,Cn="Keeps the screen from dimming or turning off while Monitor or Diag is open and while a test runs, so the browser keeps measuring. Switching to another app or tab lets it sleep as usual.",Ve=class{constructor(e){this.enabled=e;document.addEventListener("visibilitychange",()=>this.apply())}enabled;holders=new Set;lock=null;asking=!1;hold(e,t=!0){t?this.holders.add(e):this.holders.delete(e),this.apply()}apply(){if(!(ws&&this.enabled()&&this.holders.size>0&&document.visibilityState==="visible")){this.lock?.release(),this.lock=null;return}this.lock||this.asking||(this.asking=!0,navigator.wakeLock.request("screen").then(t=>{this.asking=!1,this.lock=t,t.addEventListener("release",()=>{this.lock===t&&(this.lock=null)}),this.apply()},t=>{this.asking=!1,console.info("the screen can't be kept on:",t)}))}};function ve(r){if(!ws)return null;let e=[[!0,"On"],[!1,"Off"]],t=l("div",{class:"seg",role:"radiogroup","aria-label":"Keep screen on"}),s=()=>e.forEach(([n],i)=>t.children[i]?.setAttribute("aria-checked",String(r.settings.keepAwake===n)));for(let[n,i]of e){let o=l("button",{type:"button",role:"radio"},i);o.addEventListener("click",()=>{r.settings.keepAwake=n,r.saveSettings(),r.awake.apply(),s()}),t.append(o)}return s(),{el:l("div",{class:"opt"},l("span",{class:"opt-label",title:Cn},"Keep screen on"),t),mark:s}}var Ht="t2s.pass",we=0,_t=!1,Ce=null,At="";function zt(){re(Ht,{pass:"",expires:0}),we=0}function Ge(){return we*1e3>Date.now()}async function xs(r){let e=me(Ht,{pass:"",expires:0});we=e.pass?e.expires:0,Ge()&&We(e.pass);let t;try{t=await r.json("/access")}catch{return null}return At=t.note??"",!t.required||t.pass?.valid||(We(""),we=0,await Rn(r,e.pass!=="")),t}function Rn(r,e){document.body.classList.add("gated");let t=q("#view");return L(t),new Promise(s=>{let n=e?"Access expired. Contact the service desk.":"Use of this system is limited to authorized users with an assigned access code.",{card:i,input:o}=ys(r,"h1",n,()=>{document.body.classList.remove("gated"),s()});t.append(l("section",{class:"gate"},i)),o.focus()})}function Dt(r,e,t=!1){if(Ce)return Ce;if(_t&&!t)return Promise.resolve(!1);let s=we>0&&!Ge(),n=It(e,s?"access expired. Contact the service desk.":"this function requires organization approval. Access is limited to authorized users.");return Ce=new Promise(i=>{let o=l("button",{class:"btn small",type:"button"},"Not now"),a=l("dialog",{class:"code-dialog","aria-labelledby":"access-title"}),{card:d,input:c}=ys(r,"h2",n,()=>{_t=!1,a.close("pass")},l("div",{class:"gate-later"},o));o.addEventListener("click",()=>a.close()),a.addEventListener("close",()=>{a.remove(),Ce=null;let p=a.returnValue==="pass";p||(_t=!0),i(p)}),a.append(d),document.body.append(a),a.showModal(),c.focus()}),Ce}function ys(r,e,t,s,...n){let i=l("input",{class:"code-input",id:"access-code",type:"text",name:"code",autocomplete:"off",autocapitalize:"none",autocorrect:"off",spellcheck:"false",enterkeyhint:"go",maxlength:100,"aria-describedby":"access-help",required:!0}),o=l("button",{class:"btn primary big",type:"submit"},"Continue"),a=l("p",{class:"gate-error",role:"alert"}),d=l("form",{class:"gate-form"},l("label",{class:"visually-hidden",for:"access-code"},"Access code"),i,o);return d.addEventListener("submit",p=>{p.preventDefault(),(async()=>{o.disabled=!0,a.textContent="";try{let h=await r.post("/access",{code:i.value});re(Ht,h),We(h.pass),we=h.expires,s()}catch(h){let u=h instanceof Error?h.message:String(h);a.textContent=u.startsWith("403")?"That isn't the current code. Check it with the service desk.":`The server didn't answer: ${u}`,i.select()}finally{o.disabled=!1}})()}),{card:l("div",{class:"card gate-card"},l(e,{id:"access-title"},"Enter access code"),l("p",{class:"lede",id:"access-help"},t),d,a,At?l("p",{class:"gate-note"},At):null,...n),input:i}}function It(r,e){return r?r+e:e.charAt(0).toUpperCase()+e.slice(1)}var Ot="t2s.size",Ft="t2s:size",ks=[.7,.8,.9,1,1.1,1.25];function Ts(){return parseFloat(getComputedStyle(document.body).zoom)||1}function Ss(r,e){let t=()=>r.isConnected?e():window.removeEventListener(Ft,t);window.addEventListener(Ft,t)}function _n(){try{let r=parseFloat(localStorage.getItem(Ot)??"");if(ks.includes(r))return r}catch{}return 1}function An(r){document.documentElement.style.setProperty("--ui-zoom",String(r));try{r===1?localStorage.removeItem(Ot):localStorage.setItem(Ot,String(r))}catch{}window.dispatchEvent(new Event(Ft))}function Ms(r){let e=_n(),t=l("select",{class:"picker-select","aria-label":"Page size"});for(let s of ks)t.append(l("option",{value:String(s),selected:s===e},`${Math.round(s*100)}%`));t.addEventListener("change",()=>An(parseFloat(t.value))),r.append(l("label",{class:"picker size-picker",title:"Page size"},l("span",{class:"picker-glyph","aria-hidden":"true"},"Aa"),t))}var Bt=[{id:"system",label:"Match system"},{id:"light",label:"Light"},{id:"dark",label:"Dark"},{id:"america",label:"America"},{id:"energy",label:"Energy"},{id:"federal",label:"Federal"},{id:"military",label:"Military"},{id:"texas",label:"Texas"}],Es="t2s.theme",jt="t2s:theme",Ut=r=>Bt.some(e=>e.id===r);function Hn(){let r=document.documentElement.dataset.defaultTheme;return Ut(r)?r:"system"}function zn(){try{let r=localStorage.getItem(Es);if(Ut(r))return r}catch{}return Hn()}function Dn(r){let e=document.documentElement;r==="system"?delete e.dataset.theme:e.dataset.theme=r;try{localStorage.setItem(Es,r)}catch{}}function Ke(){return getComputedStyle(document.documentElement).colorScheme==="dark"}function xe(r,e){let t=()=>r.isConnected?e():window.removeEventListener(jt,t);window.addEventListener(jt,t)}function In(){let r=()=>window.dispatchEvent(new Event(jt));new MutationObserver(r).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",r)}function On(r){return r==="system"?l("span",{class:"theme-swatch split","aria-hidden":"true"},l("span",{"data-theme":"light"}),l("span",{"data-theme":"dark"})):l("span",{class:"theme-swatch","data-theme":r,"aria-hidden":"true"})}var Fn="M12 3a9 9 0 1 0 0 18c1.2 0 1.8-.9 1.8-1.8 0-.5-.2-.9-.5-1.2-.3-.3-.5-.7-.5-1.2 0-1 .8-1.8 1.8-1.8H17a4 4 0 0 0 4-4C21 6.6 17 3 12 3z";function Ls(r){In();let e=()=>y("svg",{class:"theme-check",viewBox:"0 0 24 24","aria-hidden":"true"},y("path",{d:"M5 12.5l4.5 4.5L19 7.5"})),t=Bt.map(d=>l("button",{class:"theme-item",type:"button",role:"menuitemradio","data-value":d.id},On(d.id),l("span",{},d.label),e())),s=l("div",{class:"theme-pop",role:"menu",id:"theme-pop","aria-label":"Theme",hidden:!0},l("div",{class:"theme-pop-title","aria-hidden":"true"},"Theme"),...t),n=l("button",{class:"icon-btn",type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-controls":"theme-pop"},y("svg",{viewBox:"0 0 24 24","aria-hidden":"true"},y("path",{d:Fn}),y("circle",{cx:"7.5",cy:"11",r:"1.2"}),y("circle",{cx:"10.5",cy:"7",r:"1.2"}),y("circle",{cx:"15",cy:"7.5",r:"1.2"})));r.append(n,s);let i=()=>{let d=zn(),c=Bt.find(p=>p.id===d).label;n.setAttribute("aria-label",`Theme: ${c}`),n.title=`Theme: ${c}`;for(let p of t)p.setAttribute("aria-checked",String(p.dataset.value===d))},o=d=>{s.hidden=!1,n.setAttribute("aria-expanded","true"),d&&(t.find(c=>c.getAttribute("aria-checked")==="true")??t[0]).focus()},a=d=>{s.hidden||(s.hidden=!0,n.setAttribute("aria-expanded","false"),d&&n.focus())};n.addEventListener("click",()=>s.hidden?o(!1):a(!1)),n.addEventListener("keydown",d=>{(d.key==="ArrowDown"||d.key==="ArrowUp")&&(d.preventDefault(),o(!0))});for(let d of t)d.addEventListener("click",()=>{let c=d.dataset.value;Ut(c)&&Dn(c),i(),a(!0)});s.addEventListener("keydown",d=>{if(d.key==="Tab")return a(!1);let c=t.indexOf(document.activeElement),p=h=>t[(h+t.length)%t.length].focus();if(d.key==="ArrowDown")p(c+1);else if(d.key==="ArrowUp")p(c-1);else if(d.key==="Home")p(0);else if(d.key==="End")p(t.length-1);else if(d.key==="Escape")a(!0);else return;d.preventDefault()}),document.addEventListener("click",d=>{r.contains(d.target)||a(!1)}),i()}var Ye=class{origin=new N("");ep=this.origin;info=null;whoami=null;locations=[];selected=null;desk=!0;access=null;settings;awake=new Ve(()=>this.settings.keepAwake);pages=new Set((document.documentElement.dataset.pages??"test monitor diag history api").split(" "));home=this.pages.has("test")?"/":`/${[...this.pages][0]}`;listeners=new Set;current=null;kept=new Map;routes=[];constructor(){this.settings=me("t2s.settings",{streams:4,seconds:10,packets:500,intervalMs:10,oneStream:null,family:"auto",keepAwake:!0})}route(e,t,s){return this.routes.push({page:e,pattern:t,make:s}),this}async start(){Ms(q("#size-picker")),Ls(q("#theme-menu"));for(let t of["resize","t2s:size"])window.addEventListener(t,()=>this.fitHeader());document.fonts?.ready.then(()=>this.fitHeader()),this.fitHeader(),ms(()=>{zt(),window.location.reload()}),fs(t=>this.refusedBy(t)),this.access=await xs(this.origin),this.desk=this.access?.desk??!0;let e=document.querySelector('meta[name="texas2step-version"]');if(e&&!e.content)try{e.content=(await this.origin.json("/info")).version??""}catch{}this.fitHeader(),document.addEventListener("click",t=>{let s=t.target.closest("a[data-link]");!s||t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),this.navigate(Pe(new URL(s.href).pathname)))}),window.addEventListener("popstate",()=>this.render()),L(q("#view")),this.render(),await this.loadLocations()}navigate(e,t=!1){let s=this.match(e),n=s&&s.page!==this.current?.name&&!Object.keys(s.params).length?this.kept.get(s.page):void 0;n&&(e=n.address),e!==this.address()&&(t?history.replaceState(null,"",W(e)):history.pushState(null,"",W(e)),this.render())}setAddress(e){let t=this.kept.get(this.match(e)?.page??"");t&&(t.address=e,t===this.current&&e!==this.address()&&history.replaceState(null,"",W(e)))}address(){return Pe(window.location.pathname)+window.location.search}match(e){let t=e.split("?")[0];for(let s of this.routes){let n=s.pattern.exec(t);if(n)return{...s,params:n.groups??{}}}return null}render(){let e=Pe(window.location.pathname);for(let o of document.querySelectorAll(".tabs a")){let a=Pe(new URL(o.href).pathname),d=a==="/"?e==="/"||e.startsWith("/r/"):e.startsWith(a);o.toggleAttribute("aria-current",d),d&&o.setAttribute("aria-current","page")}let t=this.match(e);if(!t)return this.navigate(this.home,!0);let s=this.address(),n=this.current,i=this.kept.get(t.page);if(!(i===n&&i?.address===s)){if(n&&n!==i&&(n.scroll=window.scrollY,n.view.hide?.(),n.el.hidden=!0),i&&i!==n&&i.address===s){this.current=i,i.el.hidden=!1,i.view.show?.(),window.scrollTo(0,i.scroll);return}i&&(i.view.unmount?.(),i.el.remove()),i={name:t.page,view:t.make(),el:l("div",{class:"page"}),address:s,scroll:0},this.kept.set(t.page,i),this.current=i,q("#view").append(i.el),i.view.mount(i.el,t.params),n&&n!==i&&window.scrollTo(0,0)}}saveSettings(){re("t2s.settings",this.settings)}onServer(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async loadLocations(){try{this.locations=await this.origin.locations()}catch{this.locations=[]}let e=me("t2s.server",{id:""}).id;this.selected=this.locations.find(t=>t.id===e)??this.locations[0]??null,this.renderPicker(),await this.select(this.selected)}familyFor(e){let t=this.settings.family;return t==="ipv4"&&e?.url_v4?"ipv4":t==="ipv6"&&e?.url_v6?"ipv6":null}endpointFor(e){let t=this.familyFor(e);return t==="ipv4"?new N(e.url_v4,t):t==="ipv6"?new N(e.url_v6,t):new N(e.url)}async refusedBy(e){return!this.takesCode||Ge()?!1:this.access?.required?(zt(),window.location.reload(),!1):Dt(this.origin,this.over(e))}get takesCode(){return this.access?.codes===!0}async enterCode(e){let t=await Dt(this.origin,this.over(e),!0);return t&&!this.info&&await this.refreshFamily(),t}over(e){return e.family?`Over ${e.family==="ipv4"?"IPv4":"IPv6"}, `:""}needsCodeText(e){return It(this.over(e),"this function is restricted.")}async select(e){this.selected=e,e&&re("t2s.server",{id:e.id}),this.ep=e?this.endpointFor(e):this.origin,this.renderFamily(),this.info=null,this.whoami=null;try{[this.info,this.whoami]=await Promise.all([this.ep.info(),this.ep.whoami()])}catch(n){console.warn("server unreachable",n)}k(document.querySelector("#footer-version"),this.info?.version?`texas2step ${this.info.version}`:"texas2step");let t=document.querySelector("#server-picker .picker-status"),s=!this.info&&this.ep.needsCode;t?.classList.toggle("down",!this.info&&!s),t?.classList.toggle("code",s);for(let n of this.listeners)n()}async refreshFamily(){await this.select(this.selected)}renderFamily(){let e=q("#family-picker");L(e);let t=this.selected;if(!t?.url_v4&&!t?.url_v6)return;let s=l("select",{class:"picker-select","aria-label":"Address family"}),n=this.familyFor(t)??"auto",i=[["auto","Auto",""],["ipv4","IPv4 only",t.url_v4],["ipv6","IPv6 only",t.url_v6]];for(let[o,a,d]of i)(o==="auto"||d)&&s.append(l("option",{value:o,selected:o===n},a));s.addEventListener("change",()=>{this.settings.family=s.value,this.saveSettings(),this.refreshFamily()}),e.append(l("label",{class:"picker family-picker",title:"Address family"},l("span",{class:"picker-glyph","aria-hidden":"true"},"IP"),s)),this.fitHeader()}fitHeader(){let e=document.querySelector(".topbar");e&&(e.classList.remove("wrapped"),e.classList.toggle("wrapped",e.scrollWidth>e.clientWidth+1))}renderPicker(){let e=q("#server-picker");if(L(e),this.locations.length<=1){let s=this.locations[0];e.append(l("div",{class:"picker single",title:"Test server"},l("span",{class:"picker-status"}),l("span",{class:"picker-name"},s?.name??"This server"),s?.location?l("span",{class:"picker-loc"},s.location):null));return}let t=l("select",{class:"picker-select","aria-label":"Test server"});for(let s of this.locations){let n=s.location?`${s.name} \u2014 ${s.location}`:s.name;t.append(l("option",{value:s.id,selected:s.id===this.selected?.id},n))}t.addEventListener("change",()=>{this.select(this.locations.find(s=>s.id===t.value)??null)}),e.append(l("label",{class:"picker"},l("span",{class:"picker-status"}),t)),this.fitHeader()}};var Bn=[{title:"Measurement primitives",about:"The wire endpoints every test is built from. Stable, tiny and safe to script against.",items:[{method:"GET",path:"/api/v1/ping",title:"Round-trip probe",about:"Minimal response with Server-Timing. Reuse the connection and time request \u2192 first byte.",example:r=>`curl -s -w '%{time_starttransfer}\\n' -o /dev/null ${r}/api/v1/ping`},{method:"GET",path:"/api/v1/down?bytes=N",title:"Download",about:"Streams N incompressible bytes from memory (no disk). Use ?seconds=S to stream for a fixed time instead.",example:r=>`curl -o /dev/null -w '%{speed_download} B/s\\n' '${r}/api/v1/down?bytes=1000000000'`},{method:"POST",path:"/api/v1/up",title:"Upload",about:"Reads and discards the body as it arrives; returns bytes received and the server-observed rate.",example:r=>`head -c 500000000 /dev/urandom | curl -s -X POST --data-binary @- ${r}/api/v1/up`},{method:"WS",path:"/api/v1/ws",title:"Echo socket",about:"Echoes every message unchanged. Used for latency under load and live monitoring.",example:r=>`websocat ${r.replace(/^http/,"ws")}/api/v1/ws`},{method:"POST",path:"/api/v1/rtc/offer",title:"UDP probe signalling",about:`Answers a WebRTC offer with a 'probe' channel (unordered, no retransmit) echoing packets, and a 'control' channel reporting server-side counters ({"op":"stats"}).`,example:r=>`texas2step loss ${r}`}]},{title:"Server-side measurements",about:"This server measures toward another one like it and returns the result. Targets must be configured locations.",items:[{method:"POST",path:"/api/v1/measure/latency",title:"Latency",about:"Idle HTTP round-trip time and jitter.",example:r=>`curl -s -X POST ${r}/api/v1/measure/latency -H 'content-type: application/json' -d '{"target":"https://peer.example","count":20}'`},{method:"POST",path:"/api/v1/measure/download",title:"Download",about:"Multi-stream download from the target, with latency under load.",example:r=>`curl -s -X POST ${r}/api/v1/measure/download -H 'content-type: application/json' -d '{"target":"https://peer.example","seconds":10,"streams":4}'`},{method:"POST",path:"/api/v1/measure/upload",title:"Upload",about:"Multi-stream upload to the target.",example:r=>`curl -s -X POST ${r}/api/v1/measure/upload -H 'content-type: application/json' -d '{"target":"https://peer.example"}'`},{method:"POST",path:"/api/v1/measure/loss",title:"Packet loss",about:"UDP loss, RTT and jitter over WebRTC.",example:r=>`curl -s -X POST ${r}/api/v1/measure/loss -H 'content-type: application/json' -d '{"target":"https://peer.example","packets":500}'`},{method:"POST",path:"/api/v1/measure/full",title:"Everything",about:"Latency, download, upload and loss in one call.",example:r=>`curl -s -X POST ${r}/api/v1/measure/full -H 'content-type: application/json' -d '{"target":"https://peer.example"}'`}]},{title:"Discovery and results",about:"Who the server is, who you are, and saved test history.",items:[{method:"GET",path:"/api/v1/info",title:"Server info",about:"Identity, version, capabilities and limits.",example:r=>`curl -s ${r}/api/v1/info`},{method:"GET",path:"/api/v1/whoami",title:"Client view",about:"Your address and family as the server sees them.",example:r=>`curl -s ${r}/api/v1/whoami`},{method:"GET",path:"/api/v1/locations",title:"Locations",about:"Servers offered in the picker.",example:r=>`curl -s ${r}/api/v1/locations`},{method:"GET",path:"/api/v1/results",title:"Saved results",about:"Summaries, newest first. GET /api/v1/results/{id} returns one in full; POST stores one.",example:r=>`curl -s '${r}/api/v1/results?limit=10'`}]}],Xe=class{constructor(e){this.app=e}app;mount(e){let t=this.app.origin.base;e.append(l("section",{class:"page-head"},l("div",{},l("h1",{},"API"),l("p",{class:"lede"},"Every measurement the page makes is available to scripts, monitoring systems and other servers. All endpoints send CORS and Timing-Allow-Origin headers.")),l("div",{class:"head-actions"},l("a",{class:"btn",href:W("/api/docs")},"OpenAPI explorer"),l("a",{class:"btn",href:W("/api/openapi.json")},"openapi.json"))),l("section",{class:"card cli-card"},l("h2",{},"Command line"),l("p",{},"The Python package ships the same engine as a CLI. Results are comparable with browser runs."),Ps(`uv tool install texas2step # or: pipx install texas2step
2
2
  texas2step run ${t} # full test
3
3
  texas2step latency ${t} --count 50
4
4
  texas2step download ${t} --streams 8 --seconds 15
@@ -74,6 +74,6 @@
74
74
  </footer>
75
75
  <div class="tooltip" id="tooltip" role="tooltip" hidden></div>
76
76
  <noscript><p class="noscript">This page needs JavaScript to run measurements.</p></noscript>
77
- <script type="module" src="assets/app.js?v=be41a4121b"></script>
77
+ <script type="module" src="assets/app.js?v=319114b24e"></script>
78
78
  </body>
79
79
  </html>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes