put JS code directly in index.html
This fixes a bug where the template parameters in the JS code were not being replaced with actual values.
This commit is contained in:
parent
6bbec77a83
commit
89efe5d18f
2
Makefile
2
Makefile
|
@ -17,7 +17,7 @@ check:
|
|||
golangci-lint run
|
||||
#go vet
|
||||
#go test
|
||||
find . -name '*.html' -exec xmllint --noout {} \;
|
||||
find . -name '*.html' ! -path './frontend/index.html' -exec xmllint --noout {} \;
|
||||
find . -name '*.html' -exec sh -c 'tidy -q -errors -access "{}" || ls "{}"' \;
|
||||
reuse lint -q
|
||||
|
||||
|
|
|
@ -120,6 +120,17 @@ SPDX-License-Identifier: BSD-3-Clause
|
|||
<a href="https://tildegit.org/nervuri/client-hello-mirror" target="_blank">Source</a> (contributions welcome)<br/>
|
||||
License: <a href="https://opensource.org/license/BSD-3-clause/" target="_blank">BSD-3-Clause</a>
|
||||
</footer>
|
||||
<script>{{.JS}}</script>
|
||||
<script>
|
||||
// Client-side check to see if the Client Hello's gmt_unix_time
|
||||
// corresponds to the system time. More accurate than the
|
||||
// server-side check.
|
||||
// The connection may have been slow, so allow gmt_unix_time to
|
||||
// be 60 seconds in the past.
|
||||
var gmtUnixTime = {{.GMTUnixTime}}
|
||||
var now = Math.round(Date.now() / 1000)
|
||||
if (now - 60 < gmtUnixTime && gmtUnixTime < now + 2) {
|
||||
document.getElementById('systime').innerHTML = '{{.SystemTimeExposedJS}}'
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
// Client-side check to see if the Client Hello's gmt_unix_time
|
||||
// corresponds to the system time. More accurate than the
|
||||
// server-side check.
|
||||
// The connection may have been slow, so allow gmt_unix_time to
|
||||
// be 60 seconds in the past.
|
||||
var gmtUnixTime = {{.GMTUnixTime}}
|
||||
var now = Math.round(Date.now() / 1000)
|
||||
if (now - 60 < gmtUnixTime && gmtUnixTime < now + 2) {
|
||||
document.getElementById('systime').innerHTML = '{{.SystemTimeExposedJS}}'
|
||||
}
|
|
@ -63,9 +63,6 @@ var htmlError string
|
|||
//go:embed frontend/style.css
|
||||
var css string
|
||||
|
||||
//go:embed frontend/script.js
|
||||
var js string
|
||||
|
||||
//go:embed frontend/index.gmi
|
||||
var gemtext string
|
||||
|
||||
|
@ -271,7 +268,6 @@ func requestHandler(conn *tls.Conn, rawClientHello []byte) {
|
|||
JA3MD5 string
|
||||
NJA3v1 htmlTemplate.HTML
|
||||
NJA3v1Hash string
|
||||
JS htmlTemplate.JS
|
||||
}{
|
||||
htmlTemplate.CSS(css),
|
||||
htmlTemplate.HTML(getTLSVersionHTML(connectionState.Version)),
|
||||
|
@ -293,7 +289,6 @@ func requestHandler(conn *tls.Conn, rawClientHello []byte) {
|
|||
hex.EncodeToString(clientHelloMsg.Highlights.JA3MD5),
|
||||
htmlTemplate.HTML(formatNJA3v1(clientHelloMsg.Highlights.NJA3v1)),
|
||||
hex.EncodeToString(clientHelloMsg.Highlights.NJA3v1Hash),
|
||||
htmlTemplate.JS(js),
|
||||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
|
Loading…
Reference in New Issue