Configure cron to actually send to endpoint
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/pterodactyl/wings/internal/database"
|
||||
"github.com/xujiajun/nutsdb"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -17,6 +18,8 @@ const (
|
||||
ActivityConsoleCommand = Event("console_command")
|
||||
)
|
||||
|
||||
var ipTrimRegex = regexp.MustCompile(`(:\d*)?$`)
|
||||
|
||||
type Activity struct {
|
||||
// User is UUID of the user that triggered this event, or an empty string if the event
|
||||
// cannot be tied to a specific user, in which case we will assume it was the system
|
||||
@@ -89,6 +92,10 @@ func (a Activity) Save() error {
|
||||
a.Timestamp = time.Now().UTC()
|
||||
}
|
||||
|
||||
// Since the "RemoteAddr" field can often include a port on the end we need to
|
||||
// trim that off, otherwise it'll fail validation when sent to the Panel.
|
||||
a.IP = ipTrimRegex.ReplaceAllString(a.IP, "")
|
||||
|
||||
value, err := json.Marshal(a)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "database: failed to marshal activity into json bytes")
|
||||
|
||||
Reference in New Issue
Block a user