comments
This commit is contained in:
parent
cd284d1214
commit
5ca3917254
@ -17,36 +17,42 @@ type response struct {
|
|||||||
message string `json:"message"`
|
message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Proxy owns the interfaces for the pcsdk.
|
||||||
type Proxy struct {
|
type Proxy struct {
|
||||||
signing_key string
|
signing_key string
|
||||||
url netip.AddrPort
|
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 {
|
func BuildProxy(control netip.AddrPort) Proxy {
|
||||||
return Proxy {"", control}
|
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 {
|
func (p Proxy) Create(iport uint16, oport uint16, oip netip.Addr, id state.CustomUUID) error {
|
||||||
_, err := p.execute(create(iport, oport, oip, id))
|
_, err := p.execute(create(iport, oport, oip, id))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modify a tunnel with the given parameters.
|
||||||
func (p Proxy) Modify(oport uint16, oip netip.Addr, id state.CustomUUID) error {
|
func (p Proxy) Modify(oport uint16, oip netip.Addr, id state.CustomUUID) error {
|
||||||
_, err := p.execute(modify(oport, oip, id))
|
_, err := p.execute(modify(oport, oip, id))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete a tunnel with the given parameters.
|
||||||
func (p Proxy) Delete(id state.CustomUUID) error {
|
func (p Proxy) Delete(id state.CustomUUID) error {
|
||||||
_, err := p.execute(delete(id))
|
_, err := p.execute(delete(id))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: status function returning map of tunnels
|
||||||
|
// Status returns a list of tunnels for the given proxy.
|
||||||
func (p Proxy) Status() error {
|
func (p Proxy) Status() error {
|
||||||
_, err := p.execute(status())
|
_, err := p.execute(status())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: status function returning map of tunnels
|
|
||||||
|
|
||||||
func (p Proxy) execute(c command) (string, error) {
|
func (p Proxy) execute(c command) (string, error) {
|
||||||
data, err := json.Marshal(c)
|
data, err := json.Marshal(c)
|
||||||
|
Loading…
Reference in New Issue
Block a user