mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
TelnetServer: Implement basic telnet server
Fixes #407 Depends on #530 to run reliably.
This commit is contained in:
parent
423807d772
commit
040947ee47
9 changed files with 521 additions and 0 deletions
33
Servers/TelnetServer/Parser.h
Normal file
33
Servers/TelnetServer/Parser.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
#define IAC 0xff
|
||||
|
||||
class Parser {
|
||||
public:
|
||||
Function<void(const Command&)> on_command;
|
||||
Function<void(const StringView&)> on_data;
|
||||
Function<void()> on_error;
|
||||
|
||||
void write(const StringView&);
|
||||
|
||||
protected:
|
||||
enum State {
|
||||
Free,
|
||||
ReadCommand,
|
||||
ReadSubcommand,
|
||||
Error,
|
||||
};
|
||||
|
||||
void write(const String& str);
|
||||
|
||||
private:
|
||||
State m_state { State::Free };
|
||||
u8 m_command { 0 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue