Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
3c513b4b
Commit
3c513b4b
authored
Nov 18, 2014
by
woogerboy21
Browse files
moved code logic to callling function & indent fix
parent
8aa7a1d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
servatrice/src/servatrice.cpp
View file @
3c513b4b
...
@@ -380,16 +380,11 @@ QList<ServerProperties> Servatrice::getServerList() const
...
@@ -380,16 +380,11 @@ QList<ServerProperties> Servatrice::getServerList() const
int
Servatrice
::
getUsersWithAddress
(
const
QHostAddress
&
address
)
const
int
Servatrice
::
getUsersWithAddress
(
const
QHostAddress
&
address
)
const
{
{
int
result
=
0
;
int
result
=
0
;
QString
trustedSources
=
settingsCache
->
value
(
"server/trusted_sources"
,
"127.0.0.1,::1"
).
toString
();
QReadLocker
locker
(
&
clientsLock
);
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
if
(
trustedSources
.
contains
(
address
.
toString
(),
Qt
::
CaseInsensitive
))
{
if
(
static_cast
<
ServerSocketInterface
*>
(
clients
[
i
])
->
getPeerAddress
()
==
address
)
//allow all clients from trusted sources regardsless of number of connections
++
result
;
}
else
{
QReadLocker
locker
(
&
clientsLock
);
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
if
(
static_cast
<
ServerSocketInterface
*>
(
clients
[
i
])
->
getPeerAddress
()
==
address
)
++
result
;
}
return
result
;
return
result
;
}
}
...
...
servatrice/src/serversocketinterface.cpp
View file @
3c513b4b
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include
<QHostAddress>
#include
<QHostAddress>
#include
<QDebug>
#include
<QDebug>
#include
<QDateTime>
#include
<QDateTime>
#include
<QString>
#include
"settingscache.h"
#include
"settingscache.h"
#include
"serversocketinterface.h"
#include
"serversocketinterface.h"
#include
"servatrice.h"
#include
"servatrice.h"
...
@@ -117,6 +118,11 @@ bool ServerSocketInterface::initSession()
...
@@ -117,6 +118,11 @@ bool ServerSocketInterface::initSession()
sendProtocolItem
(
*
identSe
);
sendProtocolItem
(
*
identSe
);
delete
identSe
;
delete
identSe
;
//allow unlimited number of connections from the trusted sources
QString
trustedSources
=
settingsCache
->
value
(
"server/trusted_sources"
,
"127.0.0.1,::1"
).
toString
();
if
(
trustedSources
.
contains
(
address
.
toString
(),
Qt
::
CaseInsensitive
))
return
true
;
int
maxUsers
=
servatrice
->
getMaxUsersPerAddress
();
int
maxUsers
=
servatrice
->
getMaxUsersPerAddress
();
if
((
maxUsers
>
0
)
&&
(
servatrice
->
getUsersWithAddress
(
socket
->
peerAddress
())
>=
maxUsers
))
{
if
((
maxUsers
>
0
)
&&
(
servatrice
->
getUsersWithAddress
(
socket
->
peerAddress
())
>=
maxUsers
))
{
Event_ConnectionClosed
event
;
Event_ConnectionClosed
event
;
...
@@ -708,9 +714,9 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
...
@@ -708,9 +714,9 @@ Response::ResponseCode ServerSocketInterface::cmdBanFromServer(const Command_Ban
QString
userName
=
QString
::
fromStdString
(
cmd
.
user_name
());
QString
userName
=
QString
::
fromStdString
(
cmd
.
user_name
());
QString
address
=
QString
::
fromStdString
(
cmd
.
address
());
QString
address
=
QString
::
fromStdString
(
cmd
.
address
());
QString
trustedSources
=
settingsCache
->
value
(
"server/trusted_sources"
,
"127.0.0.1,::1"
).
toString
();
QString
trustedSources
=
settingsCache
->
value
(
"server/trusted_sources"
,
"127.0.0.1,::1"
).
toString
();
int
minutes
=
cmd
.
minutes
();
int
minutes
=
cmd
.
minutes
();
if
(
trustedSources
.
contains
(
address
,
Qt
::
CaseInsensitive
))
if
(
trustedSources
.
contains
(
address
,
Qt
::
CaseInsensitive
))
address
=
""
;
address
=
""
;
QSqlQuery
query
(
sqlInterface
->
getDatabase
());
QSqlQuery
query
(
sqlInterface
->
getDatabase
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment