Skip to content

Commit

Permalink
added the private and server full connect for anybody with master or …
Browse files Browse the repository at this point in the history
…admin
  • Loading branch information
Harry Delmolino committed Jun 2, 2010
1 parent 98f19ff commit 5f5a62f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions server-init.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ serverdesc "Another XSBS Server"
publicserver 1
maxclients 19
adminpass xsbsrules
serverport 20000
6 changes: 4 additions & 2 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ namespace server

int allowconnect(clientinfo *ci, const char *pwd)
{
if(SbPy::triggerPolicyEventIntString("connect_with_pass", ci->clientnum, pwd)) return DISC_NONE;
if(!m_mp(gamemode)) return DISC_PRIVATE;
if(serverpass[0])
{
Expand Down Expand Up @@ -1611,15 +1612,16 @@ namespace server
getstring(text, p);

SbPy::triggerEventInt("player_connect_pre", ci->clientnum);
SbPy::triggerEventInt("player_connect", ci->clientnum);

int disc = allowconnect(ci, text);
if(disc)
{
disconnect_client(sender, disc);
return;
}


SbPy::triggerEventInt("player_connect", ci->clientnum);

ci->playermodel = getint(p);

if(m_demo) enddemoplayback();
Expand Down
25 changes: 23 additions & 2 deletions src/pyscripts/xsbs/users/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from elixir import Entity, Field, String, ManyToOne, OneToMany, setup_all, session
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound

from xsbs.events import eventHandler, triggerServerEvent, registerServerEventHandler, registerPolicyEventHandler
from privilege import isUserAtLeastMaster
from xsbs.events import eventHandler, policyHandler, triggerServerEvent, registerServerEventHandler, registerPolicyEventHandler
from xsbs.commands import commandHandler, UsageError, StateError, ArgumentValueError
from xsbs.colors import red, green, orange
from xsbs.ui import info, error, warning
Expand Down Expand Up @@ -240,6 +240,27 @@ def onPlayerActive(cn):
p.warning_for_login = True
p.warn_nickacct = nickacct
warnNickReserved(cn, 0, sbserver.playerSessionId(cn))

@policyHandler('connect_with_pass')
def connectWithPass(cn, args):
p = player(cn)
adminhash = sbserver.hashPassword(cn, sbserver.adminPassword())
try:
na = NickAccount.query.filter(NickAccount.nick==p.name()).one()
except NoResultFound:
return False
except MultipleResultsFound:
p.message(error('Multiple names linked to this account. Contact the system administrator.'))
return False
else:
nickhash = sbserver.hashPassword(cn, na.user.password)
if args == nickhash:
login(cn, na.user)
user_id = p.user.id
if isUserAtLeastMaster:
return True
else:
return False

@eventHandler('player_name_changed')
def onPlayerNameChanged(cn, old_name, new_name):
Expand Down

0 comments on commit 5f5a62f

Please sign in to comment.