1
0
forked from 0ad/0ad
Commit Graph

133 Commits

Author SHA1 Message Date
ef623af2f8 Check for source of XMPP stanzas
Up to now Pyrogenesis didn't check if lobby related XMPP stanzas were
sent by the lobby bots. This meant that every user could send forged
data, like the list of games, to be displayed by another user. This
change fixes that by checking such stanzas come from the expected lobby
bots.

Patch by: @Dunedan
Accepted by: @Stan
Differential Revision: https://code.wildfiregames.com/D5216
This was SVN commit r28197.
2024-08-13 04:59:38 +00:00
a9ea169301 Improve formatting of XMPP announcements
Previously private messages and announcements got handled the same way.
This adds a distinct handling for server announcements, which allows
formatting them in a different way. They are now not prefixed with
"Private" anymore and show the announcement subject as well, if one was
set.

Patch by: @Dunedan
Accepted by: @Stan
Differential Revision: https://code.wildfiregames.com/D5268
This was SVN commit r28186.
2024-08-10 05:08:31 +00:00
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
d7a4fb7c20 Try to punch a hole through local firewalls, and fallback to localhost.
Fixes (probably rare) regression in 2034136560.

Differential Revision: https://code.wildfiregames.com/D3999
This was SVN commit r25515.
2021-05-22 08:34:00 +00:00
7bfcd9f78b Additional entropy when hashing match passwords.
The purpose of our client-side hashing for lobby game passwords is to
prevent malicious hosts from getting valuable passwords from clients
(e.g. accidentally typing their lobby password instead of the game, or
even their email password, etc).
However, the hashing was deterministic (and rather simple), making it
possible to compute rainbow tables and recover user passwords anyways.

By adding more variation, including some that cannot so easily be
controlled by the host (the client name), this becomes impractical. The
password hashing function used is rather fast, but given the base low
probability of mistypes, this seems fine.

Differential Revision: https://code.wildfiregames.com/D3459
This was SVN commit r25459.
2021-05-18 14:47:36 +00:00
895e4e6aa6 StunClient code cleanup: use enet functions, endianness
Instead of using platform-specific sockets, use enet_socket* functions
(which ends up doing the same).
Clean up some confusing APIs, removing the distinction between finding
the public IP for the host/join.

Fix endianness support & use simpler code.

Refs D364 / 61261d14fc (and some subsequent fixing diffs).

Differential Revision: https://code.wildfiregames.com/D3970
This was SVN commit r25453.
2021-05-17 15:14:10 +00:00
2034136560 Implement a workaround for routers without NAT loopback.
This allows joining a lobby game hosted on the same network (behind the
same NAT gateway).
This is relatively primitive to keep things simple: if the server and
the client have the same public IP, it is assumed that they are on the
same network and the client instead requests the local IP.

Differential Revision: https://code.wildfiregames.com/D3944
This was SVN commit r25448.
2021-05-16 15:34:38 +00:00
0f60bf3a97 Split off Object-related functions from ScriptInterface
Follows 34b1920e7b.

This splits off the object-related functions, such as
[Set/Get/Has]Property, CreateObject, CreateArray, FreezeObject.

It also puts the definitions in the header itself, which might end up
with faster code here & there, though perhaps slower compilation time
(somewhat doubtful since we already included most things anyways).

Differential Revision: https://code.wildfiregames.com/D3956
This was SVN commit r25430.
2021-05-13 17:23:52 +00:00
61e0aef0b4 Split JS conversions from ScriptInterface.
All ToJSVal/FromJSVal definitions are put in a separate header.
Remove AssignOr[To/From]JSVal duplication.

The functions were already static so this is rather straightforward.

Follows 34b1920e7b and 2bae30c454

Differential Revision: https://code.wildfiregames.com/D3953
This was SVN commit r25428.
2021-05-13 09:43:33 +00:00
6fbf036ae4 Split off StructuredClone from ScriptInterface
Follows 34b1920e7b.

This separates StructuredClone & DeepCopy logic into its own header,
reducing the size of the monolithic ScriptInterface header.

Differential Revision: https://code.wildfiregames.com/D3922
This was SVN commit r25419.
2021-05-10 11:51:32 +00:00
e94faf7827 Don't hardcode the "0ad" resource into lobby XMPP & hosting
XMPP JID has a concept of 'resources', which can be used to
differentiate multiple clients of the same account.

We currently hardcode this 'resource' to '0ad' in two places:
- The 0 A.D. client always uses '0ad'
- The network code expects a host resource to be '0ad' when connecting.

As noted in 0fd8aa2a77#31215, it is less effort to store the JI
D directly. This patch does that. It also makes 0 A.D. use a different
resource each time.
Note that resources ought not contain particular information, as the
XMPP server is free to
 clobber it. I keep '0ad-' here for debug purposes.

This allows:
- multiple 0 A.D. instances to log on the lobby at the same time (not
massively useful, but good for debugging sometimes)
- hosting a game with a custom resource, which will potentially make it
easier to have dedi
cated servers on one account.

Note that hosting multiple games on one account is currently not
supported and will have weird behaviour on the lobbybots side. They
should be upgraded independently of this.

Refs #3556

Differential Revision: https://code.wildfiregames.com/D3500
This was SVN commit r25407.
2021-05-09 12:51:32 +00:00
6d10a35d97 Fix some warnings.
- 25332f9b86 added 'override' to a method in ShaderProgram.cpp. This
adds it to the rest.
- BinarySerializer.cpp had custom JS includes, because putting those in
ScriptExtraHeaders failed. The cause is that gloox leaves "#define
lookup" up. This has been reported upstream, and fixed here.
- VS17 complains about an uninitialised variable, though the usage is
safe.

Differential Revision: https://code.wildfiregames.com/D3916
This was SVN commit r25359.
2021-05-02 15:45:40 +00:00
7376e43e06 Fix typos in log and warn messages
Patch by: LudovicRousseau
Refs: #6098

Differential Revision: https://code.wildfiregames.com/D3659
Differential Revision: https://code.wildfiregames.com/D3660
This was SVN commit r25033.
2021-03-10 16:50:15 +00:00
cb346e207b Refactor all usage of RegisterFunction to ScriptFunction::Register
- Replace ScriptInterface::RegisterFunction with
ScriptFunction::Register
 - Mostly removing unused cmpPrivate*
 - Some usage introduces specific getters (mapgenerator, AIWorker,
XmppClient,...)
 - Several passthrough functions are simply removed in favour of calling
the original, reducing duplication
 - Make use of ScriptRequest/ScriptInterface capabilities where
relevant.
- Make JSI_* headers only expose necessary functions, lightening them
considerably and reducing duplication
 - Reuse namespaces in JSI_* implementations directly, reducing visual
noise there

Follows f3aedf88a6

Differential Revision: https://code.wildfiregames.com/D3626
This was SVN commit r24983.
2021-03-02 20:01:14 +00:00
d078df0b85 Get the public IP from the lobby if not using STUN.
Follow-up to 1a8de6d2b8. This makes it again possible to host without
STUN via the lobby.
The lobby bot will answer the host "Register" command with the external
IP. This is only sent to the host, avoiding IP leakage.

There is a small window in which a client might try to join and the
public IP isn't up, and the request goes through, but that seems rather
unlikely to be a problem in practice.

Refs #5913

Differential Revision: https://code.wildfiregames.com/D3490
This was SVN commit r24858.
2021-02-08 15:47:34 +00:00
Angen
16a91c37e9 Limit possibility of brute force attacks when guessing password
As suggested by elexis, 1a8de6d2b8 should get some protection against
brute force attacks on password.

This is supposed to prevent attackers from getting connection data by
guessing the password.

Each failed attempt increases the counter.
XmppClient on the server side checks for the users with certain number
of failed attempts, determined in CNetServer, and refuses to check the
password, answering with banned message.
So they cant guess again in given match. Effect of this block will
dissapear after new match is created.

Differential revision: D3467
Comments by: wraitii, Stan
Tested by: Stan, Freagarach
Ref: #5913

This was SVN commit r24794.
2021-01-26 20:20:48 +00:00
Angen
3991dd6c38 Fix incorrect user identifier used in 0342f01580
iq uses lowercased version of user name, but patch was saving raw one.
Found by: @Freagarach
This was SVN commit r24733.
2021-01-20 19:54:16 +00:00
Angen
1a8de6d2b8 Hide ip and port from users until they want to join, add optional password
Current issue with the lobby, is that we make ips of hosts public for
anyone to read. This patch consists of 3 parts.
1.) Removing ips and ports from lobby javascript
2.) Removing need of script on the server to attach public ips to game
stanza by asking the host using xmppclient as proxy.
3.) Implementing password protected matches, to deny this information to
not trusted players.

Further description:
Do not send ports and stunip to the bots.

Removed from stanza.
Do not send ip to the lobby.

Removed from mapping gamelist from backend to gui (still on the backend
side, because it is done by script on 0ad server).
Get ip and ports on request when trying to connect.

On the host side, ask stun server what is host's public ip and remember
it.
On the client side, send iq through xmppclient to the hosting player and
ask for ip, port and if Stun is used, then if answer is success,
continue
   with connecting, else fail.
Add optional password for matches.

Add password required identifier to the stanza.
Allow host to setup password for the match. Hash it on the host side and
store inside Netserver. If no password is given, matches will behave
as it is not required.
On the client side, if password for the match is required, show
additional window before trying to connect and ask for password, then
hash it
and send with iq request for ip, port and stun.
Server will answer with ip, port and stun only if passwords matches,
else will asnwer with error string.
Some security:
Passwords are hashed before sending, so it is not easy to guess what
users typed. (per wraitii)
Hashes are using different salt as lobby hashing and not using usernames
as salt (as that is not doable), so they are different even typing the
same password as for the lobby account.
Client remembers which user was asked for connection data and iq's id of
request. If answer doesn't match these things, it is ignored. (thnx
user1)
Every request for connection data is logged with hostname of the
requester to the mainlog file (no ips).
If user gets iq to send connection data and is not hosting the match,
will respond with error string "not_server".
If server gets iq::result with connection data, request is ignored.

Differential revision: D3184
Reviewed by: @wraitii
Comments by: @Stan, @bb, @Imarok, @vladislavbelov
Tested in lobby

This was SVN commit r24728.
2021-01-20 18:31:39 +00:00
e009d322cc Add missing files in 4942cabab5
This was SVN commit r24488.
2020-12-31 14:27:02 +00:00
369c2e8801 Further header & precompiled cleanup, fix no-PCH builds.
GUIObjectBase is made a IGUIObject* to avoid including those headers
un-necessarily. Subsequent diffs ought to clean up the various of
pointers for that with a similar type with reference semantics.

Also:
- Add standard C and C++ headers (mostly cstring for memcpy, string and
vector) where needed.
- Swap out some includes for forward declarations
- Clean up un-necessary boost includes in precompiled and other headers.
- Clean up precompiled headers, including fewer things.
- Move ACPI to the windows-specific folder as it's included there only
and mostly specific to that platform.

Thanks Stan for the testing.

Differential Revision: https://code.wildfiregames.com/D3129
This was SVN commit r24352.
2020-12-09 14:39:14 +00:00
d92a2118b0 [SM78 2/2] Update to Spidermonkey 78 APIs
This ugprades 0 A.D. to the latest ESR at the moment of writing.

Mostly straighforward API changes (see meta-Bug 1633145)
- js::Class is merged with JSClass
- JSNewArrayObject becomes JS::NewArrayObject
- ArrayObject-functions are moved to a new public header Array.h
- JSMSG error messages have again been changed, requiring some tweaks.
- AutoValueArray becomes RootedBalueArray (Bug 1634435)
- 'uneval' is behind a Realm flag (Bug 1565170), but no removal is
planned in the short-term future.
- Some minor GC API changes (Bugs 1569564 and 1633405)
- Error reporting has had some tweaks, and error flags have been removed
(Bug 1620583)
- StructuredClone are now always thread-safe, simplifying an API change
introduced in SM52 (Bug 1607791)

Tested by: Stan, Freagarach, mammadori
Closes #5861

Differential Revision: https://code.wildfiregames.com/D3168
This was SVN commit r24333.
2020-12-06 14:03:02 +00:00
02578e46bf [SM68 2/2] Update to Spidermonkey 68 APIs
No noteworthy API changes.

Details:
- Remove UTF16 script execution since UTF8 is supported in SM68 and
going forward
- Several new headers includes are required
- Realms replace Compartments as "global holders" (see meta-Bug 1357862)
- JSRequests are removed entirely (Bug 722345), see also aae417bd29
- Trivial API updates in ProxyHandlers, ArrayBuffer, Warnings, GC
reasons, Context options, ObjectIsFunction, ValueVectors and
JSCompartment

See also the migration guide:
https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples/blob/esr78/docs/Migration%20Guide.md

Tested by: Freagarach, Stan, Subitaneo
Fixes #5860

Differential Revision: https://code.wildfiregames.com/D3144
This was SVN commit r24297.
2020-11-30 09:03:20 +00:00
fd8f5abd2e [SM52 2/2] Update to Spidermonkey 52 APIs.
No particularly noteworthy changes, as most complex API changes were
already supported in SM45 and done.
The addition of JSStructuredCloneData allows to remove our custom class.

Changes:
- InformalValueTypeName is back in the API, so remove our
implementation.
- Stop using JSRuntime entirely in favour of JSContext*
- JSPropertyDescriptor is renamed.
- CompartmentOptions are tweaked slightly (no functional changes)
- JS::Construct - API update.
- JSClass split - API update.
- A js.msg error message was removed, so we had to use a different one.
- Tests fix: fix comparison of union instances
- Disable warning in spidermonkey Vector.h
- Update error reporting to SM52 (minor API updates)
- Ignore warnings about unused return values (would come from OOM, which
isn't recoverable)

Most of the patching was done by Itms.

Tested by: Stan, Freagarach
Fixes #4893

Differential Revision: https://code.wildfiregames.com/D3095
This was SVN commit r24203.
2020-11-18 14:39:04 +00:00
25490bfec3 Improve JS Exception handling.
- Check for pending exceptions after function calls and script
executions.
- Call LOGERROR instead of JS_ReportError when there is a conversion
error in FromJSVal, since that can only be called from C++ (where JS
errors don't really make sense). Instead, C++ callers of FromJSVal
should handle the failure and, themselves, either report an error or
simply do something else.
- Wrap JS_ReportError since that makes updating it later easier.

This isn't a systematical fix since ToJSVal also ought return a boolean
for failures, and we probably should trigger errors instead of warnings
on 'implicit' conversions, rather a preparation diff.

Part of the SM52 migration, stage: SM45 compatible (actually SM52
incompatible, too).

Based on a patch by: Itms
Comments by: Vladislavbelov, Stan`
Refs #742, #4893

Differential Revision: https://code.wildfiregames.com/D3093
This was SVN commit r24187.
2020-11-15 18:29:17 +00:00
aae417bd29 Explicitly make ScriptInterface a Compartment wrapper.
ScriptInterface is now a wrapper around a JSCompartment, and thus always
has a well-defined global.

The error reporter is moved to ScriptRuntime in anticipation of that
handling JSContext in a later diff.

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3090
This was SVN commit r24180.
2020-11-14 08:46:32 +00:00
ee0d204bf6 Wrap JSAutoRequest and replace usage of JSContext* with the wrapper.
JSAutoRequest is required before calling into most JSAPI methods, for GC
reasons.
Calling it is required and fragile as one must not forget.
Further, SM52 and later make manipulating JSContext* dangerous as that
can cross Compartment(Realm in SM68) barriers (and ScriptInterface now
matches a Compartment).

The solution to both problems is to avoid using JSContext* in 0 A.D.
itself. To achieve this, a Request class is introduced, and must be used
to access a JSContext* from a scriptInterface. Further, Request is
passed to other ScriptInterface functions isntead of JSContext*, making
it obvious that the caller has already called it, reducing errors and
redundant JSAutoRequest calls.
Only JSNative functions now get a naked JSContext* without protection,
but the likelihood of forgetting a request is lower since many
ScriptInterface functions now expect it.

JSContext* is directly passed to JSAPI functions only.

Part of the SM52 migration, stage: SM45 compatible

Based on a patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3088
This was SVN commit r24176.
2020-11-13 13:18:22 +00:00
ace639f96f Use JS::Trace over CallXTracer
CallXTracer functions were removed in
https://bugzilla.mozilla.org/show_bug.cgi?id=1235598

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3092
This was SVN commit r24169.
2020-11-12 08:04:24 +00:00
413003fe4f Fix a compartment mismatch in XmppClient, causing crashes in MP games.
Added in 9023f4bebb, which changed lobby GUI messages to JS::Values,
requiring a real context. The original code mistakenly inverted the
owning script interfaces.

Given the reproducibility discovered in SM52, the timeline of the bug,
and the nature of the issues encountered in MP, this is a rather safe
fix for #5655.

Reviewed By: Itms
Fixes #5655

Differential Revision: https://code.wildfiregames.com/D2922
This was SVN commit r24116.
2020-10-31 10:13:33 +00:00
4b1a4ef4cf Rework ScriptInterface EnumeratePropertyNames to support non-enumerable properties.
This lets it support the JSClass syntax, introduced for components in
5fb88172a2/D2492, which required a workaround before.
As cleanup, remove the prefix logic which was too specific to be in
ScriptInterface, and use an upstream-compatible API that also does more
of what we want.

Based on a patch by: elexis
Differential Revision: https://code.wildfiregames.com/D2644
This was SVN commit r23771.
2020-06-14 09:49:32 +00:00
57636140b5 Fix typo (certifiacte -> certificate) imported from gloox in 0e2adda813, reported by pilino1234 on transifex, relayed via Angen on Phabricator.
This was SVN commit r23685.
2020-05-21 10:15:26 +00:00
df109bd246 Fix XmppClient upon registration or entering wrong password following 2cccd9825d/D2412.
Differential Revision: https://code.wildfiregames.com/D2482
Tested on: clang 9.0.1, Jenkins/VS2015, Jenkins/gcc6

This was SVN commit r23323.
2020-01-02 22:14:14 +00:00
2cccd9825d Rewrite lobby page to use class semantics, add more gamedetails labels, improve performance using batch processing and caching and gain possibility for game creation/player-join/leave events, refs #5387.
Game selection details features:
* Display victory conditions following their sending but missing display
following bffe917914, refs 7b0f6f530c.
* Display the host of the match and the game name in the selected game
details following 61261d14fc, refs D1666.
* Display mods if the mods differ (without having to attempt to join the
game prior) following eca956a513.

Performance features:
* Implement batch message processing in the XmppClient to rebuild GUI
objects only once when receiving backlog or returning from a match.
* Implement Game class to cache gamelist, filter and sorting values, as
they rarely change but are accessed often.
* Cache sprintf objects.

Security fixes:
* Add escapeText in lobby/ to avoid players breaking the lobby for every
participant, supersedes D720, comments by bb.
* Do not hide broadcasted unrecognized chat commands that mods used as
leaking private channels, fixes #5615.

Defect fixes:
* Fix XmppClient.cpp storing unused historic message types resulting in
memory waste and unintentional replay of for instance
disconnect/announcements messages following both e8dfde9ba6/D819 and
6bf74902a7/D2265, refs #3306.
* Fix XmppClient.cpp victoryCondition -> victoryConditions gamesetup.js
change from 6d54ab4c1f/D1240.
* Fix leaderboard/profile page cancel hotkey closing the lobby dialog as
well and removes cancel hotkey note from lobby_panels.xml from
960f2d7c31/D817 since the described issue was fixed by f9b529f2fb/D1701.
* Fix lobby playing menu sound in a running game after having closed the
lobby dialog following introduction in 960f2d7c31/D817.
* Fix GUI on nick change by updating g_Username.
* Update profile panel only with data matching the player requested.

Hack erasure:
* Object semantics make it cheap to add state and cache values, storing
literals in properties while removing globals, adding events while
decoupling components and gaining moddability.
* Erase comments and translation comments stating that this would be
IRC!!, supersedes D1136.
* Introduce Status chat message type to supersede "/special" chat
command + "isSpecial" property from bffe917914 (formerly g_specialKey
e6840f5fca) deluxe hack.
* Introduce System chat message type to supersede system errors
disguising as chat from a mock user called "system".

Code cleanups:
* Move code from XML to JS.
* Move size values from JS to XML, especially following 960f2d7c31/D817
and 7752219cef/D1051.
* Rename "user" to "player".
* Fix lobby/ eslint warnings, refs D2261.
* Remove message.nick emptiness check from 0940db3fc0/D835, since
XEP-0045 dictates that it is non-empty.
* Add translated string for deleted subjects.
* Add TODOs for some evident COList issues, refs #5638.

Differential Revision: https://code.wildfiregames.com/D2412
This was SVN commit r23172.
2019-11-21 13:44:41 +00:00
da958bf0e4 Fix wrong GlooxScriptConversions include in 9023f4bebb / D2264 triggering VS2015 build warning but no clang build warning, refs #5596.
Differential Revision: https://code.wildfiregames.com/D2298
Tested on: clang 8.0.1., Jenkins

This was SVN commit r22919.
2019-09-17 20:39:09 +00:00
cab920696c Implement glooxwrapper::MUCRoom argument for muc event handlers.
I.e. don't dereference NULL if the user of the glooxwrapper library
reads from the provided room argument.
A step towards being able to use XmppClient with multiple rooms.

Differential Revision: https://code.wildfiregames.com/D2287
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22898.
2019-09-13 15:24:44 +00:00
a84e2e57df Use ScriptInterface::CreateObject for ToJSVal<CColor>, and for ToJSVal<Grid<u8> >, ToJSVal<Grid<u16> > used by the AIManager obtaining the pathfinder grid.
Make that function static, so that it can be used for these functions
without slowly having to obtain the ScriptInterface instance using
GetScriptInterfaceAndCBData just to get the JSContext again.
Remove few redundant conversions for CreateObject arguments.

Differential Revision: https://code.wildfiregames.com/D2128
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Tedious performance testing in: D2128, D2127

This was SVN commit r22894.
2019-09-13 00:56:51 +00:00
4c454f3eee Fix missing wstring_from_utf8 for multi-user-chat messages and translated strings following 9023f4bebb / D2264.
The commit introduced support for arbitrary lobby CreateGUIMessage
JS::Value arguments but didn't transfer wstring_from_utf8 appropriately.
Instead of enlengthening the code by reintroducing utf8_from_wstring
everyhwere, shorten the code and specialize ToJSVal for
glooxwrapper::string and gloox enums.

Avoid string copies for XmppClient getters, refs D1668:
Change GetPresence() and GetRole() to return the pointer to the string
literal instead of copy constructing a std::string each call.
Don't reintroduce the unneeded utf8_from_wstring conversions for the
untranslatable ASCII identifiers returned by GetPresence() and
GetRole().
Change GetSubject() to return a const ref to the member instead of copy
assigning the std::string to an output value.
Change m_Subject to std::wstring to avoid constructing a copy using
wstring_from_utf8 each GetSubject() call.
Change gloox enum to translatable string functions to be static, so as
to use them in the new ToJSVal functions (enabled by not calling
CertificateErrorToString from ConnectionErrorToString anyymore in
92fc34c87c/D2274).

Avoid per-player string copies in m_PlayerMap:
Change m_PlayerMap value type from std::vector<std::string> to a new
PlayerMap struct with named members for readability.
Use gloox enums as PlayerMap values to avoid constructing (performance)
and storing (memory footprint) std::strings.
The JS String is created from the pointer to the ASCII string literal
without intermediaries.
Use glooxwrapper::string for nickname and m_Rating since it's the data
source type received in relevant places, but that might be improved for
performance with std::wstring.

Construct map values in place where possible and post error instead of
silently inserting if an existing value is to be modified.
Avoid repeated std::map lookups on string keys by caching the
PlayerMap::iterator where available.

Remove some glooxwrapper::string to_string() calls redundant with its
operator<< and improve DbgXMPP gloox enum output.
Transfer rating too upon nickchange.

Differential Revision: https://code.wildfiregames.com/D2271
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22891.
2019-09-12 17:23:33 +00:00
28aa7c20e4 Fix lobby playerlist rebuild following presence update message removal in 6bf74902a7/D2265.
Update the list when the data it is built from changes, not only for
presence changes.

Differential Revision: https://code.wildfiregames.com/D2283
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22888.
2019-09-11 11:51:34 +00:00
f77a3e289c Fix historic lobby kick messages following arbitrary CreateGUIMessage arguments in 9023f4bebb/D2264.
Perform the freezing for historic messages equally.

Differential Revision: https://code.wildfiregames.com/D2282
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22887.
2019-09-11 10:15:13 +00:00
92fc34c87c Pass XmppClient CertificateErrorToString independent of ConnectionErrorToString to JS using D2264 / 9023f4bebb, refs #4482.
This also allows making the enum to string functions static, refs D2271.

Differential Revision: https://code.wildfiregames.com/D2274
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22880.
2019-09-09 21:26:58 +00:00
158ba53a46 Fix missing XmppClient m_certStatus and m_PresenceUpdate member initialization following 0e2adda813 and 6bf74902a7.
This might explain unexpected TLS certificate error strings upon failed
TLS handshake, refs #4705.
Might or might not fix a conditional valgrind conditional jump depending
on uninitialized value error reported in P170 for the XmppClient
constructor (inconsistent test results).

Differential Revision: https://code.wildfiregames.com/D2278
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins

This was SVN commit r22879.
2019-09-09 20:50:17 +00:00
ee726a155c Translate lobby TLS certificate error strings following 0e2adda813 and string freeze lift, refs #4705.
Differential Revision: https://code.wildfiregames.com/D2272
This was SVN commit r22875.
2019-09-09 14:33:30 +00:00
10f805fcf4 Fix wrong "player is not a moderator anymore" lobby chat message following initial implementation in 76bc9b579a/D339, fixes #4877.
It needs to test against the historic role and not the current role,
similar to 8b437a0b1c, refs #3386.
Implements the third GUI message property using the arbitrary lobby GUI
message patch in 9023f4bebb/D2264, refs #4482, 6bf74902a7/D2265.

Differential Revision: https://code.wildfiregames.com/D2266
Tested on: clang 8.0.1

This was SVN commit r22859.
2019-09-06 16:56:43 +00:00
9023f4bebb Support creating lobby GUI messages with arbitrary arguments instead of forcing every message type into the same struct type, refs #4877 / 76bc9b579a / D339.
Creates the GUI messages directly as JS::Values and removes the
intermediary rigid struct.
Implementation similar to ScriptInterface::CreateObject from D2080.

Differential Revision: https://code.wildfiregames.com/D2264
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22856.
2019-09-06 05:14:20 +00:00
6bf74902a7 Drop lobby presence GUI messages altogether for better performance and less code complexity.
They were only used to determine whether the playerlist should be
rebuilt, which can be achieved by a boolean member.
So this patch is removing unnecessary indirection from the original
solution in 8b437a0b1c and the reduction in 16b976fc35, refs #3386.
In particular the LobbyClearPresenceUpdates call was ugly and one doesnt
need hundreds of messages with data on it each if one only wants to know
if there was one.
Makes past (e8dfde9ba6) and future (D2264) patches less complex, refs
#4877.

Differential Revision: https://code.wildfiregames.com/D2265
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins

This was SVN commit r22855.
2019-09-06 02:53:22 +00:00
24f97d9fd5 Fix unreported glooxwrapper leaks following 61261d14fc, refs #2305.
Fixes an occurring leak indicated by the reported clang unused variable
compiler warning, refs #5294, #5550,
by adding the missing glooxwrapper::Jingle::Session::Session destructor
.

Fix two leaks that would have occurred if the according code had been
used:
Delete unused glooxwrapper::Jingle::ICEUDP::ICEUDP instead of adding the
missing destructor.
Delete unused glooxwrapper::Jingle::Content::Content instead of adding
the missing destructor.

Explain why glooxwrapper::Client::registerStanzaExtension doesn't leak
the new StanzaExtensionWrapper.
Explain why glooxwrapper::Jingle::Session::sessionInitiate doesn't leak
the new gloox::Jingle::Content, nor the new gloox::Jingle::ICEUDP.
Explain why glooxwrapper::SessionManager::registerPlugins doesn't leak
the new gloox::Jingle::Content and new gloox::Jingle::ICEUDP.
Explain why glooxwrapper::SessionManager::createSession doesn't leak the
gloox::Jingle::Session.

I will not leak memory in the glooxwrapper.
I will not leak memory in the glooxwrapper.
I will not leak memory in the glooxwrapper.

Use references in the StunClient and glooxwrapper to anticipate any
confusion as to whose obligation it is to delete variables when they are
passed around across several files.
Use static_cast and reinterpret_cast instead of C-style casts in the
StunClient.

Differential Revision: https://code.wildfiregames.com/D2094
Refs D2093 for the reported leaks.
Reviewed By: Josh
Comments By: fcxSanya, Vladislav for D2094, and echotangoecho, leper in
61261d14fc

This was SVN commit r22678.
2019-08-17 00:12:19 +00:00
b4626359f5 Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later.
Differential Revision: https://code.wildfiregames.com/D2080
Previous version reviewed By: Krinkle
Comments By: historic_bruno, wraitii
This was SVN commit r22528.
2019-07-22 19:35:14 +00:00
498d58e24d Fix reported memory leaks in the glooxwrapper following 61261d14fc
Differential Revision: https://code.wildfiregames.com/D2093
Reviewed By: elexis
This was SVN commit r22514.
2019-07-19 19:46:48 +00:00
bb
0b1593e268 recieve -> receive
Reported by Stan in 13288df4f4

This was SVN commit r22169.
2019-04-07 16:06:10 +00:00
1bd9f4393b Allow users to disable TLS encryption entirely in the GUI to ease use of the lobby if gloox/GnuTLS crashes upon TLS handshake, refs #5349, #4705.
Differential Revision: https://code.wildfiregames.com/D1679
Based on patch by: Itms
Tested on Fedora: Itms, bb and myself

This was SVN commit r21932.
2018-11-27 14:41:44 +00:00