Rename CommandConfiguration to Configuration
This commit is contained in:
@@ -27,8 +27,8 @@ import (
|
|||||||
"github.com/niruix/sshwifty/application/rw"
|
"github.com/niruix/sshwifty/application/rw"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommandConfiguration contains configuration data needed to run command
|
// Configuration contains configuration data needed to run command
|
||||||
type CommandConfiguration struct {
|
type Configuration struct {
|
||||||
Dial network.Dial
|
Dial network.Dial
|
||||||
DialTimeout time.Duration
|
DialTimeout time.Duration
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ func New(cs Commands) Commander {
|
|||||||
|
|
||||||
// New Adds a new client
|
// New Adds a new client
|
||||||
func (c Commander) New(
|
func (c Commander) New(
|
||||||
cfg CommandConfiguration,
|
cfg Configuration,
|
||||||
receiver rw.FetchReader,
|
receiver rw.FetchReader,
|
||||||
sender io.Writer,
|
sender io.Writer,
|
||||||
senderLock *sync.Mutex,
|
senderLock *sync.Mutex,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ var (
|
|||||||
type Command func(
|
type Command func(
|
||||||
l log.Logger,
|
l log.Logger,
|
||||||
w StreamResponder,
|
w StreamResponder,
|
||||||
cfg CommandConfiguration,
|
cfg Configuration,
|
||||||
) FSMMachine
|
) FSMMachine
|
||||||
|
|
||||||
// Commands contains data of all commands
|
// Commands contains data of all commands
|
||||||
@@ -63,7 +63,7 @@ func (c Commands) Run(
|
|||||||
id byte,
|
id byte,
|
||||||
l log.Logger,
|
l log.Logger,
|
||||||
w StreamResponder,
|
w StreamResponder,
|
||||||
cfg CommandConfiguration) (FSM, error) {
|
cfg Configuration) (FSM, error) {
|
||||||
if id > MaxCommandID {
|
if id > MaxCommandID {
|
||||||
return FSM{}, ErrCommandRunUndefinedCommand
|
return FSM{}, ErrCommandRunUndefinedCommand
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func (h streamHandlerSender) Write(b []byte) (int, error) {
|
|||||||
|
|
||||||
// Handler client stream control
|
// Handler client stream control
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
cfg CommandConfiguration
|
cfg Configuration
|
||||||
commands *Commands
|
commands *Commands
|
||||||
receiver rw.FetchReader
|
receiver rw.FetchReader
|
||||||
sender handlerSender
|
sender handlerSender
|
||||||
@@ -117,7 +117,7 @@ type Handler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newHandler(
|
func newHandler(
|
||||||
cfg CommandConfiguration,
|
cfg Configuration,
|
||||||
commands *Commands,
|
commands *Commands,
|
||||||
receiver rw.FetchReader,
|
receiver rw.FetchReader,
|
||||||
sender io.Writer,
|
sender io.Writer,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func TestHandlerHandleEcho(t *testing.T) {
|
|||||||
}
|
}
|
||||||
lock := sync.Mutex{}
|
lock := sync.Mutex{}
|
||||||
handler := newHandler(
|
handler := newHandler(
|
||||||
CommandConfiguration{},
|
Configuration{},
|
||||||
nil,
|
nil,
|
||||||
rw.NewFetchReader(testDummyFetchGen(s)),
|
rw.NewFetchReader(testDummyFetchGen(s)),
|
||||||
&w,
|
&w,
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ type dummyStreamCommand struct {
|
|||||||
func newDummyStreamCommand(
|
func newDummyStreamCommand(
|
||||||
l log.Logger,
|
l log.Logger,
|
||||||
w StreamResponder,
|
w StreamResponder,
|
||||||
cfg CommandConfiguration,
|
cfg Configuration,
|
||||||
) FSMMachine {
|
) FSMMachine {
|
||||||
return &dummyStreamCommand{
|
return &dummyStreamCommand{
|
||||||
lock: sync.Mutex{},
|
lock: sync.Mutex{},
|
||||||
@@ -180,7 +180,7 @@ func TestHandlerHandleStream(t *testing.T) {
|
|||||||
|
|
||||||
lock := sync.Mutex{}
|
lock := sync.Mutex{}
|
||||||
hhd := newHandler(
|
hhd := newHandler(
|
||||||
CommandConfiguration{},
|
Configuration{},
|
||||||
&cmds,
|
&cmds,
|
||||||
rw.NewFetchReader(readerSource),
|
rw.NewFetchReader(readerSource),
|
||||||
wBuffer,
|
wBuffer,
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ func (c *stream) reinit(
|
|||||||
w streamHandlerSender,
|
w streamHandlerSender,
|
||||||
l log.Logger,
|
l log.Logger,
|
||||||
cc *Commands,
|
cc *Commands,
|
||||||
cfg CommandConfiguration,
|
cfg Configuration,
|
||||||
b []byte,
|
b []byte,
|
||||||
) error {
|
) error {
|
||||||
hd := streamInitialHeader{}
|
hd := streamInitialHeader{}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ func (s sshRemoteConn) isValid() bool {
|
|||||||
type sshClient struct {
|
type sshClient struct {
|
||||||
w command.StreamResponder
|
w command.StreamResponder
|
||||||
l log.Logger
|
l log.Logger
|
||||||
cfg command.CommandConfiguration
|
cfg command.Configuration
|
||||||
remoteCloseWait sync.WaitGroup
|
remoteCloseWait sync.WaitGroup
|
||||||
credentialReceive chan []byte
|
credentialReceive chan []byte
|
||||||
credentialProcessed bool
|
credentialProcessed bool
|
||||||
@@ -181,7 +181,7 @@ type sshClient struct {
|
|||||||
func newSSH(
|
func newSSH(
|
||||||
l log.Logger,
|
l log.Logger,
|
||||||
w command.StreamResponder,
|
w command.StreamResponder,
|
||||||
cfg command.CommandConfiguration,
|
cfg command.Configuration,
|
||||||
) command.FSMMachine {
|
) command.FSMMachine {
|
||||||
return &sshClient{
|
return &sshClient{
|
||||||
w: w,
|
w: w,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const (
|
|||||||
type telnetClient struct {
|
type telnetClient struct {
|
||||||
l log.Logger
|
l log.Logger
|
||||||
w command.StreamResponder
|
w command.StreamResponder
|
||||||
cfg command.CommandConfiguration
|
cfg command.Configuration
|
||||||
remoteChan chan io.WriteCloser
|
remoteChan chan io.WriteCloser
|
||||||
remoteConn io.WriteCloser
|
remoteConn io.WriteCloser
|
||||||
closeWait sync.WaitGroup
|
closeWait sync.WaitGroup
|
||||||
@@ -57,7 +57,7 @@ type telnetClient struct {
|
|||||||
func newTelnet(
|
func newTelnet(
|
||||||
l log.Logger,
|
l log.Logger,
|
||||||
w command.StreamResponder,
|
w command.StreamResponder,
|
||||||
cfg command.CommandConfiguration,
|
cfg command.Configuration,
|
||||||
) command.FSMMachine {
|
) command.FSMMachine {
|
||||||
return &telnetClient{
|
return &telnetClient{
|
||||||
l: l,
|
l: l,
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ func (s socket) Get(
|
|||||||
|
|
||||||
senderLock := sync.Mutex{}
|
senderLock := sync.Mutex{}
|
||||||
cmdExec, cmdExecErr := s.commander.New(
|
cmdExec, cmdExecErr := s.commander.New(
|
||||||
command.CommandConfiguration{
|
command.Configuration{
|
||||||
Dial: s.commonCfg.Dialer,
|
Dial: s.commonCfg.Dialer,
|
||||||
DialTimeout: s.commonCfg.DecideDialTimeout(s.serverCfg.ReadTimeout),
|
DialTimeout: s.commonCfg.DecideDialTimeout(s.serverCfg.ReadTimeout),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user