diff --git a/conf/IRConf.json b/conf/IRConf.json index 98280eb..368d33b 100644 --- a/conf/IRConf.json +++ b/conf/IRConf.json @@ -2,13 +2,13 @@ "servername": "IRCat", "info": "IRC server based on TCP/IP protocol to rfc1459 standard", "version": "v1.2", - "debuglvl": "0", + "debuglvl": "1", "comments": "release", "describe": "describe", "adminName": "Nikita", "adminNickname": "rmass", "adminEmail": "rmass@gmail.com", - "allowedIP": "127.0.0.1", + "allowedIP": "0.0.0.0", "maxChannels": 10, "maxInactiveTimeout": 120, "maxResponseTimeout": 60, diff --git a/srcs/Channel.cpp b/srcs/Channel.cpp index 4603835..14c706e 100644 --- a/srcs/Channel.cpp +++ b/srcs/Channel.cpp @@ -211,7 +211,7 @@ void Channel::removeOperator(const User &user) if (operators.size() == 0 && users.size() > 0) { operators.push_back(users[0]); - sendMessage("MODE " + this->name + " +o " + user.getNickname() + "\n", user, true); + sendMessage("MODE " + this->name + " +o " + users[0]->getNickname() + "\n", user, true); } } } diff --git a/srcs/Server.cpp b/srcs/Server.cpp index fe429cd..f03e8eb 100644 --- a/srcs/Server.cpp +++ b/srcs/Server.cpp @@ -238,6 +238,7 @@ void Server::listenSocket() std::cout << "Failed to listen on socket. errno: " << errno << std::endl; exit(EXIT_FAILURE); } + fcntl(sockfd, F_SETFL, O_NONBLOCK); } void Server::grabConnection() diff --git a/srcs/commands/ircOperatorCommands.cpp b/srcs/commands/ircOperatorCommands.cpp index b554af8..8f63d01 100644 --- a/srcs/commands/ircOperatorCommands.cpp +++ b/srcs/commands/ircOperatorCommands.cpp @@ -49,5 +49,14 @@ int Server::restartCmd(const Message &msg, User &user) { } loadConfig(); + close(sockfd); + // Create a socket (IPv4, TCP) + createSocket(); + + // Listen to port on any address + bindSocket(); + + // Start listening. + listenSocket(); return 0; } \ No newline at end of file diff --git a/srcs/main.cpp b/srcs/main.cpp index 15ef488..b8f41ef 100644 --- a/srcs/main.cpp +++ b/srcs/main.cpp @@ -40,8 +40,6 @@ int main(int argc, char **argv) // Start listening. server.listenSocket(); - fcntl(server.getSockfd(), F_SETFL, O_NONBLOCK); - signal(SIGINT, sigHandler); while (work)