mirror of
https://github.com/PretendoNetwork/splatoon.git
synced 2026-03-21 17:45:08 -05:00
feat: Save pia connection reports to database
I would have liked to save the gathering info too but I couldn't work out how to extract that from MatchmakingManager you can kinda reverse-engineer it from the tracking logs anyway
This commit is contained in:
parent
8e52c6714c
commit
ef521aea15
10
init.go
10
init.go
|
|
@ -110,4 +110,14 @@ func init() {
|
|||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
globals.Logger.Success("Connected to Postgres!")
|
||||
|
||||
_, err = globals.Postgres.Exec(`CREATE TABLE IF NOT EXISTS reports (
|
||||
id bigserial PRIMARY KEY,
|
||||
ts timestamp,
|
||||
report_id integer,
|
||||
report bytea
|
||||
)`)
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,21 @@ import (
|
|||
"github.com/PretendoNetwork/splatoon/globals"
|
||||
)
|
||||
|
||||
func CreateReportDBRecord(_ *types.PID, _ *types.PrimitiveU32, _ *types.QBuffer) error {
|
||||
return nil
|
||||
// that's right boys it's a FACTORY METHOD IN GO LET'S GOOOO
|
||||
func fCreateReportDBRecord() func(*types.PID, *types.PrimitiveU32, *types.QBuffer) error {
|
||||
createReportStmt, err := globals.Postgres.Prepare(`INSERT INTO reports (ts, report_id, report) VALUES (NOW(), $1, $2)`)
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
}
|
||||
|
||||
return func(pid *types.PID, id *types.PrimitiveU32, report *types.QBuffer) error {
|
||||
if createReportStmt == nil {
|
||||
return nil // Just drop the report in case of DB error - no need to freak out the client with a reported err
|
||||
}
|
||||
|
||||
_, err := createReportStmt.Exec(id.Value, report.Value)
|
||||
return err // consider not reporting this error to the client
|
||||
}
|
||||
}
|
||||
|
||||
func stubGetPlayingSession(err error, packet nex.PacketInterface, callID uint32, _ *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) {
|
||||
|
|
@ -70,7 +83,7 @@ func registerCommonSecureServerProtocols() {
|
|||
globals.SecureEndpoint.RegisterServiceProtocol(secureProtocol)
|
||||
commonSecureProtocol := commonsecure.NewCommonProtocol(secureProtocol)
|
||||
|
||||
commonSecureProtocol.CreateReportDBRecord = CreateReportDBRecord
|
||||
commonSecureProtocol.CreateReportDBRecord = fCreateReportDBRecord()
|
||||
|
||||
natTraversalProtocol := nattraversal.NewProtocol()
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(natTraversalProtocol)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user