status.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package ftp
  2. // FTP status codes, defined in RFC 959
  3. const (
  4. StatusInitiating = 100
  5. StatusRestartMarker = 110
  6. StatusReadyMinute = 120
  7. StatusAlreadyOpen = 125
  8. StatusAboutToSend = 150
  9. StatusCommandOK = 200
  10. StatusCommandNotImplemented = 202
  11. StatusSystem = 211
  12. StatusDirectory = 212
  13. StatusFile = 213
  14. StatusHelp = 214
  15. StatusName = 215
  16. StatusReady = 220
  17. StatusClosing = 221
  18. StatusDataConnectionOpen = 225
  19. StatusClosingDataConnection = 226
  20. StatusPassiveMode = 227
  21. StatusLongPassiveMode = 228
  22. StatusExtendedPassiveMode = 229
  23. StatusLoggedIn = 230
  24. StatusLoggedOut = 231
  25. StatusLogoutAck = 232
  26. StatusAuthOK = 234
  27. StatusRequestedFileActionOK = 250
  28. StatusPathCreated = 257
  29. StatusUserOK = 331
  30. StatusLoginNeedAccount = 332
  31. StatusRequestFilePending = 350
  32. StatusNotAvailable = 421
  33. StatusCanNotOpenDataConnection = 425
  34. StatusTransfertAborted = 426
  35. StatusInvalidCredentials = 430
  36. StatusHostUnavailable = 434
  37. StatusFileActionIgnored = 450
  38. StatusActionAborted = 451
  39. Status452 = 452
  40. StatusBadCommand = 500
  41. StatusBadArguments = 501
  42. StatusNotImplemented = 502
  43. StatusBadSequence = 503
  44. StatusNotImplementedParameter = 504
  45. StatusNotLoggedIn = 530
  46. StatusStorNeedAccount = 532
  47. StatusFileUnavailable = 550
  48. StatusPageTypeUnknown = 551
  49. StatusExceededStorage = 552
  50. StatusBadFileName = 553
  51. )
  52. var statusText = map[int]string{
  53. // 200
  54. StatusCommandOK: "Command okay.",
  55. StatusCommandNotImplemented: "Command not implemented, superfluous at this site.",
  56. StatusSystem: "System status, or system help reply.",
  57. StatusDirectory: "Directory status.",
  58. StatusFile: "File status.",
  59. StatusHelp: "Help message.",
  60. StatusName: "",
  61. StatusReady: "Service ready for new user.",
  62. StatusClosing: "Service closing control connection.",
  63. StatusDataConnectionOpen: "Data connection open; no transfer in progress.",
  64. StatusClosingDataConnection: "Closing data connection. Requested file action successful.",
  65. StatusPassiveMode: "Entering Passive Mode.",
  66. StatusLongPassiveMode: "Entering Long Passive Mode.",
  67. StatusExtendedPassiveMode: "Entering Extended Passive Mode.",
  68. StatusLoggedIn: "User logged in, proceed.",
  69. StatusLoggedOut: "User logged out; service terminated.",
  70. StatusLogoutAck: "Logout command noted, will complete when transfer done.",
  71. StatusAuthOK: "AUTH command OK",
  72. StatusRequestedFileActionOK: "Requested file action okay, completed.",
  73. StatusPathCreated: "Path created.",
  74. // 300
  75. StatusUserOK: "User name okay, need password.",
  76. StatusLoginNeedAccount: "Need account for login.",
  77. StatusRequestFilePending: "Requested file action pending further information.",
  78. // 400
  79. StatusNotAvailable: "Service not available, closing control connection.",
  80. StatusCanNotOpenDataConnection: "Can't open data connection.",
  81. StatusTransfertAborted: "Connection closed; transfer aborted.",
  82. StatusInvalidCredentials: "Invalid username or password.",
  83. StatusHostUnavailable: "Requested host unavailable.",
  84. StatusFileActionIgnored: "Requested file action not taken.",
  85. StatusActionAborted: "Requested action aborted. Local error in processing.",
  86. Status452: "Insufficient storage space in system.",
  87. // 500
  88. StatusBadCommand: "Command unrecognized.",
  89. StatusBadArguments: "Syntax error in parameters or arguments.",
  90. StatusNotImplemented: "Command not implemented.",
  91. StatusBadSequence: "Bad sequence of commands.",
  92. StatusNotImplementedParameter: "Command not implemented for that parameter.",
  93. StatusNotLoggedIn: "Not logged in.",
  94. StatusStorNeedAccount: "Need account for storing files.",
  95. StatusFileUnavailable: "File unavailable.",
  96. StatusPageTypeUnknown: "Page type unknown.",
  97. StatusExceededStorage: "Exceeded storage allocation.",
  98. StatusBadFileName: "File name not allowed.",
  99. }
  100. // StatusText returns a text for the FTP status code. It returns the empty string if the code is unknown.
  101. func StatusText(code int) string {
  102. return statusText[code]
  103. }