aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-04-27 14:19:33 -0400
committerXe Iaso <me@xeiaso.net>2025-04-27 14:19:33 -0400
commite047ce314d7ea8b6ec398c1cb633e60ea61f06dc (patch)
tree75a0eaa9ca72b0d7b1ac9324a4d352c5d99536d9 /cmd
parentc09d5139d13b785164c3651894c2859884f9393f (diff)
downloadx-master.tar.xz
x-master.zip
fix(relayd): increase correlation potentialHEADmaster
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/relayd/main.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/relayd/main.go b/cmd/relayd/main.go
index 8101778..f295990 100644
--- a/cmd/relayd/main.go
+++ b/cmd/relayd/main.go
@@ -125,6 +125,16 @@ func main() {
if err := db.Ping(); err != nil {
log.Fatal(err)
}
+
+ if _, err := db.Exec(`CREATE TABLE IF NOT EXISTS fingerprints
+ ( "application" TEXT
+ , "user_agent_string" TEXT
+ , "notes" TEXT
+ , "ja4_fingerprint" TEXT
+ , ip_address TEXT
+ )`); err != nil {
+ log.Fatal(err)
+ }
}
h := httputil.NewSingleHostReverseProxy(u)
@@ -180,7 +190,8 @@ func main() {
} else if errors.Is(err, sql.ErrNoRows) {
userAgent := req.UserAgent()
notes := fmt.Sprintf("Observed via relayd on host %s at %s", req.Host, time.Now().Format(time.RFC3339))
- if _, err := db.ExecContext(req.Context(), "INSERT INTO fingerprints(user_agent_string, notes, ja4_fingerprint) VALUES (?, ?, ?)", userAgent, notes, ja4); err != nil {
+ ip, _, _ := net.SplitHostPort(req.RemoteAddr)
+ if _, err := db.ExecContext(req.Context(), "INSERT INTO fingerprints(user_agent_string, notes, ja4_fingerprint, ip_address) VALUES (?, ?, ?, ?)", userAgent, notes, ja4, ip); err != nil {
slog.Error("can't insert fingerprint into database", "err", err)
}