more explanitory variable names (also matches rest of code)

This commit is contained in:
schulze 2023-05-03 14:13:06 +02:00
parent 75e5e991cd
commit 262ca61619

View File

@ -24,25 +24,25 @@ type Proxy struct {
} }
// BuildProxy creates a proxy struct for the given url to easily interact with that proxy instance (create, edit, delete tunnels etc) // 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(proxyIP netip.AddrPort) Proxy {
return Proxy {"", control} return Proxy {"", proxyIP}
} }
// Create a tunnel with the given parameters. // 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(entryPort uint16, servicePort uint16, serviceIP netip.Addr, serviceUUID state.CustomUUID) error {
_, err := p.execute(create(iport, oport, oip, id)) _, err := p.execute(create(entryPort, servicePort, serviceIP, serviceUUID))
return err return err
} }
// Modify a tunnel with the given parameters. // Modify a tunnel with the given parameters.
func (p Proxy) Modify(oport uint16, oip netip.Addr, id state.CustomUUID) error { func (p Proxy) Modify(servicePort uint16, serviceIP netip.Addr, serviceUUID state.CustomUUID) error {
_, err := p.execute(modify(oport, oip, id)) _, err := p.execute(modify(servicePort, serviceIP, serviceUUID))
return err return err
} }
// Delete a tunnel with the given parameters. // Delete a tunnel with the given parameters.
func (p Proxy) Delete(id state.CustomUUID) error { func (p Proxy) Delete(serviceUUID state.CustomUUID) error {
_, err := p.execute(delete(id)) _, err := p.execute(delete(serviceUUID))
return err return err
} }
@ -95,8 +95,8 @@ type commandCreate struct {
ID string `json:"id"` ID string `json:"id"`
} }
func create(iport uint16, oport uint16, oip netip.Addr, id state.CustomUUID) command { func create(entryPort uint16, servicePort uint16, serviceIP netip.Addr, serviceUUID state.CustomUUID) command {
cr:= commandCreate{iport, oport, oip, uuid.UUID.String(uuid.UUID(id))} cr:= commandCreate{entryPort, servicePort, serviceIP, uuid.UUID.String(uuid.UUID(serviceUUID))}
c:= command{} c:= command{}
c.Create = &cr c.Create = &cr
return c return c
@ -108,8 +108,8 @@ type commandModify struct {
ID string `json:"id"` ID string `json:"id"`
} }
func modify(oport uint16, oip netip.Addr, id state.CustomUUID) command { func modify(servicePort uint16, serviceIP netip.Addr, serviceUUID state.CustomUUID) command {
m:= commandModify{oport, oip, uuid.UUID.String(uuid.UUID(id))} m:= commandModify{servicePort, serviceIP, uuid.UUID.String(uuid.UUID(serviceUUID))}
c:= command{} c:= command{}
c.Modify = &m c.Modify = &m
return c return c
@ -119,8 +119,8 @@ type commandDelete struct {
ID string `json:"id"` ID string `json:"id"`
} }
func delete(id state.CustomUUID) command { func delete(serviceUUID state.CustomUUID) command {
d:= commandDelete{uuid.UUID.String(uuid.UUID(id))} d:= commandDelete{uuid.UUID.String(uuid.UUID(serviceUUID))}
c:= command{} c:= command{}
c.Delete = &d c.Delete = &d
return c return c