mirror of
				https://github.com/Tiiffi/mcrcon.git
				synced 2025-10-30 12:51:08 -04:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			a8e2a9349e
			...
			fc040ce5ea
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fc040ce5ea | |||
| 489306d4a2 | 
| @ -2,13 +2,14 @@ | |||||||
|  |  | ||||||
| ###### 0.7.3 | ###### 0.7.3 | ||||||
|  - Add support to Valve style rcon authentication |  - Add support to Valve style rcon authentication | ||||||
|  |  - Change maximum packet size to correct value (4096 -> 4106) | ||||||
|   |   | ||||||
| ###### 0.7.2 | ###### 0.7.2 | ||||||
|  - Quit gracefully when Ctrl-D or Ctrl+C is pressed |  - Quit gracefully when Ctrl-D or Ctrl+C is pressed | ||||||
|  - Remove "exit" and "quit" as quitting commands |  - Remove "exit" and "quit" as quitting commands | ||||||
|     * these are actual rcon commands on some servers |     * these are actual rcon commands on some servers | ||||||
|  - Suppress compiler warning (strncpy) |  - Suppress compiler warning (strncpy) | ||||||
|  - fix erroneous string length in packet building function |  - Fix erroneous string length in packet building function | ||||||
|  - Fix typo in ANSI escape sequence for LCYAN |  - Fix typo in ANSI escape sequence for LCYAN | ||||||
|  - Make stdout and stderr unbuffered |  - Make stdout and stderr unbuffered | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							| @ -1,4 +1,4 @@ | |||||||
| Copyright (c) 2012-2021, Tiiffi <tiiffi at gmail> | Copyright (c) 2012-2024, Tiiffi <tiiffi at gmail> | ||||||
|  |  | ||||||
| This software is provided 'as-is', without any express or implied | This software is provided 'as-is', without any express or implied | ||||||
| warranty. In no event will the authors be held liable for any damages | warranty. In no event will the authors be held liable for any damages | ||||||
|  | |||||||
							
								
								
									
										31
									
								
								create_shortcut.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								create_shortcut.bat
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | @echo off | ||||||
|  | @cls | ||||||
|  |  | ||||||
|  | @set /p host="Enter host (default: "127.0.0.1"): " | ||||||
|  | @if "%host%"=="" set host=127.0.0.1 | ||||||
|  |  | ||||||
|  | @set /p port="Enter port (default: 25575): " | ||||||
|  | @if "%port%"=="" set port=25575 | ||||||
|  |  | ||||||
|  | @set /p passwd="Enter password: " | ||||||
|  | @if "%passwd%"=="" set passwd= | ||||||
|  |  | ||||||
|  | set name=connect_%host%-%port% | ||||||
|  |  | ||||||
|  | @set /p name="Enter shortcut name (default: "%name%.bat"): " | ||||||
|  | @if "%name%"=="" set name=connect_%host%-%port% | ||||||
|  |  | ||||||
|  | set command=@mcrcon.exe -t -H %host% -P %port% -p %passwd% | ||||||
|  |  | ||||||
|  | @echo %command% >> %name%.bat | ||||||
|  | @echo. | ||||||
|  | @echo Command: "%command%" | ||||||
|  | @echo. | ||||||
|  | @echo Shortcut "%name%.bat" created! | ||||||
|  | @echo. | ||||||
|  |  | ||||||
|  | @set "host=" | ||||||
|  | @set "port=" | ||||||
|  | @set "passwd=" | ||||||
|  |  | ||||||
|  | @pause | ||||||
							
								
								
									
										29
									
								
								launch.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								launch.bat
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | @echo off | ||||||
|  | @cls | ||||||
|  |  | ||||||
|  | @if not exist mcrcon.exe ( | ||||||
|  |   @echo ERROR: Cannot find "mcrcon.exe". Bailing out! | ||||||
|  |   @echo. | ||||||
|  |   @pause | ||||||
|  |   @exit | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | @set /p host="Enter host (default: 127.0.0.1): " | ||||||
|  | @if "%host%"=="" set host=127.0.0.1 | ||||||
|  |  | ||||||
|  | @set /p port="Enter port (default: 25575): " | ||||||
|  | @if "%port%"=="" set port=25575 | ||||||
|  |  | ||||||
|  | @set /p passwd="Enter password: " | ||||||
|  | @if "%passwd%"=="" set passwd= | ||||||
|  |  | ||||||
|  | @echo. | ||||||
|  | mcrcon.exe -t -H %host% -P %port% -p %passwd% | ||||||
|  | @echo. | ||||||
|  |  | ||||||
|  | @set "host=" | ||||||
|  | @set "port=" | ||||||
|  | @set "passwd=" | ||||||
|  |  | ||||||
|  | @pause | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								mcrcon.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								mcrcon.c
									
									
									
									
									
								
							| @ -58,6 +58,8 @@ | |||||||
| #define RCON_PID                0xBADC0DE | #define RCON_PID                0xBADC0DE | ||||||
|  |  | ||||||
| #define DATA_BUFFSIZE   4096 | #define DATA_BUFFSIZE   4096 | ||||||
|  | #define MAX_PACKET_SIZE 4106 | ||||||
|  | #define MIN_PACKET_SIZE 10 | ||||||
|  |  | ||||||
| // rcon packet structure | // rcon packet structure | ||||||
| typedef struct _rc_packet { | typedef struct _rc_packet { | ||||||
| @ -434,10 +436,11 @@ rc_packet *net_recv_packet(int sd) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// NOTE(Tiiffi): This should fail if size is out of spec! | 	// NOTE(Tiiffi): This should fail if size is out of spec! | ||||||
| 	if (psize < 10 || psize > DATA_BUFFSIZE) { | 	if (psize < MIN_PACKET_SIZE || psize > MAX_PACKET_SIZE) { | ||||||
| 		fprintf(stderr, "Warning: invalid packet size (%d). Must over 10 and less than %d.\n", psize, DATA_BUFFSIZE); | 		fprintf(stderr, "Warning: invalid packet size (%d). Must over 10 and less than %d.\n", psize, MAX_PACKET_SIZE); | ||||||
|  |  | ||||||
| 		if(psize > DATA_BUFFSIZE  || psize < 0) psize = DATA_BUFFSIZE; | 		// WARNING(Tiiffi): This is probably not the way to go. Probably should just fail and exit. | ||||||
|  | 		if(psize > MAX_PACKET_SIZE || psize < 0) psize = MAX_PACKET_SIZE; | ||||||
| 		net_clean_incoming(sd, psize); | 		net_clean_incoming(sd, psize); | ||||||
|  |  | ||||||
| 		return NULL; | 		return NULL; | ||||||
| @ -448,7 +451,7 @@ rc_packet *net_recv_packet(int sd) | |||||||
| 	int received = 0; | 	int received = 0; | ||||||
| 	while (received < psize) { | 	while (received < psize) { | ||||||
| 		ret = recv(sd, (char *) &packet + sizeof(int) + received, psize - received, 0); | 		ret = recv(sd, (char *) &packet + sizeof(int) + received, psize - received, 0); | ||||||
| 		if (ret == 0) { /* connection closed before completing receving */ | 		if (ret == 0) { | ||||||
| 			fprintf(stderr, "Connection lost.\n"); | 			fprintf(stderr, "Connection lost.\n"); | ||||||
| 			global_connection_alive = 0; | 			global_connection_alive = 0; | ||||||
| 			return NULL; | 			return NULL; | ||||||
| @ -568,6 +571,11 @@ rc_packet *packet_build(int id, int cmd, char *s1) | |||||||
| { | { | ||||||
| 	static rc_packet packet = {0, 0, 0, { 0x00 }}; | 	static rc_packet packet = {0, 0, 0, { 0x00 }}; | ||||||
|  |  | ||||||
|  | 	// NOTE(Tiiffi): Issue report states that outgoing payload has max size of 1460 bytes: | ||||||
|  | 	//				 https://github.com/Tiiffi/mcrcon/issues/45#issuecomment-1000940814 | ||||||
|  | 	//				 https://mctools.readthedocs.io/en/master/rcon.html | ||||||
|  | 	//				 Have to do some testing to confirm! | ||||||
|  |  | ||||||
| 	// size + id + cmd + s1 + s2 NULL terminator | 	// size + id + cmd + s1 + s2 NULL terminator | ||||||
| 	int len = strlen(s1); | 	int len = strlen(s1); | ||||||
| 	if (len >= DATA_BUFFSIZE) { | 	if (len >= DATA_BUFFSIZE) { | ||||||
| @ -661,7 +669,7 @@ int run_commands(int argc, char *argv[]) | |||||||
| int run_terminal_mode(int sock) | int run_terminal_mode(int sock) | ||||||
| { | { | ||||||
| 	int ret = 0; | 	int ret = 0; | ||||||
| 	char command[DATA_BUFFSIZE] = {0x00}; | 	char command[DATA_BUFFSIZE] = {0}; | ||||||
|  |  | ||||||
| 	puts("Logged in.\nType 'Q' or press Ctrl-D / Ctrl-C to disconnect."); | 	puts("Logged in.\nType 'Q' or press Ctrl-D / Ctrl-C to disconnect."); | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	