added JSON response for IPTables

This commit is contained in:
2023-09-27 15:27:25 +01:00
parent 6b287f2cf1
commit 7ed25ef4b3
2 changed files with 232 additions and 188 deletions

44
Bindings/Client.go Normal file
View File

@@ -0,0 +1,44 @@
package Bindings
import "C"
import (
"encoding/json"
"github.com/Akilan1999/p2p-rendering-computation/client"
)
// The Client package where data-types
// are manually converted to the
// to a string so that it can
// be export
//export StartContainer
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output string) {
container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage)
if err != nil {
return err.Error()
}
jsonBytes, err := json.Marshal(container)
if err != nil {
return err.Error()
}
// Convert the JSON bytes to a string
return string(jsonBytes)
}
//export GetSpecs
func GetSpecs(IP string) (output string) {
specs, err := client.GetSpecs(IP)
if err != nil {
return err.Error()
}
jsonBytes, err := json.Marshal(specs)
if err != nil {
return err.Error()
}
// Convert the JSON bytes to a string
return string(jsonBytes)
}