-return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessAuthPacket(RAD_PACKET * packet)
-{
-USER_PTR ui;
-
-if (!CanAcctService((char *)packet->service))
- {
-
- // There are no sense to check for allowed service
- // It has allready checked at previous stage (authorization)
-
- printfd(__FILE__, "RADIUS::ProcessAuthPacket service '%s' neednot stargazer authentication\n", (char *)packet->service);
- packet->packetType = RAD_ACCEPT_PACKET;
- return 0;
- }
-
-// At this point we have an accountable service
-// All other services got a password if allowed or rejected
-
-if (!FindUser(&ui, (char *)packet->login))
- {
- packet->packetType = RAD_REJECT_PACKET;
- printfd(__FILE__, "RADIUS::ProcessAuthPacket user '%s' not found\n", (char *)packet->login);
- return 0;
- }
-
-if (ui->IsInetable())
- {
- packet->packetType = RAD_ACCEPT_PACKET;
- }
-else
- {
- packet->packetType = RAD_REJECT_PACKET;
- }
-
-packet->packetType = RAD_ACCEPT_PACKET;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessPostAuthPacket(RAD_PACKET * packet)
-{
-USER_PTR ui;
-
-if (!CanAcctService((char *)packet->service))
- {
-
- // There are no sense to check for allowed service
- // It has allready checked at previous stage (authorization)
-
- packet->packetType = RAD_ACCEPT_PACKET;
- return 0;
- }
-
-if (!FindUser(&ui, (char *)packet->login))
- {
- packet->packetType = RAD_REJECT_PACKET;
- printfd(__FILE__, "RADIUS::ProcessPostAuthPacket user '%s' not found\n", (char *)packet->login);
- return 0;
- }
-
-// I think that only Framed-User services has sense to be accountable
-// So we have to supply a Framed-IP
-
-USER_IPS ips = ui->GetProperty().ips;
-packet->packetType = RAD_ACCEPT_PACKET;
-
-// Additional checking for Framed-User service
-
-if (!strncmp((char *)packet->service, "Framed-User", RAD_SERVICE_LEN))
- packet->ip = ips[0].ip;
-else
- packet->ip = 0;
-
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessAcctStartPacket(RAD_PACKET * packet)
-{
-USER_PTR ui;
-
-if (!FindUser(&ui, (char *)packet->login))
- {
- packet->packetType = RAD_REJECT_PACKET;
- printfd(__FILE__, "RADIUS::ProcessAcctStartPacket user '%s' not found\n", (char *)packet->login);
- return 0;
- }
-
-// At this point we have to unauthorize user only if it is an accountable service
-
-if (CanAcctService((char *)packet->service))
- {
- if (sessions.find((const char *)packet->sessid) != sessions.end())
- {
- printfd(__FILE__, "RADIUS::ProcessAcctStartPacket session already started!\n");
- packet->packetType = RAD_REJECT_PACKET;
- return -1;
- }
- USER_IPS ips = ui->GetProperty().ips;
- if (users->Authorize(ui->GetLogin(), ips[0].ip, 0xffFFffFF, this))
- {
- printfd(__FILE__, "RADIUS::ProcessAcctStartPacket cannot authorize user '%s'\n", packet->login);
- packet->packetType = RAD_REJECT_PACKET;
- return -1;
- }
- sessions[(const char *)packet->sessid].userName = (const char *)packet->login;
- sessions[(const char *)packet->sessid].serviceType = (const char *)packet->service;
- for_each(sessions.begin(), sessions.end(), SPrinter());
- }
-else
- {
- printfd(__FILE__, "RADIUS::ProcessAcctStartPacket service '%s' can not be accounted\n", (char *)packet->service);
- }
-
-packet->packetType = RAD_ACCEPT_PACKET;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessAcctStopPacket(RAD_PACKET * packet)
-{
-std::map<std::string, RAD_SESSION>::iterator sid;
-
-if ((sid = sessions.find((const char *)packet->sessid)) == sessions.end())
- {
- printfd(__FILE__, "RADIUS::ProcessAcctStopPacket session had not started yet\n");
- packet->packetType = RAD_REJECT_PACKET;
- return -1;
- }
-
-USER_PTR ui;
-
-if (!FindUser(&ui, sid->second.userName))
- {
- packet->packetType = RAD_REJECT_PACKET;
- printfd(__FILE__, "RADIUS::ProcessPostAuthPacket user '%s' not found\n", sid->second.userName.c_str());
- return 0;
- }
-
-sessions.erase(sid);
-
-users->Unauthorize(ui->GetLogin(), this);
-
-packet->packetType = RAD_ACCEPT_PACKET;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessAcctUpdatePacket(RAD_PACKET * packet)
-{
-// Fake. May be use it later
-packet->packetType = RAD_ACCEPT_PACKET;
-return 0;
-}
-//-----------------------------------------------------------------------------
-int RADIUS::ProcessAcctOtherPacket(RAD_PACKET * packet)
-{
-// Fake. May be use it later
-packet->packetType = RAD_ACCEPT_PACKET;
-return 0;
-}
-//-----------------------------------------------------------------------------
-void RADIUS::PrintServices(const std::list<std::string> & svcs)
-{
-for_each(svcs.begin(), svcs.end(), Printer());
-}
-//-----------------------------------------------------------------------------
-bool RADIUS::FindUser(USER_PTR * ui, const std::string & login) const
-{
-if (users->FindByName(login, ui))
- {
- return false;
- }
-return true;
-}
-//-----------------------------------------------------------------------------
-bool RADIUS::CanAuthService(const std::string & svc) const
-{
-return find(authServices.begin(), authServices.end(), svc) != authServices.end();
-}
-//-----------------------------------------------------------------------------
-bool RADIUS::CanAcctService(const std::string & svc) const
-{
-return find(acctServices.begin(), acctServices.end(), svc) != acctServices.end();
-}
-//-----------------------------------------------------------------------------
-bool RADIUS::IsAllowedService(const std::string & svc) const
-{
-return CanAuthService(svc) || CanAcctService(svc);
-}
-//-----------------------------------------------------------------------------
-inline
-void InitEncrypt(BLOWFISH_CTX * ctx, const std::string & password)
-{
-unsigned char keyL[RAD_PASSWORD_LEN]; // Пароль для шифровки
-memset(keyL, 0, RAD_PASSWORD_LEN);
-strncpy((char *)keyL, password.c_str(), RAD_PASSWORD_LEN);
-Blowfish_Init(ctx, keyL, RAD_PASSWORD_LEN);
-}
-//-----------------------------------------------------------------------------
-inline
-void Encrypt(BLOWFISH_CTX * ctx, char * dst, const char * src, int len8)