parse228(resp) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/net/ftp.rb, line 843
    def parse228(resp)
      if resp[0, 3] != "228"
        raise FTPReplyError, resp
      end
      left = resp.index("(")
      right = resp.index(")")
      if left == nil or right == nil
        raise FTPProtoError, resp
      end
      numbers = resp[left + 1 .. right - 1].split(",")
      if numbers[0] == "4"
        if numbers.length != 9 || numbers[1] != "4" || numbers[2 + 4] != "2"
          raise FTPProtoError, resp
        end
        host = numbers[2, 4].join(".")
        port = (numbers[7].to_i << 8) + numbers[8].to_i
      elsif numbers[0] == "6"
        if numbers.length != 21 || numbers[1] != "16" || numbers[2 + 16] != "2"
          raise FTPProtoError, resp
        end
        v6 = ["", "", "", "", "", "", "", ""]
        for i in 0 .. 7
          v6[i] = sprintf("%02x%02x", numbers[(i * 2) + 2].to_i,
                          numbers[(i * 2) + 3].to_i)
        end
        host = v6[0, 8].join(":")
        port = (numbers[19].to_i << 8) + numbers[20].to_i
      end 
      return host, port
    end
Register or log in to add new notes.