if ($HTTP_SERVER_VARS["PHP_SELF"] == "/index.php") $mainPage = 1; include("banner.inc"); ?>
w e l c o m e . t o . t r o g ' s . h a u s
//include("subbanner.inc"); ?>
include("leftmenu.inc") ?>
image display:
3 per row
4 per row
5 per row
6 per row
------ |
download file
docs/code/hl2rcon.c
now |------
/* # This is a simple linux command line utility to execute rcon commands # Just change the YOUR_PASSWORD_HERE to your rcon password (unless # you want to enter it every time) and possibly change the default # IP address from 127.0.0.1 (localhost) # # once downloaded on your linux system, compile it with: # # gcc -o rcon rcon.c # # note, it should work on non-linux too, but may require changing the # socket stuff (i.e. windows will definitely need to add the winsock # initialization line) # # written by [ASY]Zyrain # */ #include
#include
#include
#include
#include
#include
#include
#include
#define DEBUG 0 #define SERVERDATA_EXECCOMMAND 2 #define SERVERDATA_AUTH 3 #define SERVERDATA_RESPONSE_VALUE 0 #define SERVERDATA_AUTH_RESPONSE 2 int send_rcon(int sock, int id, int command, char *string1, char *string2) { int size, ret; size = 10+strlen(string1)+strlen(string2); ret = send(sock,&size,sizeof(int),0); if(ret == -1) { perror("send() failed:"); return -1; } ret = send(sock,&id,sizeof(int),0); if(ret == -1) { perror("send() failed:"); return -1; } ret = send(sock,&command,sizeof(int),0); if(ret == -1) { perror("send() failed:"); return -1; } ret = send(sock,string1,strlen(string1)+1,0); if(ret == -1) { perror("send() failed:"); return -1; } ret = send(sock,string2,strlen(string2)+1,0); if(ret == -1) { perror("send() failed:"); return -1; } if(DEBUG) printf("Sent %d bytes\n",size+4); return 0; } int recv_rcon(int sock, int timeout, int *id, int *command, char *string1, char *string2) { struct timeval tv; fd_set readfds; int size; char *ptr; int ret; char buf[8192]; size=0xDEADBEEF; *id=0xDEADBEEF; *command=0xDEADBEEF; string1[0]=0; string2[0]=0; tv.tv_sec = timeout; tv.tv_usec = 0; FD_ZERO(&readfds); FD_SET(sock, &readfds); /* don't care about writefds and exceptfds: */ select(sock+1, &readfds, NULL, NULL, &tv); if (!FD_ISSET(sock, &readfds)) { if(DEBUG) { printf("recv timeout\n"); } return -1; // timeout } if(DEBUG) printf("Got a response\n"); ret = recv(sock, &size, sizeof(int), 0); if(ret == -1) { perror("recv() failed:"); return -1; } if((size<10) || (size>8192)) { printf("Illegal size %d\n",size); exit(-1); } ret = recv(sock, id, sizeof(int),0); if(ret == -1) { perror("recv() failed:"); return -1; } size-=ret; ret = recv(sock, command, sizeof(int),0); if(ret == -1) { perror("recv() failed:"); return -1; } size-=ret; ptr = buf; while(size) { ret = recv(sock, ptr, size, 0); if(ret == -1) { perror("recv() failed:"); return -1; } size -= ret; ptr += ret; } buf[8190] = 0; buf[8191] = 0; strncpy(string1, buf, 4095); string1[4095] = 0; strncpy(string2, buf+strlen(string1)+1, 4095); return 0; } /* This is set to 1 when we've been authorized */ int auth = 0; char string1[4096]; char string2[4096]; int process_response(int sock) { int ret; int id; int command; ret=recv_rcon(sock, 1, &id, &command, string1, string2); if(DEBUG) printf("Received = %d : id=%d, command=%d, s1=%s, s2=%s\n", ret, id, command, string1, string2); if(ret==-1) { return -1; } switch(command) { case SERVERDATA_AUTH_RESPONSE: switch(id) { case 20: auth = 1; break; case -1: printf("Password Refused\n"); return -1; default: printf("Bad Auth Response ID = %d\n",id); exit(-1); }; break; case SERVERDATA_RESPONSE_VALUE: printf("%s",string1); break; default: printf("Unexpected command: %d",command); break; }; } int main(int argc, char **argv) { struct sockaddr_in a; int sock; int ret, i; char password[512]="YOUR_PASSWORD_HERE"; short port = 27015; char address[512] = "127.0.0.1"; int arg; auth = 0; if(argc<2) { printf("Syntax: rcon [-P\"rcon_password\"] [-a127.0.0.1] [-p27015] command\n"); return 0; } for(arg = 1;arg
index of
root
>>
docs
>>
code
>>
hl2rcon.c
>>
hl2rcon.c
5,977
Linux source for a Half-Life 2 rcon utility.
//include("rightmenu.inc"); ?>
$modtime = getlastmod(); $filemodtime = date("F j Y h:i:s A", $modtime); ?>
Last modified: echo $filemodtime ?>