session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "PORT", null));
return;
}
// is port enabled
DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
if(!dataCfg.isActiveEnabled()) {
session.write(FtpReplyUtil.translate(session, request, context, 510, "PORT.disabled", null));
return;
}
InetSocketAddress address;
try {
address = SocketAddressEncoder.decode(request.getArgument());
} catch(IllegalInetAddressException e) {
session.write(FtpReplyUtil.translate(session, request, context, 510, "PORT", null));
return;
} catch(IllegalPortException e) {
LOG.debug("Invalid data port: " + request.getArgument(), e);
session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE, "PORT.invalid", null));
return;
} catch(UnknownHostException e) {
LOG.debug("Unknown host", e);
session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED, "PORT.host", null));
return;
}
// check IP
if(dataCfg.isActiveIpCheck()) {
if(session.getRemoteAddress() instanceof InetSocketAddress) {
InetAddress clientAddr = ((InetSocketAddress)session.getRemoteAddress()).getAddress();
if(!address.getAddress().equals(clientAddr)) {
session.write(FtpReplyUtil.translate(session, request, context, 510, "PORT.mismatch", null));
return;