Commit Graph

100 Commits

Author SHA1 Message Date
Tiiffi
c497f9fd6e Remove log_error macro and revert back to fprintf() 2025-11-27 04:39:07 +02:00
Tiiffi
d61da026b9 Refactor windows getline function and fix color handling:
- rename utf8_getline() to windows_getline()
- windows_getline() should now handle UTF-8 input correctly
- color printing now resets bold/bright status for each line
- remove unnecessary _setmode() calls
- disable color printing if 'valve protocol' detected
- print newline after last packet if last character was not newline
2025-11-27 01:22:54 +02:00
Tiiffi
da5821e7ab Remove unused color printing code and set stdout/stderr to binary mode to avoid newline translation confusion on Windows 2025-11-21 21:04:43 +02:00
Tiiffi
3a049e75fc Newline fixes:
- Add additional newline check to prevent double newlines
- Print newline only after multipacket guard is received
2025-11-21 16:36:33 +02:00
Tiiffi
b4da108a71 Update copyright year 2025-11-21 16:07:40 +02:00
Tiiffi
142479f9ee Refactor color handling and add error handling to UTF-8 code 2025-11-21 15:53:39 +02:00
Tiiffi
f0e7e71589 Revert back to old way of flushing input buffer 2024-12-12 22:14:40 +02:00
Tiiffi
4a1da8d373 Convert tab indentation to spaces. This is how normal people do it. :D 2024-12-06 23:44:04 +02:00
Tiiffi
b1b46ca08c Implement platform specific input buffer flushing 2024-12-06 21:53:39 +02:00
Tiiffi
0fb17971c0 Fix typo and remove 'Q' as quitting command 2024-12-06 20:26:42 +02:00
Tiiffi
2d29741691 Fixes to Windows utf-8 support + one more Minecraft newline fix 2024-12-06 16:24:04 +02:00
Tiiffi
cc77044df1 Add experimental utf-8 support for Windows and change the behaviour of Minecraft "stop" hack 2024-12-06 14:43:40 +02:00
Tiiffi
bd76b897de Fix missing newlines in Minecraft RCON messages:
Minecraft servers have a longstanding bug that omits newlines
when sending messages via RCON. This patch manually inserts
newlines to address the issue.

Reference: https://bugs.mojang.com/browse/MC-7569

Fixes #1
2024-12-06 11:00:18 +02:00
Tiiffi
1106f27700 Bump version to 0.8.0 2024-12-06 08:47:45 +02:00
Tiiffi
00fc3b5bcb Set select() timeout to 5 seconds and replace putchar() loop with fputs() call 2024-12-06 08:47:45 +02:00
Tiiffi
a0fe9e1645 Enable input/output buffering and fflush only explicitly
As suggested in old pull request: #39
2024-12-06 08:47:45 +02:00
Tiiffi
5f460e8912 Remove Valve protocol checks and set select() timeout to 1.5 seconds
Use the same method for handling multipacket responses across all servers.
2024-12-06 08:47:45 +02:00
Tiiffi
6fed74ba74 Implement select() loop to receive all incoming packets:
Send a "multipacket guard" - an empty packet with an invalid 'cmd' field
and a unique packet ID to trigger a reply from the server once the previous
command's reply has been fully sent.

Valve returns an empty payload, while Minecraft includes an error message in the payload.

This workaround ensures that all packets related to the last valid command
are received from the server, avoiding the need to wait for the select() timeout.
2024-12-06 08:47:45 +02:00
Tiiffi
5d1c87b26f Don't call memcpy() if there is nothing to copy 2024-12-04 08:17:56 +02:00
Tiiffi
fd77ad7fc0 packet_build(): add [static 1] to generate warning if NULL pointer is passed 2024-12-03 05:40:45 +02:00
Tiiffi
a502204e26 Remove unused headers 2024-12-02 09:34:48 +02:00
Tiiffi
7162bc6fe6 - add log_error macro
- rename "flag_connection_alive" variable back to "global_connection_alive"
- return exit code from run_terminal_mode()
- rcon_command(): add error messages
2024-12-02 08:55:18 +02:00
Tiiffi
f270a485b5 Remove url from version string 2024-12-02 07:40:34 +02:00
Tiiffi
df66816bee Change prefix of flag variables from 'global' to 'flag' 2024-12-02 07:37:12 +02:00
Tiiffi
5c7ab407d7 Patch of various fixes, cleanups and unused code removals:
- add MAX_COMMAND_LENGTH to define maximum command length
 - print auth failed message to stderr instead of stdout
 - remove unused net_send() function
 - remove unused net_clean_incoming() function
 - rewrite net_send_packet() function
 - net_recv_packet(): change the type of variable "ret" from int to ssize_t
 - net_recv_packet(): fail immediately if the packet size is out of spec
 - packet_print(): rename variable "def_color" to "default_color"
 - packet_print(): remove unecessary casts
 - packet_build(): use MAX_COMMAND_LENGTH
 - packet_build(): be more explicit in calculation of packet.size
 - packet_build(): use memcpy() instead of strncpy()
 - cast second argument of send()/recv() calls to (char *) so Windows is happy
 - rcon_auth(): change the return type from int to bool
 - run_terminal_mode(): use MAX_COMMAND_LENGTH
2024-12-02 07:32:07 +02:00
Tiiffi
427fd206ca Oops, uncomment struct field 2024-11-11 23:49:18 +02:00
Tiiffi
1a4010cbba Change MAX_PACKET_SIZE and DATA_BUFFSIZE, add notes about packet structure 2024-11-11 22:22:45 +02:00
Tiiffi
4488127350 Use fixed width integer types in rcon packet structure 2024-11-10 16:25:19 +02:00
Tiiffi
fc040ce5ea Change maximum packet size to correct value (4096 -> 4106) 2024-11-09 15:22:42 +02:00
Tiiffi
a8e2a9349e Exit with appropriate return code if password is not provided, fixes #87 2024-11-07 21:39:37 +02:00
Tiiffi
aa933d2c1f Add support for Valve style authentication, fixes #106 2024-11-07 14:59:31 +02:00
Tiiffi
7b8ea2bf39 Update copyright year 2021-10-30 22:30:12 +03:00
Tiiffi
05aaff88d4 Update version information, changelog and readme 2021-10-30 22:21:25 +03:00
Tiiffi
fca278e092 - Quit gracefully when Ctrl-D or Ctrl-C is pressed
- Remove "exit" and "quit" as quit commands
2021-10-30 22:16:29 +03:00
Tiiffi
b3147ebe43 Fix erroneous string length check 2021-02-15 04:31:07 +02:00
Tiiffi
48c065c304 Use setvbuf() instead of fflush() 2021-02-15 03:29:44 +02:00
Tiiffi
29a1c99f82 Merge pull request #53 from AddisonG/master
Fix compiler warning
2021-02-12 04:23:54 +02:00
Tiiffi
bf11460a0d Merge pull request #39 from kabiroberai/master
Flush stdout when needed
2021-02-08 22:51:54 +02:00
jbaldus
ada14bb4d9 Fixes typo in ANSI escape sequence for LCYAN 2021-01-13 19:22:02 -05:00
Addison G
336f528668 Fixed compiler bug
This fixes the compiler issue:

```
mcrcon.c: In function ‘packet_build’:
mcrcon.c:576:2: warning: ‘strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
  strncpy(packet.data, s1, DATA_BUFFSIZE);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2020-08-12 14:10:58 +10:00
kabiroberai
58a7a86bc3 Flush stdout when needed
This is required on certain machines (eg the iSH emulator on iOS)
2020-01-31 17:26:27 +05:30
Tiiffi
b118b7b7b9 Change year in copyright texts and manual page 2020-01-02 02:22:44 +02:00
Tiiffi
f351fb134e - Deprecate -i flag for terminal mode
- Use strcasecmp() instead strcmp() to check exit command
2019-12-22 16:27:36 +02:00
Tiiffi
af5e88b528 Update Makefile 2019-12-22 00:05:31 +02:00
Tiiffi
876201fe5a Add workaround to prevent server-side bug.
https://bugs.mojang.com/browse/MC-154617
2019-12-21 23:12:39 +02:00
Tiiffi
3c071c0c45 - Add exit string detection
- Stylistic change in getopt loop
2019-12-21 22:25:08 +02:00
Tiiffi
cffa73d223 Remove unused functions 2019-12-20 21:02:21 +02:00
Tiiffi
c62d5c8a70 Update usage and version texts 2019-12-20 20:58:40 +02:00
Tiiffi
8b75ddf4bf Indentation style change 2019-12-20 19:56:05 +02:00
Tiiffi
4f3a455095 Add more validation to mcrcon_parse_seconds() 2019-12-19 17:34:19 +02:00