 
 unless module.parent
   ftpd = new BabyFtpd
+  ftpd.addUser "taka", "1234"
   ftpd.listen 8021, "localhost"

net = require("net")

module.exports = class BabyFtpd
  constructor: (option = {})->
    @piServer  = undefined
  
  listen: (port = 21, host = "0.0.0.0")->
    @piServer = net.createServer()

      @reply 202
    
    # 仮実装しているもの
    #"RETR": ()->
    #"PWD": ()->
    #"NLST": ()->
    
    # 各コマンドの処理
    "USER": (username)->
      @userName = username
      @reply 331
    
    "PASS": (password)->
      userPass = authUser[@userName]
      if userPass? and userPass is password
        @reply 230
      else
        @reply 530
    
    "PWD": ()->
      @reply 257, '"/"'
