0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-18 01:15:09 +00:00
Commit graph

174 commits

Author SHA1 Message Date
Robin C. Ladiges
2cd7abf0bd
add command: unban ip <ipv4-address>
To remove a banned IPv4 address from the ban list.
2023-03-24 00:58:22 +01:00
Robin C. Ladiges
2f2c1fd4f7
add command: ban profile <profile-id>
To add a profile ID to the ban list.
2023-03-24 00:58:20 +01:00
Robin C. Ladiges
5dcb85eb68
add command: ban ip <ipv4-address>
To add an IPv4 address to the ban list.
2023-03-24 00:58:17 +01:00
Robin C. Ladiges
e13840d543
rename command: ban ... => ban player ...
To enable adding other subcommands starting with `ban`.

Moving ban list and crash related code into its own class to tidy the Program class up.

Change Id values of the crash cmds, to fit into the 16 byte max length imposed by ChangeStagePacket.IdSize.
2023-03-24 00:54:55 +01:00
Robin C. Ladiges
71bb96bf1e verify stage values for send and sendall
Changes:
- Moved alias mapping from Constants.cs to Stages.cs.
- Added `odyssey` as an alias.
- Hardcoded all known stage values.
- Verfify that the stage input is either a alias or a known stage name.
- Added an option to append `!` to a stage name to force sending even if the stage is not known (e.g. for custom kingdoms).

Before it only checked that it was a known alias or that it contained `Stage` or `Zone`.
That made it impossible to send players to`MoonWorldShopRoom` and `MoonWorldSphinxRoom`.
And a typo would have resulted in a game crash.
2023-03-22 16:50:38 -06:00
Robin C. Ladiges
47fc1527bf fix: don't process and broadcast shine packets when shine sync is disabled
The breaks make the function return true, which causes the shine packets to be broadcasted to all connected clients.
Returning false will prevent the broadcast of the current shine packet.

Note: If shines are enabled, the clients will receive every shine twice.
Once from the `SyncShineBag();` and then a second time from the default broadcast caused by the remaining breaks.
We should probably replace every `break;` with `return false;` here?
2022-12-16 13:18:07 -06:00
Robin C. Ladiges
a0642e6a30 fix: only send shines to connected clients and save only after sending
otherwise it will save that the client got it to the bag and then fail sending it, therefore forever preventing the client to get the shine.
2022-12-16 13:18:07 -06:00
Robin C. Ladiges
f0d837190a only warn about the Discord channel settings when a Token is set
Servers that don't use Discord (default settings) don't need to be warned about not setting Discord channels.
2022-10-10 19:37:37 -06:00
Robin C. Ladiges
122a3cd80d fix: don't output empty player IDs or RemoteEndPoints in the log
Make and use a copy of the RemoteEndPoint at the start of the HandleSocket method.
Because in some cases when the socket is disposed, the RemoteEndPoint inside of it is cleared and isn't available for the following disconnect log entries.
Also: port scanners on the internet don't introduce themselves with a name and ID.

(cherry picked from commit 2f4cd0509a)
2022-10-10 11:13:32 -06:00
Robin C. Ladiges
69cef89953 fix: on reconnect do not disconnect the new client
Currently when a client connects that is already there,
the old socket is closed, and the code tries to reuse the existing client object by exchanging its socket.

Reusing the same client object and just changing its socket does cause issues though with copies of the client in other threads.
In the situations that I could reproduce, it always disconnected both sockets, the old one and then the new one.

Instead I make a copy of the client object, use the new socket, remove the old object and add the new object to the collection.

(cherry picked from commit 9e6c312c8e)
2022-10-10 11:12:28 -06:00
Robin C. Ladiges
472c8856bc move the client.CurrentCostume update to the PacketHandler and log the packet
(cherry picked from commit 47505dbdd5)
2022-10-10 11:09:39 -06:00
Robin C. Ladiges
53442b598e only start listening for clients once everything is initialized
Otherwise clients might connect to the server before everything is ready for them.
E.g. when restarting the server, the clients will immediately try to reconnect.

Clients might connect before the `PacketHandler` is initialized, which results in some packets not being processed by the server correctly.

Same goes for the commands: Discord might send in commands before all commands were added to the `CommandHandler`.

Without the `ClientJoined` action, clients might even be allowed to connect if they are on the banlist.
(Though without this initialization they or regular clients might be broken in some ways?)

(cherry picked from commit 92e540aaa6)
2022-10-10 11:08:38 -06:00
Robin C. Ladiges
92d4bdd195 better DiscordBot channel exceptions
currently it always outputs `Failed to get log channel \"{Config.CommandChannel}\"` regardless if the error was with the command channel or the log channel.

await Run(); doesn't need to be in a try-catch block, because it has a try-catch block itself in it.
2022-09-07 10:36:57 -06:00
Robin C. Ladiges
c41499f953 remove unused label
git cherry-pick accidentially picked up a line from another commit for the JSON API
2022-09-07 10:35:26 -06:00
Robin C. Ladiges
76fc4a80a6 only broadcast the DisconnectPacket if the client was connected
Otherwise port scans, banned players or clients failing to initialize correctly,
will cause the server to send unnecessary packets to all connected clients.

They currently are informed about a disconnect for a client that hasn't even connected correctly.

(cherry picked from commit 4b04a3d5be)
2022-09-07 10:35:26 -06:00
Jack Baron
e14616030c move clear task 2022-09-05 18:56:24 -06:00
Jack Baron
24a34c35a1 ignore file not found errors 2022-09-05 18:56:24 -06:00
TheUbMunster
783b876e09 You can run commands in the command channel or log channel 2022-08-22 18:58:42 -06:00
TheUbMunster
4d743b3e1b Made changes for pr, cleaned up formatting 2022-08-22 18:58:42 -06:00
TheUbMunster
67a740dec9 By default bot does not respond to dm with error message 2022-08-22 18:58:42 -06:00
TheUbMunster
4c4ce35f14 Removed some log messages as they would trigger before prefix checking, would start spamming the server if they remained 2022-08-22 18:58:42 -06:00
TheUbMunster
86fb18962f Differentiated command channel and log channel 2022-08-22 18:58:42 -06:00
TheUbMunster
06e3b5d40a Made debug message simpler 2022-08-22 18:58:42 -06:00
TheUbMunster
02f936816c Clarified log message 2022-08-22 18:58:42 -06:00
TheUbMunster
82e94334c9 added log message that prints the channel the command came from and the channel commands are accepted from 2022-08-22 18:58:42 -06:00
TheUbMunster
b6e634ada4 changed isPrivate check to type check of "is DiscordDmChannel" 2022-08-22 18:58:42 -06:00
TheUbMunster
d828a704c1 Updated with Sanae's no private channel logic.
Behavior: No DM'ing commands under any circumstance
if Config.LogChannel == null, commands can be in any non-private channel
if Config.LogChannel != null, commands can only be in the log channel
2022-08-22 18:58:42 -06:00
TheUbMunster
08d1020770 You can no longer dm a bot for a command (has been tested) 2022-08-22 18:58:42 -06:00
Sanae
9c01f30c5e Add the ability to disable shine sync 2022-08-20 23:31:31 -06:00
raym55
c86be55717 PIPERS 2022-08-10 15:03:34 -06:00
Sanae
e7a3347a37
Merge pull request #19 from TheUbMunster/restart-command 2022-07-29 13:19:04 -06:00
Sanae
fcea1d898e
Merge pull request #22 from TheUbMunster/fix-discord-2000-charlimit 2022-07-29 12:55:50 -06:00
TheUbMunster
8baf75155e removed testing code 2022-07-29 12:55:14 -06:00
TheUbMunster
fc2f9b1417 "banning the same person multiple times" should now be fixed 2022-07-29 12:55:14 -06:00
TheUbMunster
33fdd69e15 readded persisten shinies 2022-07-29 12:55:14 -06:00
TheUbMunster
5af8001398 Fixed adding quotes around Ambiguous for "user": , fixed showing correct casing of arguments. 2022-07-29 12:55:14 -06:00
TheUbMunster
ba02c88b13 added !* variants for ban, crash, rejoin 2022-07-29 12:55:14 -06:00
TheUbMunster
95c918b5c4 Removed fire-and-forget warnings, null-forgave some metadata. 2022-07-29 12:55:01 -06:00
TheUbMunster
8350133d49 Fixed "Couldn't determine a response for this query" and removed testing command. 2022-07-29 11:16:24 -06:00
TheUbMunster
d3b8ede229 Messages are now split up into lengths small enough to not cause the discord bot to throw an exception with too long a message. 2022-07-28 19:16:24 -06:00
TheUbMunster
3a8e7ffb93 Changed "Running (pid)" to "Server Running on (pid)" 2022-07-28 18:00:18 -06:00
TheUbMunster
d2c8c8d3cd Fixed race condition with restart to make sure it only happens after the listener closes. 2022-07-28 00:11:40 -06:00
TheUbMunster
068cc7c06d Added restart server command 2022-07-27 23:56:50 -06:00
Sanae
66114bdecb
Always update client's name on connect
Since the client variable would be changed in a reconnect, the name is not set on the old client object.
2022-07-27 14:00:58 -06:00
TheUbMunster
db05586dd0 Added quotable arguments, potential fix for ban * not banning anyone. 2022-07-27 12:14:56 -06:00
TheUbMunster
d604c59a77 Added quotable arguments, potential fix for ban * not banning anyone. 2022-07-27 12:14:56 -06:00
TheUbMunster
5ca5b10db8 Fixed backwards ternaries in ban, crash, rejoin, 0 arguments no longer valid. 2022-07-27 12:14:56 -06:00
Jack Baron
f305c3001b save/load moons from file 2022-07-22 18:56:00 -06:00
Jack Baron
8d90f50fa9 add moon persistence settings 2022-07-22 18:56:00 -06:00
CraftyBoss
967a89a55b Merge branch 'master' of https://github.com/Sanae6/SmoOnlineServer 2022-07-08 23:13:44 +00:00