compile success with go 1.16.4, large expansion uwu
This commit is contained in:
@@ -6,8 +6,6 @@ extern void goRVExtension(char *output, size_t outputSize, char *input);
|
||||
extern void goRVExtensionVersion(char *output, size_t outputSize);
|
||||
extern void goRVExtensionArgs(char *output, size_t outputSize, char *input, char **argv, int argc);
|
||||
extern void goRVExtensionRegisterCallback(extensionCallback fnc);
|
||||
// context is new
|
||||
extern void goRVExtensionContext(const char **argv, int argc);
|
||||
|
||||
#ifdef WIN64
|
||||
__declspec(dllexport) void RVExtension(char *output, size_t outputSize, char *input)
|
||||
@@ -29,12 +27,6 @@ __declspec(dllexport) void RVExtensionRegisterCallback(extensionCallback fnc)
|
||||
{
|
||||
goRVExtensionRegisterCallback(fnc);
|
||||
}
|
||||
|
||||
// context is new
|
||||
__declspec(dllexport) void RVExtensionContext(const char **argv, int argc)
|
||||
{
|
||||
goRVExtensionContext(argv, argc);
|
||||
}
|
||||
#else
|
||||
__declspec(dllexport) void __stdcall _RVExtension(char *output, size_t outputSize, char *input)
|
||||
{
|
||||
@@ -55,11 +47,15 @@ __declspec(dllexport) void __stdcall _RVExtensionRegisterCallback(extensionCallb
|
||||
{
|
||||
goRVExtensionRegisterCallback(fnc);
|
||||
}
|
||||
|
||||
// context is new
|
||||
__declspec(dllexport) void __stdcall _RVExtensionContext(const char **argv, int argc)
|
||||
{
|
||||
goRVExtensionContext(argv, argc);
|
||||
}
|
||||
#endif
|
||||
// do this for all the other exported functions
|
||||
// do this for all the other exported functions
|
||||
|
||||
// dll entrypoint
|
||||
// Path: RVExtension.c
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
362
arma.go
Normal file
362
arma.go
Normal file
@@ -0,0 +1,362 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "extensionCallback.h"
|
||||
*/
|
||||
import "C" // This is required to import the C code
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
)
|
||||
|
||||
var EXTENSION_VERSION string = "0.0.1"
|
||||
var extensionCallbackFnc C.extensionCallback
|
||||
var influxConnectionSettings influxSettings
|
||||
var a3Settings arma3Settings
|
||||
|
||||
// InfluxDB variables
|
||||
var DB_CLIENT influxdb2.Client
|
||||
|
||||
// file paths
|
||||
var ADDON_FOLDER string = "./@RangerMetrics"
|
||||
var LOG_FILE string = ADDON_FOLDER + "/rangermetrics.log"
|
||||
var SETTINGS_FILE string = ADDON_FOLDER + "/settings.json"
|
||||
|
||||
// configure log output
|
||||
func init() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
// log to file
|
||||
f, err := os.OpenFile(LOG_FILE, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening file: %v", err)
|
||||
}
|
||||
// log to console as well
|
||||
log.SetOutput(io.MultiWriter(f, os.Stdout))
|
||||
}
|
||||
|
||||
// func RVExtensionContext(output *C.char, argc *C.int) {
|
||||
|
||||
// }
|
||||
|
||||
type influxSettings struct {
|
||||
Host string `json:"host"`
|
||||
Token string `json:"token"`
|
||||
Org string `json:"org"`
|
||||
DefaultBucket string `json:"defaultBucket"`
|
||||
}
|
||||
|
||||
type arma3Settings struct {
|
||||
RefreshRateMs int `json:"refreshRateMs"`
|
||||
}
|
||||
|
||||
type settingsJson struct {
|
||||
Influx influxSettings `json:"influxdb"`
|
||||
Arma3 arma3Settings `json:"arma3"`
|
||||
}
|
||||
|
||||
func connectToInflux() string {
|
||||
if influxConnectionSettings.Host == "" {
|
||||
logLine("connectToInflux", `["influxConnectionSettings.Host is empty", "ERROR"]`)
|
||||
return "ERROR"
|
||||
}
|
||||
|
||||
DB_CLIENT = influxdb2.NewClientWithOptions(influxConnectionSettings.Host, influxConnectionSettings.Token, influxdb2.DefaultOptions().SetBatchSize(500).SetFlushInterval(2000))
|
||||
|
||||
logLine("connectToInflux", `["DB_CLIENT created", "INFO"]`)
|
||||
return "CONNECTED"
|
||||
}
|
||||
|
||||
func deinitialize() {
|
||||
logLine("deinitialize", `["deinitialize called", "INFO"]`)
|
||||
DB_CLIENT.Close()
|
||||
}
|
||||
|
||||
func getDir() string {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
func loadSettings() (dir string, result string, host string) {
|
||||
logLine("loadSettings", fmt.Sprintf(`["ADDON_FOLDER: %s", "INFO"]`, ADDON_FOLDER))
|
||||
logLine("loadSettings", fmt.Sprintf(`["LOG_FILE: %s", "INFO"]`, LOG_FILE))
|
||||
logLine("loadSettings", fmt.Sprintf(`["SETTINGS_FILE: %s", "INFO"]`, SETTINGS_FILE))
|
||||
|
||||
// print the current working directory
|
||||
var file *os.File
|
||||
var err error
|
||||
// read settings from file
|
||||
// settings.json should be in the same directory as the .dll
|
||||
// see if the file exists
|
||||
if _, err = os.Stat(SETTINGS_FILE); os.IsNotExist(err) {
|
||||
// file does not exist
|
||||
log.Println("settings.json does not exist")
|
||||
// create the file
|
||||
file, err = os.Create(SETTINGS_FILE)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
// write the default settings to the file
|
||||
ifSet := influxSettings{
|
||||
Host: "http://localhost:8086",
|
||||
Token: "my-token",
|
||||
Org: "my-org",
|
||||
DefaultBucket: "my-bucket",
|
||||
}
|
||||
a3Set := arma3Settings{
|
||||
RefreshRateMs: 1000,
|
||||
}
|
||||
defaultSettings := map[string]interface{}{
|
||||
"influxdb": ifSet,
|
||||
"arma3": a3Set,
|
||||
}
|
||||
encoder := json.NewEncoder(file)
|
||||
err = encoder.Encode(defaultSettings)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
result = `["settings.json created - please modify!", "WARN"]`
|
||||
host = ifSet.Host
|
||||
return dir, result, host
|
||||
} else {
|
||||
// file exists
|
||||
log.Println("settings.json exists")
|
||||
// read the file
|
||||
file, err = os.Open(SETTINGS_FILE)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
decoder := json.NewDecoder(file)
|
||||
var settings settingsJson
|
||||
err = decoder.Decode(&settings)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// set the settings
|
||||
influxConnectionSettings = settings.Influx
|
||||
a3Settings = settings.Arma3
|
||||
|
||||
// set the result
|
||||
result = `["settings.json loaded", "INFO"]`
|
||||
host = influxConnectionSettings.Host
|
||||
}
|
||||
|
||||
return dir, result, host
|
||||
}
|
||||
|
||||
func runExtensionCallback(name *C.char, function *C.char, data *C.char) C.int {
|
||||
return C.runExtensionCallback(extensionCallbackFnc, name, function, data)
|
||||
}
|
||||
|
||||
//export goRVExtensionVersion
|
||||
func goRVExtensionVersion(output *C.char, outputsize C.size_t) {
|
||||
result := C.CString(EXTENSION_VERSION)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
|
||||
//export goRVExtensionArgs
|
||||
func goRVExtensionArgs(output *C.char, outputsize C.size_t, input *C.char, argv **C.char, argc C.int) {
|
||||
var offset = unsafe.Sizeof(uintptr(0))
|
||||
var out []string
|
||||
for index := C.int(0); index < argc; index++ {
|
||||
out = append(out, C.GoString(*argv))
|
||||
argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
|
||||
}
|
||||
temp := fmt.Sprintf("Function: %s nb params: %d params: %s!", C.GoString(input), argc, out)
|
||||
|
||||
// Return a result to Arma
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
|
||||
if C.GoString(input) == "sendToInflux" {
|
||||
// start a goroutine to send the data to influx
|
||||
// param string is argv[0] which is the data to send to influx
|
||||
// go sendToInflux(out)
|
||||
go sendToInflux(&out)
|
||||
}
|
||||
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
|
||||
func callBackExample() {
|
||||
name := C.CString("arma")
|
||||
defer C.free(unsafe.Pointer(name))
|
||||
function := C.CString("funcToExecute")
|
||||
defer C.free(unsafe.Pointer(function))
|
||||
// Make a callback to Arma
|
||||
for i := 0; i < 3; i++ {
|
||||
time.Sleep(2 * time.Second)
|
||||
param := C.CString(fmt.Sprintf("Loop: %d", i))
|
||||
defer C.free(unsafe.Pointer(param))
|
||||
runExtensionCallback(name, function, param)
|
||||
}
|
||||
}
|
||||
|
||||
func getUnixTimeNano() int64 {
|
||||
// get the current unix timestamp in nanoseconds
|
||||
return time.Now().UnixNano()
|
||||
}
|
||||
|
||||
func trimQuotes(s string) string {
|
||||
// trim the start and end quotes from a string
|
||||
return strings.Trim(s, `"`)
|
||||
}
|
||||
|
||||
func fixEscapeQuotes(s string) string {
|
||||
// fix the escape quotes in a string
|
||||
return strings.Replace(s, `""`, `"`, -1)
|
||||
}
|
||||
|
||||
func sendToInflux(a3DataRaw *[]string) string {
|
||||
|
||||
// convert to string array
|
||||
a3Data := *a3DataRaw
|
||||
|
||||
var err error
|
||||
|
||||
logLine("sendToInflux", fmt.Sprintf(`["Received %d params", "DEBUG"]`, len(a3Data)))
|
||||
|
||||
MIN_PARAMS_COUNT := 1
|
||||
|
||||
var logData string
|
||||
functionName := "sendToInflux"
|
||||
|
||||
if len(a3Data) < MIN_PARAMS_COUNT {
|
||||
logData = fmt.Sprintf(`["Not all parameters present (got %d, expected at least %d)", "ERROR"]`, len(a3Data), MIN_PARAMS_COUNT)
|
||||
logLine(functionName, logData)
|
||||
return logData
|
||||
}
|
||||
|
||||
// use custom bucket or default
|
||||
var customBucket string = trimQuotes(string(a3Data[0]))
|
||||
bucket := influxConnectionSettings.DefaultBucket
|
||||
if customBucket != "" {
|
||||
bucket = customBucket
|
||||
}
|
||||
|
||||
WRITE_API := DB_CLIENT.WriteAPI(influxConnectionSettings.Org, bucket)
|
||||
|
||||
if WRITE_API == nil {
|
||||
logData = `["Error creating write API", "ERROR"]`
|
||||
logLine(functionName, logData)
|
||||
return logData
|
||||
}
|
||||
|
||||
// now we have our write client, we'll go through the rest of the receive array items in line protocol format and write them to influx
|
||||
for i := 1; i < len(a3Data); i++ {
|
||||
var p string = fixEscapeQuotes(trimQuotes(string(a3Data[i])))
|
||||
|
||||
WRITE_API.WriteRecord(p)
|
||||
|
||||
if err != nil {
|
||||
logData = fmt.Sprintf(`["Error parsing line protocol: %s", "ERROR"]`, err.Error())
|
||||
logLine(functionName, logData)
|
||||
return logData
|
||||
}
|
||||
}
|
||||
|
||||
// schedule cleanup
|
||||
WRITE_API.Flush()
|
||||
logData = fmt.Sprintf(`["Wrote %d lines to influx", "INFO"]`, len(a3Data)-1)
|
||||
logLine(functionName, logData)
|
||||
|
||||
return "Success"
|
||||
}
|
||||
|
||||
func logLine(functionName string, data string) {
|
||||
statusName := C.CString("RangerMetrics")
|
||||
defer C.free(unsafe.Pointer(statusName))
|
||||
statusFunction := C.CString(functionName)
|
||||
defer C.free(unsafe.Pointer(statusFunction))
|
||||
statusParam := C.CString(data)
|
||||
defer C.free(unsafe.Pointer(statusParam))
|
||||
runExtensionCallback(statusName, statusFunction, statusParam)
|
||||
|
||||
log.Println(data)
|
||||
}
|
||||
|
||||
//export goRVExtension
|
||||
func goRVExtension(output *C.char, outputsize C.size_t, input *C.char) {
|
||||
|
||||
var temp string
|
||||
|
||||
switch C.GoString(input) {
|
||||
case "version":
|
||||
logLine("goRVExtension", fmt.Sprintf(`["Input: %s", "INFO"]`, C.GoString(input)))
|
||||
temp = EXTENSION_VERSION
|
||||
case "getDir":
|
||||
logLine("goRVExtension", fmt.Sprintf(`["Input: %s", "INFO"]`, C.GoString(input)))
|
||||
temp = getDir()
|
||||
case "loadSettings":
|
||||
logLine("goRVExtension", fmt.Sprintf(`["Input: %s", "INFO"]`, C.GoString(input)))
|
||||
cwd, result, influxHost := loadSettings()
|
||||
log.Println("CWD:", cwd)
|
||||
log.Println("RESULT:", result)
|
||||
log.Println("INFLUX HOST:", influxHost)
|
||||
if result != "" {
|
||||
logLine("goRVExtension", result)
|
||||
temp = fmt.Sprintf(
|
||||
`["%s", "%s", "%s", "%s", "%d"]`,
|
||||
EXTENSION_VERSION,
|
||||
influxConnectionSettings.Host,
|
||||
influxConnectionSettings.Org,
|
||||
influxConnectionSettings.DefaultBucket,
|
||||
a3Settings.RefreshRateMs,
|
||||
)
|
||||
}
|
||||
case "connectToInflux":
|
||||
logLine("goRVExtension", fmt.Sprintf(`["Input: %s", "INFO"]`, C.GoString(input)))
|
||||
result := connectToInflux()
|
||||
temp = fmt.Sprintf(`["%s", "INFO"]`, result)
|
||||
case "getUnixTimeNano":
|
||||
temp = fmt.Sprintf(`["%d", "INFO"]`, getUnixTimeNano())
|
||||
case "deinitialize":
|
||||
logLine("goRVExtension", fmt.Sprintf(`["Input: %s", "INFO"]`, C.GoString(input)))
|
||||
deinitialize()
|
||||
temp = `["Deinitializing", "INFO"]`
|
||||
default:
|
||||
temp = fmt.Sprintf(`["Unknown command: %s", "ERR"]`, C.GoString(input))
|
||||
}
|
||||
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
// return
|
||||
}
|
||||
|
||||
//export goRVExtensionRegisterCallback
|
||||
func goRVExtensionRegisterCallback(fnc C.extensionCallback) {
|
||||
extensionCallbackFnc = fnc
|
||||
}
|
||||
|
||||
func main() {}
|
||||
312
arma.go.bk
312
arma.go.bk
@@ -1,312 +0,0 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "extensionCallback.h"
|
||||
*/
|
||||
import "C" // This is required to import the C code
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||
)
|
||||
|
||||
var EXTENSION_VERSION string = "0.0.1"
|
||||
var extensionCallbackFnc C.extensionCallback
|
||||
var influxConnectionSettings influxSettings
|
||||
|
||||
// configure log output
|
||||
func init() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
// log to file
|
||||
f, err := os.OpenFile("rangermetrics.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening file: %v", err)
|
||||
}
|
||||
// log to console as well
|
||||
log.SetOutput(io.MultiWriter(f, os.Stdout))
|
||||
}
|
||||
|
||||
// func RVExtensionContext(output *C.char, argc *C.int) {
|
||||
|
||||
// }
|
||||
|
||||
type influxSettings struct {
|
||||
Host string `json:"host"`
|
||||
Token string `json:"token"`
|
||||
Org string `json:"org"`
|
||||
Bucket string `json:"bucket"`
|
||||
}
|
||||
|
||||
func loadSettings() (dir string, result string, host string) {
|
||||
// print the current working directory
|
||||
|
||||
var file *os.File
|
||||
var err error
|
||||
dir, err = os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Println("getSettings", dir)
|
||||
// read settings from file
|
||||
// settings.json should be in the same directory as the .dll
|
||||
// see if the file exists
|
||||
if _, err = os.Stat("settings.json"); os.IsNotExist(err) {
|
||||
// file does not exist
|
||||
log.Println("settings.json does not exist")
|
||||
// create the file
|
||||
file, err = os.Create("settings.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
// write the default settings to the file
|
||||
defaultSettings := influxSettings{
|
||||
Host: "http://localhost:8086",
|
||||
Token: "my-token",
|
||||
Org: "my-org",
|
||||
Bucket: "my-bucket",
|
||||
}
|
||||
encoder := json.NewEncoder(file)
|
||||
err = encoder.Encode(defaultSettings)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
result = "settings.json created - please modify!"
|
||||
host = defaultSettings.Host
|
||||
return dir, result, host
|
||||
} else {
|
||||
// file exists
|
||||
log.Println("settings.json exists")
|
||||
// read the file
|
||||
file, err = os.Open("settings.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
decoder := json.NewDecoder(file)
|
||||
err = decoder.Decode(&influxConnectionSettings)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
result = "settings.json read"
|
||||
host = influxConnectionSettings.Host
|
||||
}
|
||||
|
||||
return dir, result, host
|
||||
}
|
||||
|
||||
func runExtensionCallback(name *C.char, function *C.char, data *C.char) C.int {
|
||||
return C.runExtensionCallback(extensionCallbackFnc, name, function, data)
|
||||
}
|
||||
|
||||
//aexport goRVExtensionVersion
|
||||
// func goRVExtensionVersion(output *C.char, outputsize C.size_t) {
|
||||
// return
|
||||
// result := C.CString(EXTENSION_VERSION)
|
||||
// defer C.free(unsafe.Pointer(result))
|
||||
// var size = C.strlen(result) + 1
|
||||
// if size > outputsize {
|
||||
// size = outputsize
|
||||
// }
|
||||
// C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
// }
|
||||
|
||||
//export goRVExtensionArgs
|
||||
// func goRVExtensionArgs(output *C.char, outputsize C.size_t, input *C.char, argv **C.char, argc C.int) {
|
||||
// return
|
||||
// var offset = unsafe.Sizeof(uintptr(0))
|
||||
// var out []string
|
||||
// for index := C.int(0); index < argc; index++ {
|
||||
// out = append(out, C.GoString(*argv))
|
||||
// argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
|
||||
// }
|
||||
// temp := fmt.Sprintf("Function: %s nb params: %d params: %s!", C.GoString(input), argc, out)
|
||||
|
||||
// // Return a result to Arma
|
||||
// result := C.CString(temp)
|
||||
// defer C.free(unsafe.Pointer(result))
|
||||
// var size = C.strlen(result) + 1
|
||||
// if size > outputsize {
|
||||
// size = outputsize
|
||||
// }
|
||||
|
||||
// if C.GoString(input) == "sendToInflux" {
|
||||
// // start a goroutine to send the data to influx
|
||||
// // param string is argv[0] which is the data to send to influx
|
||||
// go sendToInflux(out)
|
||||
// }
|
||||
|
||||
// C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
// // return 1
|
||||
// }
|
||||
|
||||
func callBackExample() {
|
||||
name := C.CString("arma")
|
||||
defer C.free(unsafe.Pointer(name))
|
||||
function := C.CString("funcToExecute")
|
||||
defer C.free(unsafe.Pointer(function))
|
||||
// Make a callback to Arma
|
||||
for i := 0; i < 3; i++ {
|
||||
time.Sleep(2 * time.Second)
|
||||
param := C.CString(fmt.Sprintf("Loop: %d", i))
|
||||
defer C.free(unsafe.Pointer(param))
|
||||
runExtensionCallback(name, function, param)
|
||||
}
|
||||
}
|
||||
|
||||
func sanitize(s string) string {
|
||||
t := strings.ReplaceAll(s, "\"", "")
|
||||
return t
|
||||
}
|
||||
|
||||
func sendToInflux(a3Data []string) {
|
||||
EXPECTED_PARAMS := 8
|
||||
|
||||
var logData string
|
||||
functionName := "sendToInflux"
|
||||
|
||||
if len(a3Data) < EXPECTED_PARAMS {
|
||||
logData = fmt.Sprintf(`["Not all parameters present (got %d, expected %d)", "ERROR"]`, len(a3Data), EXPECTED_PARAMS)
|
||||
logLine(functionName, logData, "ERROR")
|
||||
return
|
||||
}
|
||||
|
||||
// sanitize all elements
|
||||
for i, v := range a3Data {
|
||||
a3Data[i] = sanitize(v)
|
||||
}
|
||||
|
||||
host := influxConnectionSettings.Host
|
||||
token := influxConnectionSettings.Token
|
||||
org := influxConnectionSettings.Org
|
||||
bucket := influxConnectionSettings.Bucket
|
||||
profile, locality := a3Data[0], a3Data[1]
|
||||
missionName, worldName, serverName := a3Data[2], a3Data[3], a3Data[4]
|
||||
metric := a3Data[5]
|
||||
valueType := a3Data[6]
|
||||
|
||||
tags := map[string]string{
|
||||
"profile": profile,
|
||||
"locality": locality,
|
||||
"worldName": worldName,
|
||||
"serverName": serverName,
|
||||
}
|
||||
fields := map[string]interface{}{
|
||||
"missionName": missionName,
|
||||
// "count": value,
|
||||
}
|
||||
|
||||
// parse the value
|
||||
var err error
|
||||
// allow for float or int values, but remove any auto backslashes
|
||||
// check if includes certain strings
|
||||
if strings.Contains(valueType, "float") {
|
||||
fields["count"], err = strconv.ParseFloat(sanitize(a3Data[7]), 64)
|
||||
} else if strings.Contains(valueType, "int") {
|
||||
fields["count"], err = strconv.Atoi(sanitize(a3Data[7]))
|
||||
} else {
|
||||
logData = fmt.Sprintf("valueType must be 'float' or 'int': %s, %s, %s", metric, valueType, a3Data[7])
|
||||
logLine(functionName, logData, "ERROR")
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logData = fmt.Sprintf("Error parsing value: %s", err.Error())
|
||||
logLine(functionName, logData, "ERROR")
|
||||
return
|
||||
}
|
||||
|
||||
// influxDB init
|
||||
client := influxdb2.NewClientWithOptions(host, token, influxdb2.DefaultOptions().SetBatchSize(120))
|
||||
writeAPI := client.WriteAPIBlocking(org, bucket)
|
||||
|
||||
p := influxdb2.NewPoint(metric, tags, fields, time.Now())
|
||||
|
||||
// write synchronously
|
||||
err = writeAPI.WritePoint(context.Background(), p)
|
||||
|
||||
if err != nil {
|
||||
logData = fmt.Sprintf("Error writing to InfluxDB: %s", err.Error())
|
||||
logLine(functionName, logData, "ERROR")
|
||||
}
|
||||
|
||||
defer client.Close()
|
||||
|
||||
logData = fmt.Sprintf("Sent to Influx: %s, %s", metric, a3Data[7])
|
||||
logLine(functionName, logData, "INFO")
|
||||
}
|
||||
|
||||
func logLine(functionName string, data string, resultType string) {
|
||||
statusName := C.CString("RangerMetrics")
|
||||
defer C.free(unsafe.Pointer(statusName))
|
||||
statusFunction := C.CString(functionName)
|
||||
defer C.free(unsafe.Pointer(statusFunction))
|
||||
statusParam := C.CString(fmt.Sprintf(`["%s", "%s"]`, data, resultType))
|
||||
defer C.free(unsafe.Pointer(statusParam))
|
||||
runExtensionCallback(statusName, statusFunction, statusParam)
|
||||
|
||||
log.Println(data)
|
||||
}
|
||||
|
||||
//export goRVExtension
|
||||
func goRVExtension(output *C.char, outputsize C.size_t, input *C.char) {
|
||||
temp := fmt.Sprintf("Hello %s!", C.GoString(input))
|
||||
// Return a result to Arma
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
|
||||
// var temp string
|
||||
|
||||
// logLine("goRVExtension", fmt.Sprintf("Input: %s", C.GoString(input)), "INFO")
|
||||
|
||||
// switch C.GoString(input) {
|
||||
// case "version":
|
||||
// temp = fmt.Sprintf("%s", EXTENSION_VERSION)
|
||||
// case "loadSettings":
|
||||
// cwd, result, influxHost := loadSettings()
|
||||
// log.Println("CWD:", cwd)
|
||||
// log.Println("RESULT:", result)
|
||||
// log.Println("INFLUX HOST:", influxHost)
|
||||
// if result != "" {
|
||||
// temp = fmt.Sprintf(`["CWD: %s", "RESULT: %s", "%s"]`, cwd, result, influxHost)
|
||||
// }
|
||||
// default:
|
||||
// temp = fmt.Sprintf(`["ERR", "Unknown command: %s", "ERR"]`, C.GoString(input))
|
||||
// }
|
||||
|
||||
// result := C.CString(temp)
|
||||
// defer C.free(unsafe.Pointer(result))
|
||||
// var size = C.strlen(result) + 1
|
||||
// if size > outputsize {
|
||||
// size = outputsize
|
||||
// }
|
||||
|
||||
// C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
// return
|
||||
}
|
||||
|
||||
//aexport goRVExtensionRegisterCallback
|
||||
// func goRVExtensionRegisterCallback(fnc C.extensionCallback) {
|
||||
// return
|
||||
// extensionCallbackFnc = fnc
|
||||
// }
|
||||
|
||||
func main() {}
|
||||
BIN
basictest.a
BIN
basictest.a
Binary file not shown.
104
basictest.go
104
basictest.go
@@ -1,104 +0,0 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extensionCallback.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var extensionCallbackFnc C.extensionCallback
|
||||
|
||||
func runExtensionCallback(name *C.char, function *C.char, data *C.char) C.int {
|
||||
return C.runExtensionCallback(extensionCallbackFnc, name, function, data)
|
||||
}
|
||||
|
||||
//export goRVExtensionVersion
|
||||
func goRVExtensionVersion(output *C.char, outputsize C.size_t) {
|
||||
result := C.CString("Version 1.0")
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
|
||||
//export goRVExtensionContext
|
||||
func goRVExtensionContext(argv **C.char, argc C.int) {
|
||||
var offset = unsafe.Sizeof(uintptr(0))
|
||||
var out []string
|
||||
for index := C.int(0); index < argc; index++ {
|
||||
out = append(out, C.GoString(*argv))
|
||||
argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
|
||||
}
|
||||
fmt.Printf("Context: %s", out)
|
||||
C.memmove(unsafe.Pointer(argv), unsafe.Pointer(&out), C.size_t(offset))
|
||||
}
|
||||
|
||||
//export goRVExtensionArgs
|
||||
func goRVExtensionArgs(output *C.char, outputsize C.size_t, input *C.char, argv **C.char, argc C.int) {
|
||||
var offset = unsafe.Sizeof(uintptr(0))
|
||||
var out []string
|
||||
for index := C.int(0); index < argc; index++ {
|
||||
out = append(out, C.GoString(*argv))
|
||||
argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
|
||||
}
|
||||
temp := fmt.Sprintf("Function: %s nb params: %d params: %s!", C.GoString(input), argc, out)
|
||||
|
||||
// Return a result to Arma
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
|
||||
func callBackExample() {
|
||||
name := C.CString("armago")
|
||||
defer C.free(unsafe.Pointer(name))
|
||||
function := C.CString("funcToExecute")
|
||||
defer C.free(unsafe.Pointer(function))
|
||||
// Make a callback to Arma
|
||||
for i := 0; i < 3; i++ {
|
||||
time.Sleep(2 * time.Second)
|
||||
param := C.CString(fmt.Sprintf("Loop: %d", i))
|
||||
defer C.free(unsafe.Pointer(param))
|
||||
runExtensionCallback(name, function, param)
|
||||
}
|
||||
}
|
||||
|
||||
//export goRVExtension
|
||||
func goRVExtension(output *C.char, outputsize C.size_t, input *C.char) {
|
||||
// Return by default through ExtensionCallback arma handler the result
|
||||
if extensionCallbackFnc != nil {
|
||||
go callBackExample()
|
||||
} else {
|
||||
// Return a result through callextension Arma call
|
||||
temp := fmt.Sprintf("Hello %s!", C.GoString(input))
|
||||
result := C.CString(temp)
|
||||
defer C.free(unsafe.Pointer(result))
|
||||
var size = C.strlen(result) + 1
|
||||
if size > outputsize {
|
||||
size = outputsize
|
||||
}
|
||||
C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
|
||||
}
|
||||
}
|
||||
|
||||
//export goRVExtensionRegisterCallback
|
||||
func goRVExtensionRegisterCallback(fnc C.extensionCallback) {
|
||||
extensionCallbackFnc = fnc
|
||||
}
|
||||
|
||||
func main() {}
|
||||
94
basictest.h
94
basictest.h
@@ -1,94 +0,0 @@
|
||||
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
||||
|
||||
/* package command-line-arguments */
|
||||
|
||||
|
||||
#line 1 "cgo-builtin-export-prolog"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
||||
#define GO_CGO_EXPORT_PROLOGUE_H
|
||||
|
||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
||||
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Start of preamble from import "C" comments. */
|
||||
|
||||
|
||||
#line 3 "basictest.go"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extensionCallback.h"
|
||||
|
||||
#line 1 "cgo-generated-wrapper"
|
||||
|
||||
|
||||
/* End of preamble from import "C" comments. */
|
||||
|
||||
|
||||
/* Start of boilerplate cgo prologue. */
|
||||
#line 1 "cgo-gcc-export-header-prolog"
|
||||
|
||||
#ifndef GO_CGO_PROLOGUE_H
|
||||
#define GO_CGO_PROLOGUE_H
|
||||
|
||||
typedef signed char GoInt8;
|
||||
typedef unsigned char GoUint8;
|
||||
typedef short GoInt16;
|
||||
typedef unsigned short GoUint16;
|
||||
typedef int GoInt32;
|
||||
typedef unsigned int GoUint32;
|
||||
typedef long long GoInt64;
|
||||
typedef unsigned long long GoUint64;
|
||||
typedef GoInt64 GoInt;
|
||||
typedef GoUint64 GoUint;
|
||||
typedef size_t GoUintptr;
|
||||
typedef float GoFloat32;
|
||||
typedef double GoFloat64;
|
||||
#ifdef _MSC_VER
|
||||
#include <complex.h>
|
||||
typedef _Fcomplex GoComplex64;
|
||||
typedef _Dcomplex GoComplex128;
|
||||
#else
|
||||
typedef float _Complex GoComplex64;
|
||||
typedef double _Complex GoComplex128;
|
||||
#endif
|
||||
|
||||
/*
|
||||
static assertion to make sure the file is being used on architecture
|
||||
at least with matching size of GoInt.
|
||||
*/
|
||||
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
||||
|
||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
||||
typedef _GoString_ GoString;
|
||||
#endif
|
||||
typedef void *GoMap;
|
||||
typedef void *GoChan;
|
||||
typedef struct { void *t; void *v; } GoInterface;
|
||||
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
||||
|
||||
#endif
|
||||
|
||||
/* End of boilerplate cgo prologue. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern __declspec(dllexport) void RVExtensionVersion(char* output, size_t outputsize);
|
||||
extern __declspec(dllexport) void RVExtensionContext(char** argv, int argc);
|
||||
extern __declspec(dllexport) void RVExtensionArgs(char* output, size_t outputsize, char* input, char** argv, int argc);
|
||||
extern __declspec(dllexport) void RVExtension(char* output, size_t outputsize, char* input);
|
||||
extern __declspec(dllexport) void RVExtensionRegisterCallback(extensionCallback fnc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
||||
|
||||
/* package arma.go */
|
||||
|
||||
|
||||
#line 1 "cgo-builtin-export-prolog"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
||||
#define GO_CGO_EXPORT_PROLOGUE_H
|
||||
|
||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
||||
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Start of preamble from import "C" comments. */
|
||||
|
||||
|
||||
#line 3 "basictest.go"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "extensionCallback.h"
|
||||
|
||||
#line 1 "cgo-generated-wrapper"
|
||||
|
||||
|
||||
/* End of preamble from import "C" comments. */
|
||||
|
||||
|
||||
/* Start of boilerplate cgo prologue. */
|
||||
#line 1 "cgo-gcc-export-header-prolog"
|
||||
|
||||
#ifndef GO_CGO_PROLOGUE_H
|
||||
#define GO_CGO_PROLOGUE_H
|
||||
|
||||
typedef signed char GoInt8;
|
||||
typedef unsigned char GoUint8;
|
||||
typedef short GoInt16;
|
||||
typedef unsigned short GoUint16;
|
||||
typedef int GoInt32;
|
||||
typedef unsigned int GoUint32;
|
||||
typedef long long GoInt64;
|
||||
typedef unsigned long long GoUint64;
|
||||
typedef GoInt64 GoInt;
|
||||
typedef GoUint64 GoUint;
|
||||
typedef size_t GoUintptr;
|
||||
typedef float GoFloat32;
|
||||
typedef double GoFloat64;
|
||||
#ifdef _MSC_VER
|
||||
#include <complex.h>
|
||||
typedef _Fcomplex GoComplex64;
|
||||
typedef _Dcomplex GoComplex128;
|
||||
#else
|
||||
typedef float _Complex GoComplex64;
|
||||
typedef double _Complex GoComplex128;
|
||||
#endif
|
||||
|
||||
/*
|
||||
static assertion to make sure the file is being used on architecture
|
||||
at least with matching size of GoInt.
|
||||
*/
|
||||
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
||||
|
||||
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
||||
typedef _GoString_ GoString;
|
||||
#endif
|
||||
typedef void *GoMap;
|
||||
typedef void *GoChan;
|
||||
typedef struct { void *t; void *v; } GoInterface;
|
||||
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
||||
|
||||
#endif
|
||||
|
||||
/* End of boilerplate cgo prologue. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern __declspec(dllexport) void goRVExtensionVersion(char* output, size_t outputsize);
|
||||
extern __declspec(dllexport) void goRVExtensionContext(char** argv, int argc);
|
||||
extern __declspec(dllexport) void goRVExtensionArgs(char* output, size_t outputsize, char* input, char** argv, int argc);
|
||||
extern __declspec(dllexport) void goRVExtension(char* output, size_t outputsize, char* input);
|
||||
extern __declspec(dllexport) void goRVExtensionRegisterCallback(extensionCallback fnc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
20
build.txt
20
build.txt
@@ -1,13 +1,19 @@
|
||||
$ENV:GOARCH = "amd64"
|
||||
$ENV:CGO_ENABLED = 1
|
||||
# # $ENV:CC = "C:`\Program Files (x86)`\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe"
|
||||
go build -o RangerMetrics_x64.dll -buildmode=c-shared .
|
||||
go build -buildmode=c-shared .
|
||||
go1.16.4 build -o RangerMetrics_x64.dll -buildmode=c-shared .
|
||||
|
||||
# THIS ONE WORKS
|
||||
$ENV:GOARCH = "amd64"
|
||||
$ENV:CGO_ENABLED = 1
|
||||
go1.16.4 build -o RangerMetrics_x64.dll -buildmode=c-shared .
|
||||
|
||||
|
||||
. "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\dumpbin.exe" /exports .\RangerMetrics_x64.dll
|
||||
|
||||
|
||||
go build -buildmode=c-archive basictest.go
|
||||
gcc -shared -pthread -o basictest_x64.dll RVExtension.c basictest.a
|
||||
gcc -shared -W -c -c -c -o basictest_x64.dll RVExtension.c bases -Wl, --subsystem -Wl, windows -Wl, --inable-ctdcall-fixuptes -Wl, --subsystem -Wl, windows -Wl, --enable-stdcall-fixupt.a -Wl, --subsystem -Wl, windows -Wl, --enable-stdcall-fixup
|
||||
|
||||
g++ -o test -l mingw32 RVExtension.c .\RangerMetrics_x64.dll
|
||||
|
||||
@@ -26,8 +32,8 @@ gcc -shared -pthread -o basictest_x64.dll -fPIC RVExtension.c basictest.a
|
||||
|
||||
$ENV:GOARCH = "amd64"
|
||||
$ENV:CGO_ENABLED = 1
|
||||
go build -buildmode=c-archive basictest_x64.go
|
||||
gcc -shared -pthread -o basictest_x64.dll -fPIC RVExtension.c basictest_x64.a
|
||||
go build -buildmode=c-archive basictest.go
|
||||
. "C:\TDM-GCC-64-9.2.0\bin\gcc.exe" -shared -pthread -o basictest_x64.dll RVExtension.c basictest.a
|
||||
|
||||
$ENV:GOARCH = 386
|
||||
$ENV:CGO_ENABLED = 1
|
||||
@@ -36,5 +42,7 @@ go build -o basictest.dll -buildmode=c-shared .
|
||||
|
||||
$ENV:GOARCH = "amd64"
|
||||
$ENV:CGO_ENABLED = 1
|
||||
go build -o basictest_x64.dll -buildmode=c-shared basictest.go
|
||||
$ENV:GOOS = "windows"
|
||||
$ENV:CC = "x86_64-w64-mingw32-gcc"
|
||||
go build -o basictest_x64.dll -buildmode=c-shared .
|
||||
. "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\dumpbin.exe" /exports .\basictest_x64.dll
|
||||
6
go.mod
6
go.mod
@@ -1,5 +1,5 @@
|
||||
module arma.go
|
||||
module main
|
||||
|
||||
go 1.20
|
||||
go 1.16
|
||||
|
||||
require github.com/influxdata/influxdb-client-go/v2 v2.12.3
|
||||
require github.com/influxdata/influxdb-client-go/v2 v2.6.0
|
||||
|
||||
33
go.sum
33
go.sum
@@ -1,6 +1,5 @@
|
||||
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/deepmap/oapi-codegen v1.8.2 h1:SegyeYGcdi0jLLrpbCMoJxnUUn8GBXHsvr4rbzjuhfU=
|
||||
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
|
||||
@@ -12,8 +11,8 @@ github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.12.3 h1:28nRlNMRIV4QbtIUvxhWqaxn0IpXeMSkY/uJa/O/vC4=
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.12.3/go.mod h1:IrrLUbCjjfkmRuaCiGQg4m2GbkaeJDcuWoxiWdQEbA0=
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.6.0 h1:bIOaGTgvvv1Na2hG+nIvqyv7PK2UiU2WrJN1ck1ykyM=
|
||||
github.com/influxdata/influxdb-client-go/v2 v2.6.0/go.mod h1:Y/0W1+TZir7ypoQZYd2IrnVOKB3Tq6oegAQeSVN/+EU=
|
||||
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU=
|
||||
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -33,36 +32,24 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -74,30 +61,18 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
31
testsqf.sqf
31
testsqf.sqf
@@ -1,25 +1,18 @@
|
||||
// freeExtension "RangerMetrics";
|
||||
freeExtension "RangerMetrics";
|
||||
// sleep 0.5;
|
||||
// "RangerMetrics" callExtension "loadSettings";
|
||||
// sleep 0.5;
|
||||
// "RangerMetrics" callextension "version";
|
||||
// sleep 1.5;
|
||||
// "RangerMetrics" callExtension ["sendToInflux", ["myProfile","global","TestMission123","Altis","TestingServer","units.count","int","22"]];
|
||||
"RangerMetrics" callExtension "loadSettings";
|
||||
|
||||
// sleep 12;
|
||||
// sleep 3;
|
||||
// "RangerMetrics" callExtension "version";
|
||||
// sleep 3;
|
||||
// "RangerMetrics" callExtension "connectToInflux";
|
||||
// // sleep 3;
|
||||
// // sleep 100;
|
||||
// "RangerMetrics" callExtension ["sendToInflux", ["server","mission_name","string","tag|profile|IndigoFox","tag|world|altis","tag|source|onLoadName","field|server|IndigoFox on DESKTOP-6B2U0AT","field|mission|aarangermetricstesting","field|value|mission_name"]];
|
||||
|
||||
sleep 30;
|
||||
// freeExtension "RangerMetrics";
|
||||
|
||||
|
||||
freeExtension "basictest";
|
||||
sleep 0.5;
|
||||
"basictest" callExtension "loadSettings";
|
||||
sleep 0.5;
|
||||
"basictest" callextension "version";
|
||||
sleep 1.5;
|
||||
"basictest" callExtension ["sendToInflux", ["myProfile","global","TestMission123","Altis","TestingServer","units.count","int","22"]];
|
||||
|
||||
sleep 12;
|
||||
freeExtension "basictest";
|
||||
|
||||
// sleep 15;
|
||||
// exit;
|
||||
exit;
|
||||
Reference in New Issue
Block a user