Compare commits
3 Commits
v3.0.0
...
haskell-bi
| Author | SHA1 | Date | |
|---|---|---|---|
| ce7fa2ccf3 | |||
| 4115451875 | |||
| 3a40e687a5 |
@@ -3,6 +3,7 @@ package main
|
||||
import "C"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||
@@ -17,8 +18,8 @@ import (
|
||||
// --------------------------------- Container Control ----------------------------------------
|
||||
|
||||
//export StartContainer
|
||||
func StartContainer(IP string) (output *C.char) {
|
||||
container, err := abstractions.StartContainer(IP)
|
||||
func StartContainer(IP *C.char) (output *C.char) {
|
||||
container, err := abstractions.StartContainer(C.GoString(IP))
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
@@ -26,8 +27,8 @@ func StartContainer(IP string) (output *C.char) {
|
||||
}
|
||||
|
||||
//export RemoveContainer
|
||||
func RemoveContainer(IP string, ID string) (output *C.char) {
|
||||
err := abstractions.RemoveContainer(IP, ID)
|
||||
func RemoveContainer(IP *C.char, ID *C.char) (output *C.char) {
|
||||
err := abstractions.RemoveContainer(C.GoString(IP), C.GoString(ID))
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
@@ -76,8 +77,8 @@ func RemoveContainer(IP string, ID string) (output *C.char) {
|
||||
// --------------------------------- Get Specs ----------------------------------------
|
||||
|
||||
//export GetSpecs
|
||||
func GetSpecs(IP string) (output *C.char) {
|
||||
specs, err := abstractions.GetSpecs(IP)
|
||||
func GetSpecs(IP *C.char) (output *C.char) {
|
||||
specs, err := abstractions.GetSpecs(C.GoString(IP))
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
@@ -85,13 +86,12 @@ func GetSpecs(IP string) (output *C.char) {
|
||||
}
|
||||
|
||||
//export Init
|
||||
func Init(customConfig string) (output *C.char) {
|
||||
init, err := abstractions.Init(customConfig)
|
||||
func Init(customConfig *C.char) (output *C.char) {
|
||||
init, err := abstractions.Init(C.GoString(customConfig))
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return ConvertStructToJSONString(init)
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------- P2P Controls -----------------------------------
|
||||
@@ -115,9 +115,9 @@ func UpdateIPTable() (output *C.char) {
|
||||
}
|
||||
|
||||
//export EscapeFirewall
|
||||
func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internalPort string) (output *C.char) {
|
||||
func EscapeFirewall(HostOutsideNATIP *C.char, HostOutsideNATPort *C.char, internalPort *C.char) (output *C.char) {
|
||||
// Get free port from P2PRC server node
|
||||
serverPort, err := frp.GetFRPServerPort("http://" + HostOutsideNATIP + ":" + HostOutsideNATPort)
|
||||
serverPort, err := frp.GetFRPServerPort("http://" + C.GoString(HostOutsideNATIP) + ":" + C.GoString(HostOutsideNATPort))
|
||||
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
@@ -125,7 +125,7 @@ func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internal
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
ExposedPort, err := frp.StartFRPClientForServer(HostOutsideNATIP+":"+HostOutsideNATPort, serverPort, internalPort, "")
|
||||
ExposedPort, err := frp.StartFRPClientForServer(C.GoString(HostOutsideNATIP)+":"+C.GoString(HostOutsideNATPort), serverPort, C.GoString(internalPort), "")
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
@@ -134,8 +134,9 @@ func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internal
|
||||
}
|
||||
|
||||
//export MapPort
|
||||
func MapPort(Port string) *C.char {
|
||||
entireAddress, _, err := abstractions.MapPort(Port)
|
||||
func MapPort(Port *C.char) *C.char {
|
||||
fmt.Println(C.GoString(Port))
|
||||
entireAddress, _, err := abstractions.MapPort(C.GoString(Port))
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ USAGE:
|
||||
p2prc [global options] command [command options] [arguments...]
|
||||
|
||||
VERSION:
|
||||
<version no>
|
||||
2.0.0
|
||||
|
||||
COMMANDS:
|
||||
help, h Shows a list of commands or help for one command
|
||||
@@ -81,6 +81,7 @@ GLOBAL OPTIONS:
|
||||
--ViewImages value, --vi value View images available on the server IP address [$VIEW_IMAGES]
|
||||
--CreateVM value, --touch value Creates Docker container on the selected server [$CREATE_VM]
|
||||
--ContainerName value, --cn value Specifying the container run on the server side [$CONTAINER_NAME]
|
||||
--BaseImage value, --bi value Specifying the docker base image to template the dockerfile [$CONTAINER_NAME]
|
||||
--RemoveVM value, --rm value Stop and Remove Docker container (IP:port) accompanied by container ID via --ID or --id [$REMOVE_VM]
|
||||
--ID value, --id value Docker Container ID [$ID]
|
||||
--Ports value, -p value Number of ports to open for the Docker Container [$NUM_PORTS]
|
||||
@@ -96,10 +97,13 @@ GLOBAL OPTIONS:
|
||||
--Groups, --groups View all groups (default: false) [$GROUPS]
|
||||
--RemoveContainerGroup, --rmcgroup Remove specific container in the group (default: false) [$REMOVE_CONTAINER_GROUP]
|
||||
--RemoveGroup value, --rmgroup value Removes the entire group [$REMOVE_GROUP]
|
||||
--MAPPort value, --mp value Maps port for a specific port provided as the parameter [$MAPPORT]
|
||||
--DomainName value, --dn value While mapping ports allows to set a domain name to create a mapping in the proxy server [$DOMAINNAME]
|
||||
--Generate value, --gen value Generates a new copy of P2PRC which can be modified based on your needs [$GENERATE]
|
||||
--ModuleName value, --mod value New go project module name [$MODULENAME]
|
||||
--PullPlugin value, --pp value Pulls plugin from git repos [$PULLPLUGIN]
|
||||
--RemovePlugin value, --rp value Removes plugin [$REMOVEPLUGIN]
|
||||
--AddMetaData value, --amd value Adds metadata about the current node in the p2p network which is then propagated through the network [$ADDMETADATA]
|
||||
--help, -h show help (default: false)
|
||||
--version, -v print the version (default: false)
|
||||
|
||||
@@ -213,6 +217,11 @@ p2prc --rp <plugin name>
|
||||
p2prc --amd "custom metadata"
|
||||
```
|
||||
|
||||
### Map port
|
||||
```
|
||||
p2prc --mp <internal port no from your machine> --dn <domain name you want the port linked to>
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
--------------
|
||||
|
||||
Reference in New Issue
Block a user