yans/internal/protocol/constants.go

84 lines
2.1 KiB
Go
Raw Normal View History

2022-01-17 22:38:56 +00:00
package protocol
2022-02-03 16:44:08 +00:00
var (
ErrSyntaxError = NNTPResponse{Code: 501, Message: "Syntax Error"}
)
func IsMessageHeaderAllowed(headerName string) bool {
switch headerName {
case
"Date",
"From",
"Message-ID",
"Newsgroups",
"Path",
"Subject",
"Comments",
"Keywords",
"In-Reply-To",
"Sender",
"MIME-Version",
"Content-Type",
"Content-Transfer-Encoding",
"Content-Disposition",
"Content-Language",
"Approved",
"Archive",
"Control",
"Distribution",
"Expires",
"Followup-To",
"Injection-Date",
"Injection-Info",
"Organization",
"References",
"Summary",
"Supersedes",
"User-Agent",
"Xref":
return true
}
return false
}
const (
CRLF = "\r\n"
MultilineEnding = "."
)
2022-01-17 22:38:56 +00:00
const (
CommandCapabilities = "CAPABILITIES"
CommandQuit = "QUIT"
CommandDate = "DATE"
CommandMode = "MODE"
CommandList = "LIST"
2022-01-25 16:27:58 +00:00
CommandGroup = "GROUP"
2022-01-25 21:29:30 +00:00
CommandNewGroups = "NEWGROUPS"
2022-02-03 16:44:08 +00:00
CommandPost = "POST"
2022-01-17 22:38:56 +00:00
)
const (
CapabilityNameVersion = "VERSION"
CapabilityNameReader = "READER"
CapabilityNameIHave = "IHAVE"
CapabilityNamePost = "POST"
CapabilityNameNewNews = "NEWNEWS"
CapabilityNameHdr = "HDR"
CapabilityNameOver = "OVER"
CapabilityNameList = "LIST"
CapabilityNameImplementation = "IMPLEMENTATION"
CapabilityNameModeReader = "MODE-READER"
)
const (
MessageNNTPServiceReadyPostingProhibited = "201 YANS NNTP Service Ready, posting prohibited"
2022-01-17 22:38:56 +00:00
MessageReaderModePostingProhibited = "201 Reader mode, posting prohibited"
MessageNNTPServiceExitsNormally = "205 NNTP Service exits normally, bye!"
2022-01-17 22:38:56 +00:00
MessageUnknownCommand = "500 Unknown command"
MessageErrorHappened = "403 Failed to process command:"
MessageListOfNewsgroupsFollows = "215 list of newsgroups follows"
2022-01-25 16:27:58 +00:00
MessageNoSuchGroup = "411 No such newsgroup"
2022-02-03 16:44:08 +00:00
MessageInputArticle = "340 Input article; end with <CR-LF>.<CR-LF>"
MessageArticleReceived = "240 Article received OK"
2022-01-17 22:38:56 +00:00
)