faboussard / 42-irc

3 stars 1 forks source link

New class `Config` | Update numeric replies functions parameters | Update `std::map typedef` in Channel #16

Closed ysengoku closed 3 weeks ago

ysengoku commented 3 weeks ago

Config class

This class has all ISUPPORT parameters defined in server.conf file:

CASEMAPPING=ascii
CHANLIMIT=10
CHANMODES=i,t,k,l
CHANNELLEN=50
CHANTYPES=#
HOSTLEN=63
KICKLEN=255
MAXLIST=100
MAXTARGETS=4
MODES=3
NETWORK=42IRC
NICKLEN=9
PREFIX=(o)@
TOPICLEN=307
USERLEN=10
USERMODES=ior

These default values are from RFC1459(IRC 1993).

Add a global variable gConfig so that we can access to configuration from everywhere.

USAGE (Arguments are examples.)

Channel class

PING command

Usage:


Other updates

numericReplies

Client class

Channel class

Server class

Previous version

Client cli();
cli.setFd(newClientFd);
cli.setIp(inet_ntoa(cliadd.sin_addr));

Update

std::string clientIp = inet_ntoa(cliadd.sin_addr);
struct hostent* host = gethostbyaddr(&cliadd.sin_addr, sizeof(cliadd.sin_addr), AF_INET);
std::string hostName;
if (host->h_name == NULL || sizeof(host->h_name) == 0 ||
      static_cast<size_t> (host->h_length) > gConfig->getLimit("HOSTLEN"))
  hostName = clientIp;
else
  hostName = host->h_name;
Client cli(newClientFd, clientIp, hostName);