0d4b0b2279
- $ann implemented - concurrency removed; server is now single-threaded, event-driven and much more stable - rare seed is no longer the game id; ids are sequential from server startup so they weren't random at all before - supports dropping privileges; now you can run it as root so it can open a sockets on low ports, then it will switch to the given user before serving any traffic - newserv now behaves like a proxy if you run it with the --proxy-destination=<IP_OR_HOSTNAME> argument; there's also an (invisible) shell in this mode where you can inject commands to the server or client. e.g. it can always be christmas in the lobby if you do `sc DA 01 00 00` - increased the mtu on PSODolphinConfig's tap0 configuration; this seems to make the connection more stable - fixed some uninitialized memory bugs - the shell is now event-driven and now uses libevent too; unfortunately this means readline doesn't work anymore (no history and vim-like shortcuts) - made network command display consistent for input vs. output (the header appears in both cases now) - fixed bugs in some subcommand handling (the BB logic was being applied to non-BB clients erroneously, causing most item drops not to work at all) - fixed player tags in the short lobby data struct. unclear if this was actually a problem but it was inconsistent with other servers - fixed "unused" field in game join command (actually it appears to be disable_udp and should be 1, not 0) - cleaned up Server abstraction a bit - rewrote some text functions; asan was complaining about the built-in ones for some reason - added an optional welcome message
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <event2/event.h>
|
|
|
|
#include <stdexcept>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <phosg/Filesystem.hh>
|
|
|
|
#include "ServerState.hh"
|
|
|
|
|
|
|
|
class Shell {
|
|
public:
|
|
Shell(std::shared_ptr<struct event_base> base,
|
|
std::shared_ptr<ServerState> state);
|
|
virtual ~Shell() = default;
|
|
Shell(const Shell&) = delete;
|
|
Shell(Shell&&) = delete;
|
|
Shell& operator=(const Shell&) = delete;
|
|
Shell& operator=(Shell&&) = delete;
|
|
|
|
protected:
|
|
std::shared_ptr<struct event_base> base;
|
|
std::shared_ptr<ServerState> state;
|
|
std::unique_ptr<struct event, void (*)(struct event*)> read_event;
|
|
std::unique_ptr<struct event, void (*)(struct event*)> prompt_event;
|
|
Poll poll;
|
|
|
|
class exit_shell : public std::runtime_error {
|
|
public:
|
|
exit_shell();
|
|
~exit_shell() = default;
|
|
};
|
|
|
|
static void dispatch_print_prompt(evutil_socket_t fd, short events, void* ctx);
|
|
static void dispatch_read_stdin(evutil_socket_t fd, short events, void* ctx);
|
|
virtual void print_prompt();
|
|
void read_stdin();
|
|
virtual void execute_command(const std::string& command) = 0;
|
|
};
|