mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 16:03:31 +00:00
removed golang project
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
# build Golang app for Linux
|
|
||||||
FROM golang:1.20
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# get gcc-multilib and gcc-mingw-w64
|
|
||||||
RUN apt update
|
|
||||||
RUN apt install -y gcc-multilib gcc-mingw-w64
|
|
||||||
|
|
||||||
CMD ["/bin/sh"]
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/indig0fox/a3go/a3interface"
|
|
||||||
)
|
|
||||||
|
|
||||||
func armatak_controller_get_uid(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
data string,
|
|
||||||
) (string, error) {
|
|
||||||
return armatak_service_get_uid()
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_args_get_uid(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
command string,
|
|
||||||
args []string,
|
|
||||||
) (string, error) {
|
|
||||||
return armatak_service_get_uid()
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_get_auth_token(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
command string,
|
|
||||||
) (string, error) {
|
|
||||||
return invalidCallExtensionMethod(": the auth informations must be provided")
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_args_get_auth_token(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
command string,
|
|
||||||
args []string,
|
|
||||||
) (string, error) {
|
|
||||||
sanitazeArgs(args)
|
|
||||||
|
|
||||||
return armatak_service_get_auth_token(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_post_marker(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
data string,
|
|
||||||
) (string, error) {
|
|
||||||
return invalidCallExtensionMethod(": post marker requires args")
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_args_post_marker(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
command string,
|
|
||||||
args []string,
|
|
||||||
) (string, error) {
|
|
||||||
sanitazeArgs(args)
|
|
||||||
|
|
||||||
return armatak_service_post_marker(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_post_marker_debug(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
data string,
|
|
||||||
) (string, error) {
|
|
||||||
return invalidCallExtensionMethod(": post marker requires args")
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_args_post_marker_debug(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
command string,
|
|
||||||
args []string,
|
|
||||||
) (string, error) {
|
|
||||||
sanitazeArgs(args)
|
|
||||||
|
|
||||||
return armatak_service_post_marker(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_delete_marker(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
data string,
|
|
||||||
) (string, error) {
|
|
||||||
return invalidCallExtensionMethod(": post marker requires args")
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_controller_args_delete_marker(
|
|
||||||
ctx a3interface.ArmaExtensionContext,
|
|
||||||
command string,
|
|
||||||
args []string,
|
|
||||||
) (string, error) {
|
|
||||||
sanitazeArgs(args)
|
|
||||||
|
|
||||||
return armatak_service_delete_marker(args)
|
|
||||||
}
|
|
||||||
BIN
extensions/armatak/dist/armatak.dll
LFS
vendored
BIN
extensions/armatak/dist/armatak.dll
LFS
vendored
Binary file not shown.
BIN
extensions/armatak/dist/armatak.so
vendored
BIN
extensions/armatak/dist/armatak.so
vendored
Binary file not shown.
BIN
extensions/armatak/dist/armatak_x64.dll
LFS
vendored
BIN
extensions/armatak/dist/armatak_x64.dll
LFS
vendored
Binary file not shown.
BIN
extensions/armatak/dist/armatak_x64.so
vendored
BIN
extensions/armatak/dist/armatak_x64.so
vendored
Binary file not shown.
@@ -1,8 +0,0 @@
|
|||||||
module armatak
|
|
||||||
|
|
||||||
go 1.20
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/google/uuid v1.6.0
|
|
||||||
github.com/indig0fox/a3go v0.3.2
|
|
||||||
)
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/indig0fox/a3go v0.3.2 h1:bNL90pffeOnS6Qtjoo5JHpdpZn1f0BZmRZR8nz/xcvQ=
|
|
||||||
github.com/indig0fox/a3go v0.3.2/go.mod h1:8htVwBiIAVKpT1Jyb+5dm7GuLAAevTXgw7UKxSlOawY=
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/indig0fox/a3go/a3interface"
|
|
||||||
)
|
|
||||||
|
|
||||||
var EXTENSION_NAME = "ARMATAK"
|
|
||||||
|
|
||||||
var a3ErrorChannel chan []string = make(chan []string)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Scanln()
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
a3interface.SetVersion("0.0.0")
|
|
||||||
a3interface.RegisterErrorChan(a3ErrorChannel)
|
|
||||||
|
|
||||||
a3interface.NewRegistration("get_uid").
|
|
||||||
SetDefaultResponse("getting uuid4").
|
|
||||||
SetRunInBackground(false).
|
|
||||||
SetFunction(armatak_controller_get_uid).
|
|
||||||
SetArgsFunction(armatak_controller_args_get_uid).
|
|
||||||
Register()
|
|
||||||
|
|
||||||
a3interface.NewRegistration("get_auth_token").
|
|
||||||
SetDefaultResponse("getting auth token").
|
|
||||||
SetRunInBackground(false).
|
|
||||||
SetFunction(armatak_controller_get_auth_token).
|
|
||||||
SetArgsFunction(armatak_controller_args_get_auth_token).
|
|
||||||
Register()
|
|
||||||
|
|
||||||
a3interface.NewRegistration("post_marker").
|
|
||||||
SetDefaultResponse("posting marker").
|
|
||||||
SetRunInBackground(true).
|
|
||||||
SetFunction(armatak_controller_post_marker).
|
|
||||||
SetArgsFunction(armatak_controller_args_post_marker).
|
|
||||||
Register()
|
|
||||||
|
|
||||||
a3interface.NewRegistration("post_marker_debug").
|
|
||||||
SetDefaultResponse("posting marker debug mode").
|
|
||||||
SetRunInBackground(false).
|
|
||||||
SetFunction(armatak_controller_post_marker_debug).
|
|
||||||
SetArgsFunction(armatak_controller_args_post_marker_debug).
|
|
||||||
Register()
|
|
||||||
|
|
||||||
a3interface.NewRegistration("delete_marker").
|
|
||||||
SetDefaultResponse("deleting marker").
|
|
||||||
SetRunInBackground(false).
|
|
||||||
SetFunction(armatak_controller_delete_marker).
|
|
||||||
SetArgsFunction(armatak_controller_args_delete_marker).
|
|
||||||
Register()
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
)
|
|
||||||
|
|
||||||
func armatak_service_get_uid() (string, error) {
|
|
||||||
return uuid.New().String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_service_get_auth_token(args []string) (string, error) {
|
|
||||||
authInfo := AuthInfo{
|
|
||||||
Username: args[1],
|
|
||||||
Password: args[2],
|
|
||||||
}
|
|
||||||
|
|
||||||
response, responseError := postRequestWithoutToken(args[0]+"/api/login?include_auth_token", authInfo)
|
|
||||||
|
|
||||||
if responseError != nil {
|
|
||||||
return "", responseError
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonString := string(response)
|
|
||||||
|
|
||||||
var data struct {
|
|
||||||
Meta struct{} `json:"meta"`
|
|
||||||
Response struct {
|
|
||||||
CSRFToken string `json:"csrf_token"`
|
|
||||||
User struct {
|
|
||||||
AuthenticationToken string `json:"authentication_token"`
|
|
||||||
} `json:"user"`
|
|
||||||
} `json:"response"`
|
|
||||||
}
|
|
||||||
|
|
||||||
err := json.Unmarshal([]byte(jsonString), &data)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
authToken := data.Response.User.AuthenticationToken
|
|
||||||
|
|
||||||
return authToken, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_service_post_marker(args []string) (string, error) {
|
|
||||||
marker, markerError := parseMarkerArgs(args)
|
|
||||||
|
|
||||||
if markerError != nil {
|
|
||||||
return "", markerError
|
|
||||||
}
|
|
||||||
|
|
||||||
response, responseError := postRequest(args[8]+"/api/markers?auth_token="+args[9], marker)
|
|
||||||
|
|
||||||
if responseError != nil {
|
|
||||||
return "", responseError
|
|
||||||
}
|
|
||||||
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func armatak_service_delete_marker(args []string) (string, error) {
|
|
||||||
marker, markerError := parseMarkerArgs(args)
|
|
||||||
|
|
||||||
if markerError != nil {
|
|
||||||
return "", markerError
|
|
||||||
}
|
|
||||||
|
|
||||||
response, responseError := deleteRequest(args[8]+"/api/markers?auth_token="+args[9], marker)
|
|
||||||
|
|
||||||
if responseError != nil {
|
|
||||||
return "", responseError
|
|
||||||
}
|
|
||||||
|
|
||||||
return response, nil
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
type Payload struct {
|
|
||||||
Content string `json:"content"`
|
|
||||||
Username string `json:"username,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Marker struct {
|
|
||||||
Longitude float64 `json:"longitude"`
|
|
||||||
Latitude float64 `json:"latitude"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
UID string `json:"uid"`
|
|
||||||
Type string `json:"type,omitempty"`
|
|
||||||
Course int `json:"course,omitempty"`
|
|
||||||
Azimuth int `json:"azimuth,omitempty"`
|
|
||||||
Speed int `json:"speed,omitempty"`
|
|
||||||
Battery int `json:"battery,omitempty"`
|
|
||||||
FOV int `json:"fov,omitempty"`
|
|
||||||
CE int `json:"ce,omitempty"`
|
|
||||||
HAE int `json:"hae,omitempty"`
|
|
||||||
LE int `json:"le,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Message struct {
|
|
||||||
Message string `json:"uid"`
|
|
||||||
Sender string `json:"sender"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthInfo struct {
|
|
||||||
Username string `json:"username"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/indig0fox/a3go/a3interface"
|
|
||||||
)
|
|
||||||
|
|
||||||
func sanitazeArgs(args []string) {
|
|
||||||
for i, v := range args {
|
|
||||||
args[i] = a3interface.RemoveEscapeQuotes(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func invalidCallExtensionMethod(complement string) (string, error) {
|
|
||||||
return "Invalid callExtension method" + complement, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseMarkerArgs(args []string) (Marker, error) {
|
|
||||||
sanitazeArgs(args)
|
|
||||||
|
|
||||||
latitude, latitudeError := strconv.ParseFloat(args[1], 32)
|
|
||||||
|
|
||||||
if latitudeError != nil {
|
|
||||||
return Marker{}, latitudeError
|
|
||||||
}
|
|
||||||
|
|
||||||
longitude, longitudeError := strconv.ParseFloat(args[2], 32)
|
|
||||||
|
|
||||||
if longitudeError != nil {
|
|
||||||
return Marker{}, longitudeError
|
|
||||||
}
|
|
||||||
|
|
||||||
speed, speedError := strconv.ParseFloat(args[3], 32)
|
|
||||||
|
|
||||||
if speedError != nil {
|
|
||||||
speed = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
bearing, bearingError := strconv.ParseFloat(args[4], 32)
|
|
||||||
|
|
||||||
if bearingError != nil {
|
|
||||||
bearing = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
altitude, altitudeError := strconv.ParseFloat(args[7], 32)
|
|
||||||
|
|
||||||
if altitudeError != nil {
|
|
||||||
altitude = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
marker := Marker{
|
|
||||||
UID: args[0],
|
|
||||||
Latitude: latitude,
|
|
||||||
Longitude: longitude,
|
|
||||||
Speed: int(speed / 4),
|
|
||||||
Course: int(bearing) + 6,
|
|
||||||
Type: args[5],
|
|
||||||
Name: args[6],
|
|
||||||
HAE: int(altitude),
|
|
||||||
}
|
|
||||||
|
|
||||||
return marker, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func postRequestWithoutToken(route string, body any) ([]byte, error) {
|
|
||||||
jsonData, err := json.Marshal(body)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error marshalling payload:", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
client := &http.Client{}
|
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, route, bytes.NewReader(jsonData))
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error creating request:", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error sending request:", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
fmt.Println("Error sending request:", resp.Status)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
parsedBody, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("getting Error reading response body: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (parsedBody), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func postRequest(route string, body any) (string, error) {
|
|
||||||
jsonData, err := json.Marshal(body)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error marshalling payload:", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
client := &http.Client{}
|
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, route, bytes.NewReader(jsonData))
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error creating request:", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error sending request:", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
fmt.Println("Error sending request:", resp.Status)
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
parsedBody, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("getting Error reading response body: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(parsedBody), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteRequest(route string, body any) (string, error) {
|
|
||||||
jsonData, err := json.Marshal(body)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error marshalling payload:", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
client := &http.Client{}
|
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodDelete, route, bytes.NewReader(jsonData))
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error creating request:", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error sending request:", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
fmt.Println("Error sending request:", resp.Status)
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
parsedBody, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("getting Error reading response body: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(parsedBody), nil
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user