Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add erase-guest-data command #268

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/tesla-control/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,4 +819,12 @@ var commands = map[string]*Command{
return nil
},
},
"erase-guest-data": &Command{
help: "Erase Guest Mode user data",
requiresAuth: true,
requiresFleetAPI: false,
handler: func(ctx context.Context, acct *account.Account, car *vehicle.Vehicle, args map[string]string) error {
return car.EraseGuestData(ctx)
},
},
}
2 changes: 2 additions & 0 deletions pkg/proxy/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ func ExtractCommandAction(ctx context.Context, command string, params RequestPar
return func(v *vehicle.Vehicle) error { return v.Lock(ctx) }, nil
case "door_unlock":
return func(v *vehicle.Vehicle) error { return v.Unlock(ctx) }, nil
case "erase_user_data":
return func(v *vehicle.Vehicle) error { return v.EraseGuestData(ctx) }, nil
case "reset_pin_to_drive_pin":
return func(v *vehicle.Vehicle) error { return v.ResetPIN(ctx) }, nil
case "reset_valet_pin":
Expand Down
11 changes: 11 additions & 0 deletions pkg/vehicle/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,14 @@ func (v *Vehicle) SendAddKeyRequestWithRole(ctx context.Context, publicKey *ecdh
}
return v.conn.Send(ctx, encodedEnvelope)
}

// EraseGuestData erases user data created while in Guest Mode. This command has no effect unless
// the vehicle is currently in Guest Mode.
func (v *Vehicle) EraseGuestData(ctx context.Context) error {
return v.executeCarServerAction(ctx,
&carserver.Action_VehicleAction{
VehicleAction: &carserver.VehicleAction{
VehicleActionMsg: &carserver.VehicleAction_EraseUserDataAction{},
},
})
}
Loading