Esempio n. 1
0
        private async Task CommandPortAsync(string parameter)
        {
            var paramSegs = parameter.Split(',');

            if (paramSegs.Length != 6)
            {
                await ReplyAsync(
                    FtpReplyCode.SyntaxErrorInParametersOrArguments,
                    "Syntax error, count of comma incorrect");

                return;
            }
            try
            {
                var       bytes      = paramSegs.Select(x => byte.Parse(x)).ToArray();
                IPAddress remoteIP   = new IPAddress(new ArraySegment <byte>(bytes, 0, 4).ToArray());
                int       remotePort = (bytes[4] << 8) | bytes[5];
                userActiveDataPort = remotePort;
                userActiveIP       = remoteIP;
                userActiveProtocal = 1;
                dataConnectionMode = DataConnectionMode.Active;
                await dataConnection.ConnectActiveAsync(userActiveIP, userActiveDataPort, userActiveProtocal);
                await ReplyAsync(FtpReplyCode.CommandOkay, "Data connection established");

                return;
            }
            catch
            {
                await ReplyAsync(
                    FtpReplyCode.SyntaxErrorInParametersOrArguments,
                    "Syntax error, number format incorrect");

                return;
            }
        }