mirror of
https://github.com/openziti/zrok.git
synced 2025-06-20 01:37:52 +02:00
support --auto mode for agent-based private shares (#780)
This commit is contained in:
parent
3f8e76094e
commit
c728ae878f
@ -14,6 +14,10 @@ type access struct {
|
|||||||
frontendToken string
|
frontendToken string
|
||||||
token string
|
token string
|
||||||
bindAddress string
|
bindAddress string
|
||||||
|
autoMode bool
|
||||||
|
autoAddress string
|
||||||
|
autoStartPort uint16
|
||||||
|
autoEndPort uint16
|
||||||
responseHeaders []string
|
responseHeaders []string
|
||||||
|
|
||||||
process *proctree.Child
|
process *proctree.Child
|
||||||
|
@ -3,6 +3,7 @@ package agent
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"github.com/openziti/zrok/agent/agentGrpc"
|
"github.com/openziti/zrok/agent/agentGrpc"
|
||||||
"github.com/openziti/zrok/agent/proctree"
|
"github.com/openziti/zrok/agent/proctree"
|
||||||
"github.com/openziti/zrok/environment"
|
"github.com/openziti/zrok/environment"
|
||||||
@ -21,9 +22,19 @@ func (i *agentGrpcImpl) AccessPrivate(_ context.Context, req *agentGrpc.AccessPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
accCmd := []string{os.Args[0], "access", "private", "--subordinate", "-b", req.BindAddress, req.Token}
|
accCmd := []string{os.Args[0], "access", "private", "--subordinate", "-b", req.BindAddress, req.Token}
|
||||||
|
if req.AutoMode {
|
||||||
|
accCmd = append(accCmd, "--auto", "--auto-address", req.AutoAddress, "--auto-start-port", fmt.Sprintf("%v", req.AutoStartPort))
|
||||||
|
accCmd = append(accCmd, "--auto-end-port", fmt.Sprintf("%v", req.AutoEndPort))
|
||||||
|
}
|
||||||
|
logrus.Info(accCmd)
|
||||||
|
|
||||||
acc := &access{
|
acc := &access{
|
||||||
token: req.Token,
|
token: req.Token,
|
||||||
bindAddress: req.BindAddress,
|
bindAddress: req.BindAddress,
|
||||||
|
autoMode: req.AutoMode,
|
||||||
|
autoAddress: req.AutoAddress,
|
||||||
|
autoStartPort: uint16(req.AutoStartPort),
|
||||||
|
autoEndPort: uint16(req.AutoEndPort),
|
||||||
responseHeaders: req.ResponseHeaders,
|
responseHeaders: req.ResponseHeaders,
|
||||||
bootComplete: make(chan struct{}),
|
bootComplete: make(chan struct{}),
|
||||||
agent: i.agent,
|
agent: i.agent,
|
||||||
|
@ -374,11 +374,19 @@ func (cmd *accessPrivateCommand) accessAgent(args []string, root env_core.Root)
|
|||||||
}
|
}
|
||||||
defer func() { _ = conn.Close() }()
|
defer func() { _ = conn.Close() }()
|
||||||
|
|
||||||
acc, err := client.AccessPrivate(context.Background(), &agentGrpc.AccessPrivateRequest{
|
req := &agentGrpc.AccessPrivateRequest{
|
||||||
Token: args[0],
|
Token: args[0],
|
||||||
BindAddress: cmd.bindAddress,
|
BindAddress: cmd.bindAddress,
|
||||||
ResponseHeaders: cmd.responseHeaders,
|
ResponseHeaders: cmd.responseHeaders,
|
||||||
})
|
}
|
||||||
|
if cmd.autoMode {
|
||||||
|
req.AutoMode = true
|
||||||
|
req.AutoAddress = cmd.autoAddress
|
||||||
|
req.AutoStartPort = uint32(cmd.autoStartPort)
|
||||||
|
req.AutoEndPort = uint32(cmd.autoEndPort)
|
||||||
|
}
|
||||||
|
|
||||||
|
acc, err := client.AccessPrivate(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tui.Error("error creating access", err)
|
tui.Error("error creating access", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user