hldsrcon 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/hldsrcon.gemspec +24 -0
- data/lib/hldsrcon/rconhlds.rb +59 -0
- data/lib/hldsrcon/version.rb +3 -0
- data/lib/hldsrcon.rb +6 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6995b64e27eb0bb2357adafd2175cb0e6b551cf8
|
4
|
+
data.tar.gz: 7184a721f7a373388d515cb42d6ba1cbbf936f89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f79eed0dbca50e5e571fa48bfe36989b60b20ade5af669c6b72b9d5e646399a6a517044469053a48b59f54f726de1d7b62e6da3a919dc696f15cce7e9af8852f
|
7
|
+
data.tar.gz: 7e9448b3e2f1e2f65f81f9df4e6605163d439665a780f30e56e813005279bd5551e0752e50992c476b7ce92b5fb108998131b17b20f033801b854d096a9b8de3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 freemanmax
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Hldsrcon
|
2
|
+
|
3
|
+
Hldsrcon gem is Counter-Strike 1.6 Server remote console, the gem use UDP Socket to send and
|
4
|
+
receive data or to execute Counter-Strike 1.6 Server command and receive respons from Server.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'hldsrcon'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
```
|
17
|
+
$ bundle
|
18
|
+
```
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
```
|
23
|
+
$ gem install hldsrcon
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
To use this game you have first to installet the gem.
|
29
|
+
Use this example, create new ruby file rcon.rb and put this in it:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'hldsrcon'
|
33
|
+
|
34
|
+
@conn = RconHlds.new("192.168.0.1", 27015, 29015)
|
35
|
+
@conn.rcon_pass('ctx')
|
36
|
+
rcon = @conn.rcon_command('sv_restart 1')
|
37
|
+
puts rcon
|
38
|
+
```
|
39
|
+
|
40
|
+
Note 'ctx' is the Counter-Strike 1.6 Server rcon_password.
|
41
|
+
After this run the rcon.rb file in terminal, make sure that your terminal directory is where the file is located
|
42
|
+
and after this run ruby rcon.rb. If everything go well you should get respons from server like this:
|
43
|
+
```
|
44
|
+
L 04/24/2016 - 10:04:21: Server cvar "sv_restart" = "1"
|
45
|
+
```
|
46
|
+
If you get:
|
47
|
+
```
|
48
|
+
Bad Rcon
|
49
|
+
```
|
50
|
+
Your Counter-Strike 1.6 Server rcon_password is wrong.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
55
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hldsrcon"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/hldsrcon.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hldsrcon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hldsrcon"
|
8
|
+
spec.version = Hldsrcon::VERSION
|
9
|
+
spec.authors = ["freemanmax"]
|
10
|
+
spec.email = ["nenadstojkovikj@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Hldsrcon is Counter-Strike 1.6 Server remote console.}
|
13
|
+
spec.description = %q{Hldsrcon execute command in Counter-Strike 1.6 Server console.}
|
14
|
+
spec.homepage = "https://github.com/freemanmax/hldsrcon"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
require "socket"
|
3
|
+
|
4
|
+
class RconHlds
|
5
|
+
def initialize(ip_addr, port, bind_port)
|
6
|
+
@socket = UDPSocket.new
|
7
|
+
@socket.bind "", bind_port
|
8
|
+
@socket.connect ip_addr, port
|
9
|
+
end
|
10
|
+
def close
|
11
|
+
@socket.close
|
12
|
+
@socket = nil
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
def rcon_pass(pass)
|
16
|
+
@pass = pass
|
17
|
+
@socket.send "\xFF\xFF\xFF\xFFchallenge rcon", 0
|
18
|
+
paket = @socket.recvfrom(1400)
|
19
|
+
data = paket[0]
|
20
|
+
data.gsub!("\xFF\xFF\xFF\xFFchallenge ", "")
|
21
|
+
data.gsub!("\n\x00", "")
|
22
|
+
@challenge = data
|
23
|
+
@rcon_pass_respons = ""
|
24
|
+
if ( @challenge =~ /rcon\s\d/ )
|
25
|
+
@socket.send "\xFF\xFF\xFF\xFF#{@challenge} #{@pass}", 0
|
26
|
+
rcon_paket = @socket.recvfrom(1400)
|
27
|
+
if rcon_paket[0] == "\xFF\xFF\xFF\xFFl\x00\x00"
|
28
|
+
@rcon_pass_respons = "Good Rcon"
|
29
|
+
return @rcon_pass_respons
|
30
|
+
else
|
31
|
+
@rcon_pass_respons = "Bad Rcon"
|
32
|
+
return @rcon_pass_respons
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
def rcon_command(command)
|
37
|
+
@command = command
|
38
|
+
if ( @rcon_pass_respons == "Good Rcon" )
|
39
|
+
@socket.send "\xFF\xFF\xFF\xFF#{@challenge} #{@pass} #{@command}", 0
|
40
|
+
@socket.send "\xFF\xFF\xFF\xFF#{@challenge} #{@pass}", 0
|
41
|
+
@receve_paket = true
|
42
|
+
@datas = ""
|
43
|
+
while @receve_paket do
|
44
|
+
@command_paket = @socket.recvfrom(1400)
|
45
|
+
data = @command_paket[0]
|
46
|
+
@datas << data
|
47
|
+
if ( @command_paket[0] == "\xFF\xFF\xFF\xFFl\x00\x00" )
|
48
|
+
@receve_paket = false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
@datas.gsub!("\xFF\xFF\xFF\xFFl", "")
|
52
|
+
@datas.gsub!("\x00\x00", "")
|
53
|
+
return @datas
|
54
|
+
else
|
55
|
+
@rcon_command_respons = "Bad Rcon"
|
56
|
+
return @rcon_command_respons
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/hldsrcon.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hldsrcon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- freemanmax
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Hldsrcon execute command in Counter-Strike 1.6 Server console.
|
42
|
+
email:
|
43
|
+
- nenadstojkovikj@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- hldsrcon.gemspec
|
56
|
+
- lib/hldsrcon.rb
|
57
|
+
- lib/hldsrcon/rconhlds.rb
|
58
|
+
- lib/hldsrcon/version.rb
|
59
|
+
homepage: https://github.com/freemanmax/hldsrcon
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.4.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Hldsrcon is Counter-Strike 1.6 Server remote console.
|
83
|
+
test_files: []
|