initial commit before refactor switch

This commit is contained in:
brent saner
2024-12-12 02:22:54 -05:00
commit db081e2699
33 changed files with 3101 additions and 0 deletions

45
server/tpl/about.html.tpl Normal file
View File

@@ -0,0 +1,45 @@
{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}}
{{- define "about" }}
{{- $page := . -}}
{{- $linkico := "🔗" }}
{{ template "meta.top" $page }}
<div class="jumbotron">
<h1>About</h1>
</div>
<p>
This is a tool to reveal certain information about your connection that the server sees.
Note that all of this information you see is <i>sent by your client</i>;
there was no probing/scanning or the like done from the server this site is hosted on.
</p>
<p>
If you don't like this info being available to server administrators of the websites
you visit you may want to consider:
<ul>
<li><a href="https://www.torproject.org/">hiding your client IP address</a></li>
<li>
<a href="https://panopticlick.eff.org/self-defense">hiding your browser's metadata, which can be done via browser plugins such as:</a>
<ul>
<li><a href="https://www.eff.org/privacybadger">Privacy Badger</a></li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/modify-headers/">Modify Headers</a></li>
<li><a href="https://www.requestly.in/">Requestly</a></li>
</ul>
</li>
</ul>
There are, of course, many other plugins/methods but as always, due diligence is required when finding the right plugin for you.
Be sure to read multiple reviews.
Some plugins/extensions even disguise your browser as an entirely different operating system, OS version, etc.
Feel free to check back on this site after enabling them to test! (You may need to reset your browser's cache.)
</p>
<p>
If you would like to view the <i>server</i> headers, then you can:
<ul>
<li>use a service such as <a href="https://securityheaders.io">SecurityHeaders.io</a></li>
<li>use the <code>--head</code> (<code>-i</code>, <code>-X HEAD</code>, <code>--request HEAD</code>, etc.; all do the same thing) argument to <b><code>curl</code></b></li>
<li>use the <code>-v</code> (<code>--verbose</code>) argument to <b><code>curl</code></b></li>
<li>use your browser's built-in developer console (<a href="https://firefox-source-docs.mozilla.org/devtools-user/">on Firefox</a>, <a href="https://developer.chrome.com/docs/devtools/open">on Chrome and Chrome-based browsers</a>)</li>
</ul>
There are additionally some extensions/plugins that offer this in a directly-accessible button on the toolbar.
</p>
<br />
{{- template "meta.bottom" $page }}
{{- end }}

14
server/tpl/index.html.tpl Normal file
View File

@@ -0,0 +1,14 @@
{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}}
{{- define "index" }}
{{- $page := . -}}
{{- $linkico := "🔗" }}
{{- template "meta.top" $page }}
<div class="jumbotron">
<h1>Client Info Revealer</h1>
<p class="lead">A tool to reveal client-identifying data sent to webservers</p>
</div>
<div>
{{- template "meta.info" $page }}
</div>
{{- template "meta.bottom" $page }}
{{- end }}

View File

@@ -0,0 +1,11 @@
{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}}
{{- define "meta.bottom" -}}
{{- $page := . -}}
{{- $linkico := "🔗" }}
<footer class="footer">
<p><sub>See <a href="https://pkg.go.dev/r00t2.io/clientinfo">https://pkg.go.dev/r00t2.io/clientinfo</a> for more information on this program.</sub></p>
</footer>
</div>
</body>
</html>
{{- end -}}

View File

@@ -0,0 +1,55 @@
{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}}
{{- define "meta.info" -}}
{{- $page := . -}}
{{- $linkico := "🔗" }}
<h2 id="client">Client/Browser Information<a href="#client">{{ $linkico }}</a></h2>
<p>
<b>Your IP Address is <i><a href="https://ipinfo.io/{{ $page.Info.IP.String }}">{{ $page.Info.IP.String }}</a></i>.</b>
<br/>
<i>You are connecting with port <b>{{ $page.Info.Port }}</b> outbound.</i>
</p>
{{- if $page.Raw }}
<h3 id="client_raw">Raw Block ({{ $page.RawFmt }})<a href="#client_raw">{{ $linkico }}</a></h3>
<p>
{{- if $page.DoRawIndent }}
<pre>{{ $page.Raw }}</pre>
{{- else }}
<code>{{ $page.Raw }}</code>
{{- end }}
</p>
{{- end }}
<h3 id="client_ua">User Agent Information<a href="#client_ua">{{ $linkico }}</a></h3>
<p>This is information that your browser sends to identify itself.</p>
<p>
{{- range $idx, $ua := $page.Info.Client }}
User Agent ({{ $idx }}):
<ul>
{{- $flds := $ua.ToMap }}
{{- range $fld, $str := $flds }}
<li><b>{{ $fld }}:</b> {{ $str }}</li>
{{- end }}
</ul>
{{- end }}
</p>
<h3 id="client_hdrs">Request Headers<a href="#client_hdrs">{{ $linkico }}</a></h3>
<p>
These are headers sent along with the request your browser sends for the page's content.
Note that some headers may have multiple values.
</p>
<p>
<table>
<tr>
<th>Header</th>
<th>Value</th>
</tr>
{{- range $hdrNm, $hdrVals := $page.Info.Req.Header }}
<tr>
{{- range $val := $hdrVals }}
<td>{{ $hdrNm }}</td>
<td>{{ $val }}</td>
{{- end }}
</tr>
{{- end }}
</table>
</p>
{{- end }}

View File

@@ -0,0 +1,53 @@
{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}}
{{- define "meta.top" -}}
{{- $page := . -}}
{{- $linkico := "🔗" -}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{ getTitle $page.PageType }}</title>
<!-- Bootstrap core CSS -->
<!--
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
-->
<!-- Tachyons -->
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css"/>
<!--
Custom styles for Bootstrap
-->
<!--
<link href="https://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css"
rel="stylesheet">
-->
<!--
<link href="https://getbootstrap.com/docs/4.0/examples/offcanvas/offcanvas.css" rel="stylesheet">
-->
</head>
<body>
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="/">Home</a></li>
<li role="presentation"><a href="/about">About</a></li>
<li role="presentation"><a href="/usage">Usage</a></li>
<ul role="presentation">
<li><a href="/?mime=application/json&indent">JSON</a></li>
<li><a href="/?mime=application/xml&indent">XML</a></li>
<li><a href="/?mime=application/yaml">YAML</a></li>
<li><a href="/?mime=text/html">HTML (This Page)</a></li>
</ul>
<!--
the following opens in a new tab/window/whatever.
the line after opens in the same tab/window/etc.
-->
<!--
<li role="presentation"><a href="https://r00t2.io/" target="_blank">r00t^2</a></li>
-->
<li role="presentation"><a href="https://r00t2.io/">r00t^2</a></li>
</ul>
</nav>
</div>
{{- end }}

95
server/tpl/usage.html.tpl Normal file
View File

@@ -0,0 +1,95 @@
{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}}
{{- define "usage" }}
{{- $page := . -}}
{{- $linkico := "🔗" }}
{{- template "meta.top" $page }}
<div class="jumbotron">
<h1>Usage</h1>
</div>
<h2 id="usage_params">Parameters<a href="#usage_params">{{ $linkico }}</a></h2>
<p>
You can control how the <a href="/">main page</a> displays/renders.
By default, it will try to "guess" what you want; e.g. if you access it in Chrome, it will return HTML but if you fetch via Curl, you'll get raw JSON
(or your specified data format; see below). If the classification of client can't be determined and an <code>Accept</code> wasn't specified,
a fallback to text-mode (by default <code>application/json</code>) will be returned.
<br/>
You can force a specific raw output by specifying the <a href="https://www.iana.org/assignments/media-types/media-types.xhtml">MIME type</a> via
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.1">the <code>Accept</code> header (RFC 9110 &sect; 12.5.1)</a>, which may be one of:
<ul>
<li><code>application/json</code> for <a href="https://www.rfc-editor.org/rfc/rfc8259.html">JSON</a></li>
<li><code>application/xml</code> for <a href="https://www.rfc-editor.org/rfc/rfc7303.html">XML</a></li>
<li><code>application/yaml</code> for <a href="https://www.rfc-editor.org/rfc/rfc9512.html">YAML</a></li>
<li><code>text/html</code> for <a href="https://www.rfc-editor.org/rfc/rfc2854.html">HTML</a></li>
</ul>
For example: <code>Accept: application/json</code> will return JSON.
<br/>
If unspecified and it is a text-mode client (e.g. Curl), the default is <code>application/json</code>.
<code>text/html</code> may be used to force an HTML response from a text-only client,
just as one of the <code>application/*</code> MIME types above may be used to force that "raw" text MIME type for a "graphical" browser client.
The specification as defined by <a href="https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.1">RFC 9110 &sect; 12.5.1</a> is completely
valid to pass and will be parsed without error (provided the header value is RFC-compliant and IANA-compliant),
though note that <code>application/xml</code> and <code>text/html</code>'s <code>charset</code> parameter will be entirely ignored;
the returned XML/HTML is <b>always</b> Unicode (with UTF-8 encoding).
<br/>
If no selectable MIME type is provided but an <code>Accept</code> was given, an error will be returned; specifically, a
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.7"><code>406</code> status code (RFC 9110 &sect; 15.5.7)</a>.
In this case, supported MIME types will be returned in the response's <code>Accept</code> header.
<br/>
Note that <a href="https://lynx.invisible-island.net/">Lynx</a> and <a href="http://elinks.or.cz/">Elinks</a> are considered "graphical"
browsers by this program as they are HTML-centric.
</p>
<p id="usage_params_mod">
The following parameters control/modify behavior.<a href="#usage_params_mod">{{ $linkico }}</a>
<ul>
<li>
<b>mime:</b> Specify an explicit MIME type via URL instead of the <code>Accept</code> header as specified above.
<ul>
<li>This should only be used by clients in which it is impossible or particularly cumbersome to modify/specify headers.
<code>Accept</code> is more performant.</li>
<li>Only the first supported instance of this parameter will be used.</li>
<li>Any of the defined MIME types above may be specified (e.g. <code>?mime=application/json</code>).</li>
<li>If both this URL query parameter and the <code>Accept</code> header is specified, the URL query takes preference.</li>
</ul>
</li>
<li>
<b>include:</b> Include a <code>&lt;code&gt;</code> (or <code>&lt;pre&gt;</code>, depending on if indentation is needed/requested) block in the HTML for the specified MIME type as well.</li>
<ul>
<li>Only the first supported instance of this parameter will be used.</li>
<li>
The value <b>must</b> conform to the same rules/specifications as the <code>mime</code> parameter/<code>Accept</code> header.
<ul>
<li><code>include</code> may <b>not</b> be <code>text/html</code>; it will be ignored if this is set. Just learn to <code>ctrl+u</code>.</li>
</ul>
</li>
<li>Only used if the evaluated return is HTML, ignored otherwise.</li>
<li>Indentation can be specified via the <b>indent</b> parameter below (since indentation is otherwise meaningless to HTML returns).</li>
</ul>
</li>
<li>
<b>indent:</b> Enable/specify indentation for JSON and XML output; ignored for others.
<ul>
<li>The default is to not indent. (Commonly referred to as "condensed" or "compressed" JSON/XML.)</li>
<li>Only the first specified instance of this parameter will be used.</li>
<li>If specified with a string value, use that string as each indent.
<ul>
<li>Be mindful of URL query parameter encoding,
per <a href="https://www.rfc-editor.org/rfc/rfc3986.html#section-3.4">RFC 3986 &sect; 3.4</a>
and <a href="https://www.rfc-editor.org/rfc/rfc8820.html#section-2.4">RFC 8820 &sect; 2.4</a></li>
<li>For quick reference and as an example, to indent with a <a href="https://asciiref.dev/#c9">tab</a>
(<code>\t</code>, <code>0x09</code>) for each level, use <code>?indent=%09</code></li>
</ul>
</li>
<li>If indentation is specified without any value (<code>?indent</code>), the default is two
<a href="https://asciiref.dev/#c32">spaces</a> (<code>0x20</code>); this would be represented
as <code>?indent=%20%20</code></li>
<li><code>?indent=</code> (no value specified) is equal to <code>?indent</code>.</li>
</ul>
</li>
</ul>
</p>
{{- template "meta.bottom" $page }}
{{- end }}