Make forward type and target public

This commit is contained in:
timoxa0 2024-06-14 15:56:58 +05:00
parent 627bfc67be
commit 2d9cf39596

View file

@ -6,34 +6,34 @@ import (
"github.com/timoxa0/goadb/internal/errors" "github.com/timoxa0/goadb/internal/errors"
) )
type ForwardType uint8 type ForwardType int8
const ( const (
TypeInvalid ForwardType = iota TypeInvalid ForwardType = iota
TCP ForwardTCP
LOCAL ForwardLOCAL
) )
var forwardTypeStrings = map[string]ForwardType{ var forwardTypeStrings = map[string]ForwardType{
"tcp": TCP, "tcp": ForwardTCP,
"local": LOCAL, "local": ForwardLOCAL,
} }
type ForwardTarget string type ForwardTarget string
type ForwardLocal struct { type ForwardLocal struct {
ftype ForwardType FType ForwardType
target ForwardTarget FTarget ForwardTarget
} }
type ForwardRemote struct { type ForwardRemote struct {
ftype ForwardType FType ForwardType
target ForwardTarget FTarget ForwardTarget
} }
type Forward struct { type Forward struct {
local ForwardLocal Local ForwardLocal
remote ForwardRemote Remote ForwardRemote
} }
func parseForward(str string, deviceSerial string) ([]Forward, error) { func parseForward(str string, deviceSerial string) ([]Forward, error) {
@ -48,13 +48,13 @@ func parseForward(str string, deviceSerial string) ([]Forward, error) {
raw_local := strings.Split(local, ":") raw_local := strings.Split(local, ":")
raw_remote := strings.Split(remote, ":") raw_remote := strings.Split(remote, ":")
forwards = append(forwards, Forward{ forwards = append(forwards, Forward{
local: ForwardLocal{ Local: ForwardLocal{
ftype: forwardTypeStrings[raw_local[0]], FType: forwardTypeStrings[raw_local[0]],
target: ForwardTarget(raw_local[1]), FTarget: ForwardTarget(raw_local[1]),
}, },
remote: ForwardRemote{ Remote: ForwardRemote{
ftype: forwardTypeStrings[raw_remote[0]], FType: forwardTypeStrings[raw_remote[0]],
target: ForwardTarget(raw_remote[1]), FTarget: ForwardTarget(raw_remote[1]),
}, },
}) })
} }