A Go library for To connect easy and stable to PasarGuard-Node.
go get github.com/pasarguard/node_bridgepackage main
import (
"fmt""log""github.com/google/uuid""github.com/pasarguard/node_bridge""github.com/pasarguard/node_bridge/common"
)
funcmain() {
// Initialize the node clientapiKey:=uuid.New() // Replace with your actual API keynode, err:=node_bridge.New("127.0.0.1", node_bridge.GRPC,
node_bridge.WithPort(8080),
node_bridge.WithAPIKey(apiKey),
)
iferr!=nil {
log.Fatal(err)
}
// Start the node with a configurationconfig:=`{"inbounds": [], "outbounds": []}`// Your node configurationerr=node.Start(config, common.BackendType_XRAY, nil, 60)
iferr!=nil {
log.Fatal(err)
}
// Get node informationinfo, err:=node.Info()
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("Node Version: %s\n", info.NodeVersion)
fmt.Printf("Core Version: %s\n", info.CoreVersion)
// Get system statsstats, err:=node.GetSystemStats()
iferr==nil {
fmt.Printf("CPU Usage: %.2f%%\n", stats.CpuUsage)
}
}