From 5ca3917254a7317f72b9a801eeecca5b09287a21 Mon Sep 17 00:00:00 2001 From: schulze Date: Wed, 3 May 2023 14:06:19 +0200 Subject: [PATCH] comments --- pcsdk/commands.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pcsdk/commands.go b/pcsdk/commands.go index f9f0103..be153de 100644 --- a/pcsdk/commands.go +++ b/pcsdk/commands.go @@ -17,36 +17,42 @@ type response struct { message string `json:"message"` } +// Proxy owns the interfaces for the pcsdk. type Proxy struct { signing_key string url netip.AddrPort } +// BuildProxy creates a proxy struct for the given url to easily interact with that proxy instance (create, edit, delete tunnels etc) func BuildProxy(control netip.AddrPort) Proxy { return Proxy {"", control} } +// Create a tunnel with the given parameters. func (p Proxy) Create(iport uint16, oport uint16, oip netip.Addr, id state.CustomUUID) error { _, err := p.execute(create(iport, oport, oip, id)) return err } +// Modify a tunnel with the given parameters. func (p Proxy) Modify(oport uint16, oip netip.Addr, id state.CustomUUID) error { _, err := p.execute(modify(oport, oip, id)) return err } +// Delete a tunnel with the given parameters. func (p Proxy) Delete(id state.CustomUUID) error { _, err := p.execute(delete(id)) return err } +// TODO: status function returning map of tunnels +// Status returns a list of tunnels for the given proxy. func (p Proxy) Status() error { _, err := p.execute(status()) return err } -// TODO: status function returning map of tunnels func (p Proxy) execute(c command) (string, error) { data, err := json.Marshal(c)