in debug mode, disable https checking

This commit is contained in:
Ted Unangst 2020-05-13 17:00:34 -04:00
parent 4721226402
commit 8196f8b53e
3 changed files with 13 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package main
import (
"bytes"
"context"
"crypto/tls"
"database/sql"
"fmt"
"html"
@ -56,12 +57,23 @@ func friendorfoe(ct string) bool {
return false
}
var debugClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
func PostJunk(keyname string, key httpsig.PrivateKey, url string, j junk.Junk) error {
return PostMsg(keyname, key, url, j.ToBytes())
}
func PostMsg(keyname string, key httpsig.PrivateKey, url string, msg []byte) error {
client := http.DefaultClient
if debugMode {
client = debugClient
}
req, err := http.NewRequest("POST", url, bytes.NewReader(msg))
if err != nil {
return err

View File

@ -260,6 +260,7 @@ func main() {
}
getconfig("usersep", &userSep)
getconfig("honksep", &honkSep)
getconfig("debug", &debugMode)
prepareStatements(db)
switch cmd {
case "admin":

1
web.go
View File

@ -2357,7 +2357,6 @@ func serve() {
go bgmonitor()
w100 := wait100ms()
getconfig("debug", &debugMode)
readviews = templates.Load(debugMode,
viewDir+"/views/honkpage.html",
viewDir+"/views/honkfrags.html",