mirror of
https://github.com/ChronosX88/yans.git
synced 2024-12-21 22:21:46 +00:00
Implement HELP command
This commit is contained in:
parent
164c296835
commit
5981fd1415
@ -45,7 +45,7 @@
|
||||
- :x: `LIST DISTRIB.PATS`
|
||||
- :construction: Information Commands
|
||||
- :heavy_check_mark: `DATE`
|
||||
- :x: `HELP`
|
||||
- :heavy_check_mark: `HELP`
|
||||
- :heavy_check_mark: `NEWGROUPS`
|
||||
- :x: `NEWNEWS`
|
||||
|
||||
|
@ -60,6 +60,7 @@ const (
|
||||
CommandHead = "HEAD"
|
||||
CommandBody = "BODY"
|
||||
CommandStat = "STAT"
|
||||
CommandHelp = "HELP"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -40,6 +40,7 @@ func NewHandler(b backend.StorageBackend, serverDomain string) *Handler {
|
||||
protocol.CommandHead: h.handleArticle,
|
||||
protocol.CommandBody: h.handleArticle,
|
||||
protocol.CommandStat: h.handleArticle,
|
||||
protocol.CommandHelp: h.handleHelp,
|
||||
}
|
||||
h.serverDomain = serverDomain
|
||||
return h
|
||||
@ -512,6 +513,49 @@ func (h *Handler) handleArticle(s *Session, command string, arguments []string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) handleHelp(s *Session, command string, arguments []string, id uint) error {
|
||||
s.tconn.StartResponse(id)
|
||||
defer s.tconn.EndResponse(id)
|
||||
|
||||
help :=
|
||||
" ARTICLE [message-ID|number]\r\n" +
|
||||
" BODY [message-ID|number]\r\n" +
|
||||
" CAPABILITIES [keyword]\r\n" +
|
||||
" DATE\r\n" +
|
||||
" GROUP newsgroup\r\n" +
|
||||
" HEAD [message-ID|number]\r\n" +
|
||||
" HELP\r\n" +
|
||||
" LAST\r\n" +
|
||||
" LIST [ACTIVE [wildmat]|NEWSGROUPS [wildmat]]\r\n" +
|
||||
" LISTGROUP [newsgroup [range]]\r\n" +
|
||||
" MODE READER\r\n" +
|
||||
" NEWGROUPS [yy]yymmdd hhmmss [GMT]\r\n" +
|
||||
" NEXT\r\n" +
|
||||
" POST\r\n" +
|
||||
" QUIT\r\n" +
|
||||
" STAT [message-ID|number]\r\n"
|
||||
|
||||
dw := s.tconn.DotWriter()
|
||||
w := bufio.NewWriter(dw)
|
||||
|
||||
_, err := w.Write([]byte(protocol.NNTPResponse{Code: 100, Message: "Legal commands"}.String() + protocol.CRLF))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = w.Write([]byte(help))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = w.Flush()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dw.Close()
|
||||
}
|
||||
|
||||
func (h *Handler) Handle(s *Session, message string, id uint) error {
|
||||
splittedMessage := strings.Split(message, " ")
|
||||
for i, v := range splittedMessage {
|
||||
|
Loading…
Reference in New Issue
Block a user