allow selection of listen address

This commit is contained in:
scatterflower 2020-10-07 01:48:10 -05:00
parent 8c6385048e
commit 0a29665927
2 changed files with 15 additions and 3 deletions

View File

@ -329,12 +329,13 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
args.append(incoming_args[1].toString());
// char name
if (!server->characters.contains(incoming_args[2].toString()))
return invalid;
if (current_char != incoming_args[2].toString()) {
// Selected char is different from supplied folder name
// This means the user is INI-swapped
// TODO: ini swap locking
// if no iniswap allowed then
// if (!server->characters.contains(incoming_args[2].toString()))
// return invalid;
qDebug() << "INI swap detected from " << getIpid();
}
args.append(incoming_args[2].toString());

View File

@ -32,7 +32,18 @@ Server::Server(int p_port, int p_ws_port, QObject* parent) : QObject(parent)
void Server::start()
{
if (!server->listen(QHostAddress::Any, port)) {
QSettings config("config/config.ini", QSettings::IniFormat);
config.beginGroup("Options");
QString bind_ip = config.value("ip", "all").toString();
QHostAddress bind_addr;
if (bind_ip == "all")
bind_addr = QHostAddress::Any;
else
bind_addr = QHostAddress(bind_ip);
if (bind_addr.protocol() != QAbstractSocket::IPv4Protocol && bind_addr.protocol() != QAbstractSocket::IPv6Protocol && bind_addr != QHostAddress::Any) {
qDebug() << bind_ip << "is an invalid IP address to listen on! Server not starting, check your config.";
}
if (!server->listen(bind_addr, port)) {
qDebug() << "Server error:" << server->errorString();
}
else {