Support clnt #143

Merged
lunny merged 1 commits from lunny/clnt into v2 2020-12-06 11:36:58 +00:00
3 changed files with 21 additions and 0 deletions

19
cmd.go

@ -34,6 +34,7 @@ var (
"CWD": commandCwd{},
"CCC": commandCcc{},
"CONF": commandConf{},
"CLNT": commandCLNT{},
"DELE": commandDele{},
"ENC": commandEnc{},
"EPRT": commandEprt{},
@ -139,7 +140,25 @@ func (cmd commandAppe) Execute(sess *Session, param string) {
} else {
sess.writeMessage(450, fmt.Sprint("error during transfer: ", err))
}
}
type commandCLNT struct{}
func (cmd commandCLNT) IsExtend() bool {
return true
}
func (cmd commandCLNT) RequireParam() bool {
return false
}
func (cmd commandCLNT) RequireAuth() bool {
return false
}
func (cmd commandCLNT) Execute(sess *Session, param string) {
sess.clientSoft = param
sess.writeMessage(200, "OK")
}
type commandOpts struct{}

@ -273,6 +273,7 @@ func (server *Server) ListenAndServe() error {
func (server *Server) Serve(l net.Listener) error {
server.listener = l
server.ctx, server.cancel = context.WithCancel(context.Background())
defer server.cancel()
sessionID := newSessionID()
for {
tcpConn, err := server.listener.Accept()

@ -42,6 +42,7 @@ type Session struct {
preCommand string
closed bool
tls bool
clientSoft string
Data map[string]interface{} // shared data between different commands
}