File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "license" : " BSD-3-Clause" ,
3+ "repo-type" : " git" ,
4+ "source-url" : " git@github.com:shuppet/p6-net-rcon.git" ,
5+ "auth" : " github:shuppet" ,
6+ "depends" : [
7+ " IO::Socket::INET"
8+ ],
9+ "provides" : {
10+ "Net::RCON" : " lib/API/RCON.pm6"
11+ },
12+ "name" : " Net::RCON" ,
13+ "description" : " Perl 6 module for interacting with the Source RCON (remote console) protocol." ,
14+ "perl" : " 6.c" ,
15+ "version" : " 0.0.1" ,
16+ "authors" : [
17+ " Kane 'kawaii' Valentine <kane@cute.im>"
18+ ]
19+ }
Original file line number Diff line number Diff line change 1+ unit class Net::RCON ;
2+
3+ use IO ::Socket::INET;
4+ use experimental : pack;
5+
6+ constant {
7+ SERVERDATA_RESPONSE_VALUE => 0 ,
8+ SERVERDATA_AUTH_RESPONSE => 2 ,
9+ SERVERDATA_EXECCOMMAND => 2 ,
10+ SERVERDATA_AUTH => 3
11+ };
12+
13+ sub connect (: $ hostname , : $ port , : $ password ) {
14+
15+ my % arguments = host => $ hostname || " localhost" ,
16+ port => $ port || 27015 ,
17+ id => 0 ,
18+ ;
19+
20+ my $ socket = IO ::Socket::INET. new (: % arguments <hostname >, : % arguments <port >);
21+ my $ connection = $ socket . accept;
22+
23+ authenticate(: $ connection , : $ password );
24+ }
25+
26+ sub authenticate (: $ connection , : $ password ) {
27+
28+ my $ type = SERVERDATA_AUTH;
29+ my $ data = $ password ;
30+
31+ send(: $ connection , : $ type , : $ data );
32+ }
33+
34+ sub send (: $ connection , : $ type , : $ data ) {
35+
36+ my $ payload = pack (" VV" , 1 , $ type ) ~ $ data ~ pack (" xx" );
37+ $ payload = pack (" V" , $ payload . bytes ) ~ $ payload ;
38+
39+ $ connection . write ($ payload );
40+ }
41+
42+ sub recieve () {
43+
44+ }
You can’t perform that action at this time.
0 commit comments