tools

package
v0.0.0-...-2d054f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

* @author: mojtaba.eskandari@waziup.org Nov 25th 2019 * @A deamon to execute commands on host

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCommand

func ExecCommand(cmd string, withLogs bool) (out string, err error)

func GetIPAddr

func GetIPAddr() string

GetIPAddr returns the non loopback local IP of the container

func GetMACAddr

func GetMACAddr() (addr string)

GetMACAddr gets the MAC hardware address of the host machine from https://gist.github.com/rucuriousyet/ab2ab3dc1a339de612e162512be39283

func ReadAll

func ReadAll(rc io.ReadCloser) ([]byte, error)

func SendJSON

func SendJSON(resp http.ResponseWriter, obj interface{})

func SendPlainResponse

func SendPlainResponse(resp http.ResponseWriter, plain_response string)

func ServeHost

func ServeHost()

func SetRequestBody

func SetRequestBody(req *http.Request, body interface{})

func Shell

func Shell(dir string, sh string) (string, error)

func SockDeleteReqest

func SockDeleteReqest(API string) ([]byte, error)

SockDeleteReqest makes a DELETE request to a unix socket ex: SockDeleteReqest( "/var/run/wazigate-host.sock", "containers/waziup.wazigate-test")

func SockGetRequest

func SockGetRequest(API string) ([]byte, error)

SockGetRequest makes a GET request to a unix socket ex: SockGetRequest( "/var/run/wazigate-host.sock", "/")

func SockPostReqest

func SockPostReqest(socketAddr string, API string, postValues string) ([]byte, error)

SockPostReqest makes a POST request to a unix socket ex (post Request): SockPostReqest( "/var/run/wazigate-host.sock", "cmd", "ls -a")

func SocketReqest

func SocketReqest(url string, method string, contentType string, body io.Reader) (*http.Response, error)

SocketReqest makes a request to a unix socket

func Untar

func Untar(dst string, r io.Reader) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

Types

type ClosingBuffer

type ClosingBuffer struct {
	*bytes.Buffer
}

func (*ClosingBuffer) Close

func (cb *ClosingBuffer) Close() error

type RequestBodyContextKey

type RequestBodyContextKey struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL