Logo Search packages:      
Sourcecode: sbnc version File versions  Download package

RESULT< bool > CCore::AddHostAllow ( const char *  Mask,
bool  UpdateConfig = true 
)

AddHostAllow

Adds a new "host allow" entry. Only users are permitted to log in whose IP address/host is matched by a host in this list.

Parameters:
Mask the new mask
UpdateConfig whether to update the config files

Definition at line 2020 of file Core.cpp.

References CanHostConnect(), CVector< Type >::GetLength(), CVector< Type >::Insert(), IsValidHostAllow(), m_HostAllows, and UpdateHosts().

Referenced by CCore(), and CClientConnection::ProcessBncCommand().

                                                                    {
      char *dupMask;
      RESULT<bool> Result;

      if (Mask == NULL) {
            THROW(bool, Generic_InvalidArgument, "Mask cannot be NULL.");
      }

      if (m_HostAllows.GetLength() > 0 && CanHostConnect(Mask)) {
            THROW(bool, Generic_Unknown, "This hostmask is already added or another hostmask supercedes it.");
      }

      if (!IsValidHostAllow(Mask)) {
            THROW(bool, Generic_Unknown, "The specified mask is not valid.");
      }

      if (m_HostAllows.GetLength() > 50) {
            THROW(bool, Generic_Unknown, "You cannot add more than 50 masks.");
      }

      dupMask = strdup(Mask);

      CHECK_ALLOC_RESULT(dupMask, strdup) {
            THROW(bool, Generic_OutOfMemory, "strdup() failed.");
      } CHECK_ALLOC_RESULT_END;

      Result = m_HostAllows.Insert(dupMask);

      if (IsError(Result)) {
            LOGERROR("Insert() failed. Host could not be added.");

            free(dupMask);

            THROWRESULT(bool, Result);
      }

      if (UpdateConfig) {
            UpdateHosts();
      }

      RETURN(bool, true);
}


Generated by  Doxygen 1.6.0   Back to index