Commit graph

974 commits

Author SHA1 Message Date
heinrich5991 d7019a244e Get rid of the MySQL C++ connector as a dependency
We now use the C API directly. This has the advantage of using one
obscure dependency less, as the C++ connector also used the C API.
2021-02-24 17:34:08 +01:00
Alexander Akulich 6b49bf1388 Make spectators stay specs on map changed
Based on PRs to the upstream:
https://github.com/teeworlds/teeworlds/pull/2065
https://github.com/teeworlds/teeworlds/pull/2066

Co-authored-by: Jordy Ruiz <jordy.ruiz@univ-lille.fr>
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2021-02-23 19:36:52 +03:00
Alexander Akulich 2790270abf Adopt upstream refactoring: Mark several functions as 'const' 2021-02-23 18:26:16 +03:00
bors[bot] 2b5723cdef
Merge #3492 #3559 #3561 #3565
3492: Support F-Client and replace non-extended extension messages r=Learath2 a=heinrich5991

This continues what #3439 started, and also replaces non-extended messages that are DDRace extensions with extended messages. The DDNet server still sends the old message to old clients and the DDNet client still understands the old messages.

Supersedes #3439.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


3559: Don't highlight us if we have no name (alternative fix for #3554) r=heinrich5991 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


3561: Fix input message position in teehistorian files r=heinrich5991 a=Zwelf

Previously the message was recorded when incoming. But the time when the input should apply wasn't recorded. Now inputs are recorded right before they get applied in the game world.

And record exact tick where load/save result is returned.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


3565: Add Arabic language translation by .Yukki r=heinrich5991 a=def-

![screenshot-20210131@093216](https://user-images.githubusercontent.com/2335377/106378755-747d7780-63a7-11eb-9553-6a1898907441.png)

## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: def <dennis@felsin9.de>
Co-authored-by: Zwelf <zwelf@strct.cc>
2021-01-31 14:37:48 +00:00
heinrich5991 43998ce41a Replace projectile hack with a new extended snapshot object
Still send the old hack to old clients, still accept the old hack from
old servers. This is so F-Client can support DDNet servers without such
hacks.
2021-01-26 20:58:42 +01:00
bors[bot] 29fbaddce4
Merge #3520
3520: Fix median calculation r=Learath2 a=def-

as reported by I.K.U on Discord

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2021-01-21 10:05:32 +00:00
def b3062d04a0 Fix median calculation
as reported by I.K.U on Discord
2021-01-21 11:02:01 +01:00
Zwelf cf80ace45a Remove locking from database interface 2021-01-20 21:55:22 +01:00
Zwelf bad2d71d77 Add ExecuteUpdate to database interface reporting affected rows 2021-01-20 21:42:25 +01:00
bors[bot] cdb5a5c280
Merge #3519
3519: Send logout packet after using timeout protection r=def- a=heinrich5991

Only send the logout packet if you're actually logged in.

Fixes #3490. Supersedes #3495.

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2021-01-17 18:00:00 +00:00
heinrich5991 91b1f62fa0 Send logout packet after using timeout protection
Only send the logout packet if you're actually logged in.

Fixes #3490. Supersedes #3495.
2021-01-17 17:44:48 +01:00
bors[bot] 174eeab80d
Merge #3504
3504: Display median time instead of average (fixes #3399) r=heinrich5991 a=def-

Do we want average too or just median?

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2021-01-17 16:40:50 +00:00
heinrich5991 b66e090425 Also display DDNet version for 0.7 clients 2021-01-15 22:39:18 +01:00
nobody-mb 46387373d1
show sixup in status (#3512)
* show sixup in status

* format sixup in status

* str_copy
2021-01-15 19:26:40 +01:00
Zwelf 0aed8cf8eb Fix memory leak in SQLite3 print statement
https://www.sqlite.org/c3ref/expanded_sql.html
2021-01-14 19:47:01 +01:00
def 39d06c5e85 Display median time instead of average (fixes #3399) 2021-01-12 14:24:38 +01:00
heinrich5991 0d916e2ef6 Remove F-Client-specific messages
The PLAYERFLAG_AIM can now be set directly on DDNet servers via the 0.7
bridge and will be sent to clients identifying themselves as DDNet
clients.

Add a new extended message that mirror the old `Sv_TeamsState`.
2021-01-12 01:38:23 +01:00
fokkonaut 9940a806fa Support for F-Client 2021-01-12 01:38:23 +01:00
Alexander Akulich c2f276cee1 Port CConfig API from the upstream (0.7.5)
The old (g_Config) API is kept to not break the stuff.

See commits:
    de5859b371
    78076761eb
2021-01-10 17:10:19 +03:00
Alexander Akulich 09c05ab99f Port CConsole::Init() from the upstream code
Partial port of upstream commit c0bf37fb48
2021-01-10 16:51:18 +03:00
def 7260dec878 Don't print name change message when trying to change to banned name
Introduced in https://github.com/ddnet/ddnet/pull/3095/files?w=1
2020-12-19 11:21:15 +01:00
Zwelf b256250b7b Synchronize database thread via atomic_bool instead of use_count from shared pointer 2020-12-08 18:11:00 +01:00
Edgar 105b049497
Rename lock and semaphore classes to match current naming 2020-11-29 18:12:58 +01:00
bors[bot] d80d1df0db
Merge #3297 #3305 #3307
3297: Fix memleak in CServer on instant shutdown r=Jupeyy a=def-

```
Direct leak of 566869 byte(s) in 1 object(s) allocated from:
    #0 0x4f28e3 in __interceptor_malloc (/home/teeworlds/servers/DDNet-Server-asan+0x4f28e3)
    #1 0x55b3c9 in CServer::LoadMap(char const*) /home/teeworlds/src/master/src/engine/server/server.cpp:2312:49
    #2 0x55bfdd in CServer::Run() /home/teeworlds/src/master/src/engine/server/server.cpp:2351:6
    #3 0x56add2 in main /home/teeworlds/src/master/src/engine/server/server.cpp:3553:21
    #4 0x7f54401cd09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
```

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


3305: DemoRecorder: Only remove existing filenames r=Jupeyy a=def-

As noticed by Jupstar

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


3307: Don't crash with debug mode in demo r=Jupeyy a=def-

Since character doesn't exist then. Reported by murpi

Originally introduced in https://github.com/ddnet/ddnet/pull/2578

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2020-11-13 10:31:20 +00:00
Zwelf 03179af14d Fix updating points on SQLite3 backend 2020-11-11 20:27:22 +01:00
bors[bot] a12ec3c9a8
Merge #3279
3279: Add a script to check for variable name style violations, fix some variable names r=def- a=heinrich5991

Didn't fix all variable names because there were far too many. Ideas? At least the second commit should probably go in.

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-11-11 17:42:12 +00:00
def 71674b13da Fix memleak in CServer on instant shutdown
Direct leak of 566869 byte(s) in 1 object(s) allocated from:
    #0 0x4f28e3 in __interceptor_malloc (/home/teeworlds/servers/DDNet-Server-asan+0x4f28e3)
    #1 0x55b3c9 in CServer::LoadMap(char const*) /home/teeworlds/src/master/src/engine/server/server.cpp:2312:49
    #2 0x55bfdd in CServer::Run() /home/teeworlds/src/master/src/engine/server/server.cpp:2351:6
    #3 0x56add2 in main /home/teeworlds/src/master/src/engine/server/server.cpp:3553:21
    #4 0x7f54401cd09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2020-11-11 17:24:51 +01:00
def 225787ea39 Fix invalid server-assigned utf8 names with (1) prefix (fixes #3269) 2020-11-09 18:10:55 +01:00
heinrich5991 7663641ed2 Fix some variable name's style 2020-11-08 17:15:48 +01:00
bors[bot] 556f64775e
Merge #3242
3242: Enable most clang-tidy bugprone-*, misc-*, performance-* checks r=Jupeyy a=def-

Fixes #3134

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2020-11-07 20:15:30 +00:00
def 312b9d3bd8 Enable clang-tidy performance-* checks 2020-11-05 11:34:20 +01:00
def 5b5cfa7d9e nick name -> nickname 2020-11-05 09:32:14 +01:00
def ed27c49eea Fix bugprone-unused-return-value 2020-11-05 08:25:34 +01:00
def ba53c7e20c Add most bugprone checks 2020-11-05 08:25:26 +01:00
def 165857a5a8 Fix variable names manually 2020-11-02 22:40:40 +01:00
def b1f0fd8969 Enable modernize-loop-convert clang-tidy check
and run clang-format afterwards

https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html
2020-11-02 22:40:24 +01:00
Zwelf 6eb95c6b96 Fix random_map and random_unfinished_map on SQLite server 2020-10-28 22:36:54 +01:00
bors[bot] 2ba4d5d6cb
Merge #3136
3136: Fix some asan issues r=Jupeyy a=def-



Co-authored-by: def <dennis@felsin9.de>
2020-10-22 15:26:41 +00:00
bors[bot] 2709afb007
Merge #3095
3095: Disallow player name changes when the player is muted r=def- a=heinrich5991



Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-10-20 15:56:16 +00:00
Zwelf aa53f28449 Fix memory leak in MySQL getBlob function
Direct leak of 768 byte(s) in 2 object(s) allocated from:
    #0 0x4e91ad in operator new(unsigned long)
    #1 0x7f0c54a3bf63 in sql::mysql::MySQL_Prepared_ResultSet::getBlob(unsigned int) const (/usr/lib/x86_64-linux-gnu/libmysqlcppconn.so.7+0x77f63)
2020-10-19 14:00:53 +02:00
def 1081a6870c Put CLineReader on stack so we can't forget to delete it
Found in https://github.com/ddnet/ddnet/issues/3134

Direct leak of 360712 byte(s) in 11 object(s) allocated from:
    #0 0x51fb22 in operator new(unsigned long) (/home/teeworlds/servers/DDNet-Server-asan+0x51fb22)
    #1 0x561d77 in CServer::GetAnnouncementLine(char const*) /home/teeworlds/src/master/src/engine/server/server.cpp:3563:20
    #2 0x5c00a7 in CGameContext::OnTick() /home/teeworlds/src/master/src/game/server/gamecontext.cpp:971:32
    #3 0x556073 in CServer::Run() /home/teeworlds/src/master/src/engine/server/server.cpp:2544:19
    #4 0x561a56 in main /home/teeworlds/src/master/src/engine/server/server.cpp:3537:21
    #5 0x7f2349f3809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2020-10-18 12:57:36 +02:00
Learath2 ba7b95f7ad Revert #3066
This reverts commits:
	a2b3f45f8b
	26a07c804f
2020-10-17 17:32:52 +02:00
heinrich5991 6ff53358d3 Remove code for CRC in most places, except where needed for net compat
This should path the way to remove it altogether in the future.
2020-10-14 17:08:58 +02:00
heinrich5991 246d2ac3d6 Allow IServer users to check when client's names change
Use that available interface to process name change spam protection more
cleanly.
2020-10-14 16:42:35 +02:00
def 0867424749 Fix clang-analyzer-security.insecureAPI.strcpy
/media/ddnet/src/engine/server/sql_string_helpers.cpp:74:3: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
2020-10-14 15:45:47 +02:00
heinrich5991 a2b3f45f8b Reintroduce CMDFLAG_TEST
Add some more helpful messages for executing test/game commands.
2020-10-11 16:27:28 +02:00
Andrii 26a07c804f Disallow game-related commands unless testing is enabled 2020-10-11 16:02:10 +02:00
12pm e34acce0cd increase buffer size for name_ban messages 2020-10-11 14:25:31 +02:00
def 5ec702ad2f Use rest instead of string in some commands
where it makes sense, means you don't need to quote strings for those
2020-10-04 17:52:05 +02:00
Dennis Felsing cb2fa0800f
Merge pull request #2934 from def-/pr-show_ips2
Fix show_ips on non-SQL servers
2020-09-27 10:38:37 +02:00
Zwelf cb2c1d2144 Fix cutting of one character when showing ips in rcon
The buffer size passed to `str_append` includes the null terminator.
2020-09-27 10:15:41 +02:00
def b0b47e1286 Fix show_ips on non-SQL servers
Mistake was introduced in 7c31a15c93

We didn't notice since official servers are SQL, except Block servers,
and we just started moderating them a bit.
2020-09-27 01:16:18 +02:00
def 3be8a592e5 Run clang-format
Purely automatic change. In case of conflict with this change, apply the
other change and rerun the formatting to restore it:

$ python scripts/fix_style.py
2020-09-26 21:50:15 +02:00
def 0bac9f0de8 Manual preparation for cleaner clang-format
Also include what you use explicitly
2020-09-26 21:41:01 +02:00
def 6ce04d93f1 Server: Only recv new packets when we know they are waiting
Reduces the number of syscalls
2020-09-15 19:11:51 +02:00
Zwelf a78e84d724 Only call sqlite3_expanded_sql when it exists
Only print expanded SQLite statement, when expanding function exists. This is
required to not bump the minimum required Ubuntu version, since Ubuntu 16.04
doesn't ship SQLite 3.14 or above. SQLite introduced ``sqlite3_expanded_sql`
in 3.14, Ubuntu 16.04 packages 3.11.

Disabled weak linking on MSVC, since it isn't supported.
2020-09-10 20:22:37 +02:00
Zwelf 88dc1c1a9c Add print functionality to SQLite 2020-09-10 20:16:42 +02:00
Zwelf 46b0ff354e Align InsertIgnore with other SQL query related functions 2020-09-10 20:16:42 +02:00
def 28cd437684 Document which commands only work in initial config (fixes #2773) 2020-09-07 12:31:00 +02:00
def 1fd5c3ebc3 Try out higher mysql timeouts 2020-09-06 21:51:31 +02:00
Dennis Felsing dde40779fe
Merge pull request #2737 from def-/pr-ignore
INSERT OR IGNORE on sqlite
2020-09-04 16:27:20 +02:00
bors[bot] e3b879f616
Merge #2736
2736: Let 0.7 clients fastdownload too r=def- a=Learath2

Easier than expected, I wonder why I didn't do this at the start.

Co-authored-by: Learath <learath2@gmail.com>
2020-09-04 14:17:32 +00:00
def c3f9dc7c9f INSERT OR IGNORE on sqlite 2020-09-04 16:12:12 +02:00
Learath b8242689c6 Let 0.7 clients fastdownload too 2020-09-04 16:45:49 +03:00
def a51f38e6b8 Fix syntax for primary key tables 2020-08-31 23:14:58 +02:00
Dennis Felsing 958d75abf1
Merge pull request #2663 from def-/pr-duplicate-db
Ignore duplicate records when inserting (fixes #2636)
2020-08-29 15:02:46 +02:00
def 7417c2f937 Introduce primary keys for record_race and record_teamrace 2020-08-29 14:53:36 +02:00
heinrich5991 31cfa9250d Fix server port in teehistorian
Official servers weren't affected because they didn't use the default of
`sv_port 0`.
2020-08-29 14:14:37 +02:00
Andrii cec8bf2195 Read server port from CNetServer but not from app config 2020-08-27 19:54:44 +03:00
def d41a6e6878 Give a more instructive message on DNSBL ban 2020-08-25 13:41:38 +02:00
Zwelf 2cbbd9088b Fix copy paste error 2020-08-21 22:43:22 +02:00
Dennis Felsing b2ebcb4f3c
Merge pull request #2623 from Zwelf/pr-mysql-enhance-unreachable-server-situation
MySQL enhance unreachable server situation
2020-08-21 20:15:49 +02:00
Zwelf 3a30dfbd84 Keep connecting to last reachable MySQL server 2020-08-21 19:46:44 +02:00
Zwelf a808ad5463 Enhance SQL error reporting 2020-08-21 10:37:52 +02:00
Learath 97b6704a6b Add ban_region_range and sv_region_name 2020-08-19 14:07:55 +03:00
Learath 6a936602aa Add ban_region 2020-08-19 12:38:49 +03:00
Zwelf 961ad077fb Don't print MySQL password to console 2020-08-09 18:18:25 +02:00
Zwelf 5893913922 Clean up includes in sql backend 2020-08-09 17:54:25 +02:00
Zwelf 61ffd88f34 Reformulate #if not defined() because MSVC errors on this expression 2020-08-09 17:13:21 +02:00
Zwelf b2cf3cafc5 Implement dump_sqlserver 2020-08-03 16:37:50 +02:00
Zwelf 9e1979f561 Rename Database connect result from ERROR to FAILURE 2020-08-03 13:11:52 +02:00
Zwelf c6b1b08355 Database specific collate utf8 nocase
making and work
2020-08-03 12:58:52 +02:00
Zwelf d16bb5cc08 Make timestamps compatible with SQLite
works for `/mapinfo`, `/load`, `/save`, `/times`
2020-08-03 12:58:52 +02:00
Zwelf 044edbe42b Make storing teamrank compatible with SQLite 2020-08-03 12:58:52 +02:00
Zwelf e3a78a7a31 Add BindBlob and BindFloat function to IDbConnection interface 2020-08-03 12:58:52 +02:00
Zwelf 26a2c91235 Trying to reconnect when ongoing MySQL connection failed 2020-08-03 12:58:52 +02:00
Zwelf eb4d77f071 Make inserting ranks compatible with SQLite 2020-08-03 12:58:52 +02:00
Zwelf 17de42a947 Implement locking in SQLite 2020-08-03 12:58:52 +02:00
Zwelf 1677e1fed5 Gracefully shutdown database pool 2020-08-03 12:58:52 +02:00
Zwelf 00da45191c Make CREATE TABLE compatible with SQLite 2020-08-03 12:58:52 +02:00
Zwelf 452017a58b Move format string to CREATE TABLE into own file 2020-08-03 12:58:52 +02:00
Zwelf 2c5f892205 Apply suggestions from code review 2020-08-03 12:58:52 +02:00
Zwelf b898f8c7c2 Remove unused MySQL interface 2020-08-03 12:58:52 +02:00
Zwelf 7c31a15c93 Add SQLite interface 2020-08-03 12:58:52 +02:00
Zwelf 2eb3d23ef4 Rewrite score using the new interface
delete file_score for now as it will be replaced by a sqlite backend
2020-08-03 12:58:52 +02:00
Zwelf 295ce95d64 Roughly define database pool interface 2020-08-03 12:58:52 +02:00
Zwelf d59cdf47b5 Define new database interface 2020-08-03 12:58:52 +02:00
def c8876b2c02 Fix legacy 64 player serverinfo, don't send duplicate packets (fixes #2495)
For legacy we sent the first packet once correctly, then the 2nd and 3rd
packet without the marker and token at the start, so they never worked.

For new 64 player serverinfo we sent all packets correctly but the 1st
packet twice.

Introduced in #1955.
2020-07-13 00:19:00 +02:00
def a34c72530b Some minor improvements to sv_port 0, make it default 2020-07-09 18:28:20 +02:00
MikiGamer f7eda384ea changes for auto port 2020-07-09 17:48:03 +02:00
MikiGamer beaadca6a9 switch, limited tries & sv_port 0 2020-07-09 17:47:30 +02:00
MikiGamer 6a87278c3d find available port 2020-07-09 17:46:22 +02:00
def 66c7bf8851 Tell why DNSBL isn't allowing to vote (fixes #2466) 2020-07-07 23:12:55 +02:00
def f15ac1d869 Fix uninitialised values in sixup differently (fixes #2421)
"./DDNet-Server shutdown" still works
2020-07-07 10:26:44 +02:00
Zwelf 6be35cd4e7 Remove unused function 2020-07-03 20:13:51 +02:00
Learath 416cb37000 Send Sixup information to antibot 2020-07-01 21:09:58 +03:00
heinrich5991 358735aadb Revert "Don't run UpdateServerInfo if server isn't initialized yet"
This reverts commit e69f747e5f.

Fixes `shutdown` on the initial command line which is also used on CI.
2020-07-01 17:45:01 +02:00
def e69f747e5f Don't run UpdateServerInfo if server isn't initialized yet
or currently shutting down anyway. Fixes the first half of #2421
2020-06-30 18:33:22 +02:00
Learath 8d8f1d7208 Only SendChat to clients that exist. Initialize m_Sixup anyway 2020-06-30 18:58:44 +03:00
bors[bot] 1750bb09f7
Merge #2335 #2336 #2340 #2342 #2349
2335: Make it more clear that this is a sixup translation server r=heinrich5991 a=def-



2336: Set skill level for Sixup (fixes #2334) r=heinrich5991 a=def-



2340: Keeping multiple states consistent is hard (fixes #2315) r=heinrich5991 a=def-

let's go recount every time

2342: Don't forget video recorder fps setting r=heinrich5991 a=def-

after switching to non-videorecorder client

2349: Document which MySQL/MariaDB versions we require (fixes #2343) r=heinrich5991 a=def-



Co-authored-by: def <dennis@felsin9.de>
2020-06-24 14:37:53 +00:00
def 5b3b42b771 Make it more clear that this is a sixup translation server 2020-06-24 14:49:23 +02:00
def a8a2b41f3a Set skill level for Sixup (fixes #2334) 2020-06-23 22:47:29 +02:00
Learath f327e5bc42 Log join type 2020-06-23 18:30:57 +03:00
def 252cda2d49 Use str_comp instead of strcmp
error: ‘strcmp’ was not declared in this scope
2020-06-22 14:47:49 +02:00
Learath 28905c4659 Disable timeout for 0.7 clients 2020-06-20 19:52:23 +03:00
Learath 6db72b2388 Times are no longer negative in 0.7 2020-06-20 11:59:46 +03:00
Learath 91c44f1808 Sixup needs it's own maps 2020-06-20 01:00:45 +03:00
bors[bot] 5b4227fbba
Merge #2283
2283: teehistorian: Track whether clients join via the 0.7 protocol r=Learath2 a=heinrich5991



Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-06-19 20:31:40 +00:00
heinrich5991 e294da41ba teehistorian: Track whether clients join via the 0.7 protocol 2020-06-19 22:06:39 +02:00
Learath da68923ac3 Implement a switch for 0.7 compatibility 2020-06-19 22:08:41 +03:00
Learath aeb7ea2971 Don't forget that the client is Sixup 2020-06-19 20:28:55 +03:00
Learath 70ecf785bb Compatible version filter 2020-06-19 20:28:55 +03:00
Learath 9f71478099 Get Rcon working 2020-06-19 20:28:55 +03:00
Learath 88ca573682 Serverinfo and Register support for 0.7
Co-authored-by: Tim Schumacher <tim@timakro.de>
2020-06-19 20:28:55 +03:00
Learath 9e2434c65d Better skin colors. Better game message translation 2020-06-19 20:28:55 +03:00
Learath 9dc1a0357a Get /spec working 2020-06-19 20:28:55 +03:00
Learath 03070d0567 Fix many issues 2020-06-19 20:28:52 +03:00
Learath 807c92f1a4 Generate the 0.7 protocol 2020-06-19 20:27:15 +03:00
Learath f7e9df7abf Move the rest of the translation to CServer 2020-06-19 20:27:15 +03:00
Learath b0e5a37fa9 Do message translation differently 2020-06-19 20:27:15 +03:00
Learath 5000b248bb Fix things 2020-06-19 20:27:15 +03:00
Tim Schumacher 442148a194 Begin work on 0.7 support 2020-06-19 20:27:15 +03:00
bors[bot] 6f8f606e05
Merge #2276
2276: Fix segmentation fault when creating sql tables failed r=heinrich5991 a=Zwelf

`GameServer()->OnShutdown(true);` (which would wait on running threads to exit)
wasn't called if an error occured in the server init. Therefore `CServer` was
freed before the init-thread finished executing, causing a use after free from
`CSqlConnector::ms_ppSqlReadServers` pointing to `CServer->m_apSqlReadServers`.

Fixes #2271 

Note that the server exits when creating tables failed. Since the tables are created by default, it has to be disabled explicitly (e.g. `add_sqlserver r teeworlds record teeworlds PASSWORD "localhost" 3306 0`) if the servers should start even when the database connection fails.

Co-authored-by: Zwelf <zwelf@strct.cc>
2020-06-18 19:23:00 +00:00
Zwelf f5ac6eea56 Fix segmentation fault when creating sql tables failed
`GameServer()->OnShutdown(true);` (which would wait on running threads to exit)
wasn't called if an error occured in the server init. Therefore `CServer` was
freed before the init-thread finished executing, causing a use after free from
`CSqlConnector::ms_ppSqlReadServers` pointing to `CServer->m_apSqlReadServers`.
2020-06-18 21:11:36 +02:00
def 882185e299 Make SaveID DEFAULT NULL 2020-06-18 10:32:58 +02:00
Zwelf f1b2ff086c Clean up thread safe SQL refactor 2020-06-17 21:15:07 +02:00
Zwelf ea31171873 Generate passphrase for save-code
* when none is given
* if the given save-code already exist
* if the database connection fails therefore it can't be checked if the save-code already exists

Using the short word list from eff:
https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2020-06-15 11:14:15 +02:00
Zwelf 528ca377ed Thread safe saving of team score 2020-06-15 11:14:15 +02:00
Zwelf 62d56ca8e8 Make database init with create tables synchronous
Note: database init without creating tables behaves the same
2020-06-15 11:14:15 +02:00
Zwelf 031ac52320 Thread safe /save 2020-06-15 11:14:15 +02:00
Zwelf 4152a1995e Add missing dependeny to sql string helper 2020-06-15 11:14:15 +02:00
bors[bot] 92fc95d742
Merge #2202
2202: Send DDNet version early in the connection process r=Learath2 a=heinrich5991

This gets rid of the problem that we don't know whether we should send
full snapshots to clients because they haven't told us about them being
DDNet yet.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-05-27 17:49:31 +00:00
heinrich5991 f339fea748
Merge pull request #2139 from edg-l/pr_add_upnp
Add UPnP support
2020-05-24 22:23:20 +02:00
Edgar 3569e174f2
refactor upnp code 2020-05-24 11:36:43 +02:00
heinrich5991 0d7872c79e Send DDNet version early in the connection process
This gets rid of the problem that we don't know whether we should send
full snapshots to clients because they haven't told us about them being
DDNet yet.
2020-05-22 17:58:41 +02:00
Learath 850e4e84e4 Reserve bytes for the type and token 2020-05-18 21:13:15 +03:00
Learath 788fc8bb5f Update can happen when the gameserver doesn't exist 2020-05-18 16:17:06 +03:00
Learath 1426392ae7 Don't Destroy if we didn't Init 2020-05-16 23:10:42 +03:00
heinrich5991 457c4db964 Some antibot fixes 2020-05-16 00:39:17 +02:00
Learath eacc56059b Keep ticks going 2020-05-15 19:29:34 +03:00
Learath 5e02bb5a23 Extend antibot interface
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-05-13 23:39:40 +03:00
Ryozuki b647c1e978
Add UPnP support 2020-04-14 12:11:50 +02:00
bors[bot] 7a3ebd5948
Merge #2041
2041: Strip spaces in browser (server name) r=heinrich5991 a=ChillerDragon

before:
![image](https://user-images.githubusercontent.com/20344300/72688976-b45f1d00-3b0c-11ea-8920-5328c6d721f7.png)
after:
![image](https://user-images.githubusercontent.com/20344300/72688970-9db8c600-3b0c-11ea-8636-330218d75ca1.png)


Co-authored-by: KillaBilla <robomastermail@googlemail.com>
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-01-25 12:45:36 +00:00
bors[bot] 749929431a
Merge #2040
2040: fixed faulty message id r=heinrich5991 a=ChillerDragon

(cherry picked from commit 9023796d27)

Co-authored-by: oy <Tom_Adams@web.de>
2020-01-25 12:40:14 +00:00
12pm ec42291756 Allow filtering by name in status
Easier to find players when the server is full
2020-01-24 14:44:54 +01:00
KillaBilla ba1abac52f remove leading and trailing space from server name and forbit the use of multiple spaces
(cherry picked from commit a9cc1e8de2)
2020-01-19 22:28:19 +01:00
oy 1b4131a7fd fixed faulty message id
(cherry picked from commit 9023796d27)
2020-01-19 21:30:12 +01:00
Learath d2fad6c79a Fix demo bug 2020-01-03 12:13:40 +03:00
ChillerDragon 4a6a85124a Remove some unused includes 2019-12-14 10:20:42 +01:00
def 18e2232727 Add support to tell DDNet7 ranks apart from DDNet ones
Saves should not be loadable from one to the other.

Requires:
ALTER TABLE record_race ADD COLUMN DDNet7 BOOL DEFAULT FALSE AFTER GameID;
ALTER TABLE record_teamrace ADD COLUMN DDNet7 BOOL DEFAULT FALSE AFTER GameID;
ALTER TABLE record_saves ADD COLUMN DDNet7 BOOL DEFAULT FALSE AFTER Server;
2019-12-08 16:04:49 +01:00
Dennis Felsing 785ec3d345 Expire server info on connected/drop events 2019-11-04 15:45:55 +01:00
Learath2 c2bcd3bd4d Fix bug 2019-11-04 01:06:52 +01:00
bors[bot] 0de012572b
Merge #1955
1955: Cache serverinfo responses r=def- a=Learath2

I'm not sure I like it but it works

Co-authored-by: Learath2 <learath2@gmail.com>
2019-11-03 20:09:21 +00:00
Learath2 c0b0f48d16 Oops 2019-11-03 20:58:35 +01:00
def fdaafea6b5 Also init m_aClients[*].m_Latency
as reported by valgrind --tool=memcheck:

==376722== Conditional jump or move depends on uninitialised value(s)
==376722==    at 0x1CDBDB: int maximum<int>(int, int) (math.h:79)
==376722==    by 0x216A46: CPlayer::Tick() (player.cpp:174)
==376722==    by 0x1FB308: CGameContext::OnTick() (gamecontext.cpp:658)
==376722==    by 0x1C60AF: CServer::Run() (server.cpp:2046)
==376722==    by 0x1CB099: main (server.cpp:3040)
==376722==
==376722== Conditional jump or move depends on uninitialised value(s)
==376722==    at 0x183F27: int minimum<int>(int, int) (math.h:77)
==376722==    by 0x216A65: CPlayer::Tick() (player.cpp:175)
==376722==    by 0x1FB308: CGameContext::OnTick() (gamecontext.cpp:658)
==376722==    by 0x1C60AF: CServer::Run() (server.cpp:2046)
==376722==    by 0x1CB099: main (server.cpp:3040)
2019-11-03 18:54:25 +01:00
Learath2 c4d18118c1 Use automatic storage for the data 2019-11-03 18:31:05 +01:00
Learath2 52cca29cd9 Use a std::list, improve variable naming 2019-11-03 15:39:32 +01:00
Learath2 3d495a9936 Initialize variables 2019-11-03 01:53:50 +01:00
Learath2 79e4651d5b Only update serverinfo when needed 2019-11-03 01:07:10 +01:00
Learath2 7f0589bff7 Cache serverinfo responses 2019-11-03 00:33:30 +01:00
def cb738ffed0 Fix show_ips to show regular formatting (fixes #1873) 2019-08-01 20:24:30 +02:00
Learath 0bc3650356 Send DDNet capability flag 2019-07-29 14:18:40 +03:00
12pm c57fcf3ee7 Persist playerflags when using timeout protection 2019-07-26 01:39:53 +02:00
Emir Marincic 57197d990c
Better represent the state of the server
Co-Authored-By: heinrich5991 <heinrich5991@gmx.de>
2019-07-20 21:25:15 +03:00
Learath 1769e5ae71 Don't advertise the reserved slots. Fix #1808 2019-07-18 18:20:55 +03:00
bors[bot] bbcf7a6905 Merge #1815
1815: Return error codes on server fail r=def- a=ChillerDragon



Co-authored-by: ChillerDragon <chillerdragon@gmail.com>
2019-07-11 09:25:59 +00:00
ChillerDragon b9273a9ed2 Return error codes on server fail 2019-07-11 11:18:25 +02:00
ChillerDragon 6172a9dca0 Use the float type explicitly 2019-07-08 23:08:42 +02:00
heinrich5991 62846821da Revert "Implement ISDDNET. Deprecates #1320"
This reverts commit 1929bc6739.
2019-06-14 00:28:59 +02:00
heinrich5991 f31e081bd4 Remove all checking for the gametype in the game
OK, maybe not actually remove because it is kept for fallback when the
new method isn't available.

The whole gametype parsing business had the same downsides as user agent
parsing on the web, hence I removed it while keeping behavior the same.

This allows servers to explicitly opt in or out of certain bug
workarounds and other client behavior. This increases the complexity of
different configurations that are available in the client (which is a
bad thing).
2019-06-14 00:28:59 +02:00
def 85bb376bdc sv_server_info_per_second, sv_van_conn_per_second: allow 0 to disable
Clean up code a bit, also allow larger values
2019-06-11 18:12:43 +02:00
Learath 1929bc6739 Implement ISDDNET. Deprecates #1320 2019-05-21 10:25:15 +02:00
bors[bot] 9bca330a73 Merge #1691
1691: Persist show_ips setting on map changes r=Learath2 a=def-

@12pm 

Co-authored-by: def <dennis@felsin9.de>
2019-05-01 12:08:13 +00:00
ChillerDragon 7a7caabbec Fix inconsistant uppercase server in logs 2019-04-30 09:03:06 +02:00
def a910d9eff7 Persist show_ips setting on map changes 2019-04-29 21:39:17 +02:00
Dennis Felsing cde07b420b Implement changes suggested by -Wuseless-cast
But don't enable it yet because I'm not sure what the best way is.
2019-04-11 19:54:43 +02:00
def ea093f6d39 2 more tries to force DB to respond in UTF8 (fixes #1599) 2019-04-08 16:55:53 +02:00
def 25c54ef4db Implement show_ips to protect accidental leaking of IPs
Marks all sensitive data with <{ }> and then filters that out when
show_ips is not set.
2019-04-06 19:22:02 +02:00
heinrich5991 e44b1ca986 Use OpenSSL md5 if it is available
Fixes #1582.
2019-04-06 02:56:29 +02:00
12pm a7ef921e3f Add playerflags, dnsbl, and ips for non-admins in status 2019-04-03 15:07:05 +02:00
Dennis Felsing 8b68a2859a
Merge pull request #1509 from ddnet/error-checking
More error checking in system.c (fixes #1317)
2019-03-20 07:44:12 +01:00
def 1e4890c499 More error checking in system.c (fixes #1317) 2019-03-19 23:16:29 +01:00
12pm 9f4f06e995 Make updating nameban reason work 2019-03-19 22:54:16 +01:00
def 6f9cfd5af1 Increase MAX_PATH_LENGTH to support our own downloadedmaps names 2019-03-12 18:43:03 +01:00
Dennis Felsing b8c256b602
Merge pull request #1467 from 12pm/nameban_exact
Add exact name ban option
2019-03-11 22:50:39 +01:00
12pm 3dcb83778f Make name more descriptive 2019-03-11 14:48:45 +01:00
bors[bot] 26dc51a272 Merge #1466
1466: Add colors for authed players. Deprecates #1299 r=def- a=Learath2

Not sure if a snap item is the best idea for this but it should help with not sending the data more then needed and keeping it properly updated. The colors aren't great now but we can fix that easily.

![image](https://user-images.githubusercontent.com/490500/53680889-607bf780-3cf2-11e9-84a0-579160e9e170.png)


Co-authored-by: Learath <learath2@gmail.com>
2019-03-06 13:44:28 +00:00
def deb2494692 Don't suggest to downgrade, clean up versioning (fixes #1440) 2019-03-03 20:31:23 +01:00
12pm 29592afdb5 Add exact name ban option 2019-03-03 18:29:33 +01:00
Learath 548e9969b2 Add colors for authed players. Deprecates #1299 2019-03-02 13:50:33 +03:00