mirror of
https://github.com/bettercap/bettercap
synced 2025-07-05 20:42:09 -07:00
new: gps.set to manually set/override gps coordinates (closes #915)
This commit is contained in:
parent
9d5c38c693
commit
7636ca2808
1 changed files with 19 additions and 0 deletions
|
@ -3,6 +3,7 @@ package gps
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/bettercap/bettercap/v2/session"
|
||||
|
@ -65,6 +66,24 @@ func NewGPS(s *session.Session) *GPS {
|
|||
return mod.Show()
|
||||
}))
|
||||
|
||||
mod.AddHandler(session.NewModuleHandler("gps.set LAT LON", `(?i)^gps\.set\s+([0-9\.]+)\s+([0-9\.]+)$`,
|
||||
"Manually set GPS location.",
|
||||
func(args []string) error {
|
||||
|
||||
if lat, err := strconv.ParseFloat(args[0], 64); err != nil {
|
||||
return err
|
||||
} else if lon, err := strconv.ParseFloat(args[1], 64); err != nil {
|
||||
return err
|
||||
} else {
|
||||
mod.Session.GPS.Updated = time.Now()
|
||||
mod.Session.GPS.Latitude = lat
|
||||
mod.Session.GPS.Longitude = lon
|
||||
mod.Session.Events.Add("gps.new", mod.Session.GPS)
|
||||
}
|
||||
|
||||
return nil
|
||||
}))
|
||||
|
||||
return mod
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue