Compare commits

..

1 Commits

Author SHA1 Message Date
aoife cassidy
49bf74e692
add suspicious_hosts table to signups.sql 2025-11-22 12:44:16 +01:00
2 changed files with 15 additions and 4 deletions

View File

@ -9,12 +9,12 @@ import (
"log" "log"
"net" "net"
"os" "os"
"path"
"regexp" "regexp"
"slices" "slices"
"strings" "strings"
"time" "time"
"git.tilde.town/tildetown/town/external/lockingwriter"
"git.tilde.town/tildetown/town/models" "git.tilde.town/tildetown/town/models"
"git.tilde.town/tildetown/town/signup" "git.tilde.town/tildetown/town/signup"
"github.com/MakeNowJust/heredoc/v2" "github.com/MakeNowJust/heredoc/v2"
@ -25,6 +25,7 @@ import (
const ( const (
maxInputLength = 10000 maxInputLength = 10000
logDir = "/town/var/signups/log"
) )
type scene struct { type scene struct {
@ -147,8 +148,14 @@ func DigMX(raw string) (domains []string, err error) {
} }
func main() { func main() {
lw := lockingwriter.New() logFile := path.Join(logDir, fmt.Sprintf("%d", time.Now().Unix()))
logger := log.New(lw, "signup: ", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile|log.Lmsgprefix) logF, err := os.Create(logFile)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
logger := log.New(logF, "", log.Ldate|log.Ltime)
db, err := signup.ConnectDB() db, err := signup.ConnectDB()
if err != nil { if err != nil {
@ -235,7 +242,7 @@ func _main(l *log.Logger, db *sql.DB) error {
su.Email = string(s.Input.Bytes()) su.Email = string(s.Input.Bytes())
suspiciousHosts, err := models.SuspiciousHosts(db) suspiciousHosts, err := models.SuspiciousHosts(db)
if err != nil { if err != nil {
l.Println("could not connect to suspicious hosts db") // XXX: maybe log somewhere that the database failed
return return
} }
var shDomains []string var shDomains []string

View File

@ -29,4 +29,8 @@ CREATE TABLE IF NOT EXISTS notes (
CREATE TABLE IF NOT EXISTS suspicious_hosts ( CREATE TABLE IF NOT EXISTS suspicious_hosts (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
domain TEXT, domain TEXT,
-- unused but worth adding instead of another migration later
common_name TEXT,
tier INTEGER,
) )