tox 0.0.2 → 0.0.3
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 +5 -5
- data/.gitignore +5 -0
- data/.gitmodules +2 -2
- data/.rubocop.yml +6 -0
- data/.travis.yml +4 -9
- data/README.md +9 -0
- data/Rakefile +112 -3
- data/bin/childprocess +44 -0
- data/examples/echo_bot.rb +11 -7
- data/ext/tox/client.c +579 -285
- data/ext/tox/extconf.rb +187 -133
- data/ext/tox/friend.c +95 -105
- data/ext/tox/options.c +358 -39
- data/ext/tox/tox.c +41 -37
- data/ext/tox/tox.h +201 -21
- data/ext/tox/version.c +0 -18
- data/lib/tox.rb +11 -28
- data/lib/tox/address.rb +12 -16
- data/lib/tox/address_checksum.rb +12 -0
- data/lib/tox/binary.rb +26 -29
- data/lib/tox/client.rb +7 -64
- data/lib/tox/connection_status.rb +23 -0
- data/lib/tox/friend.rb +9 -20
- data/lib/tox/node.rb +1 -17
- data/lib/tox/nospam.rb +9 -16
- data/lib/tox/options.rb +54 -16
- data/lib/tox/out_friend_message.rb +40 -0
- data/lib/tox/out_message.rb +6 -16
- data/lib/tox/proxies/base.rb +54 -0
- data/lib/tox/proxies/http.rb +14 -0
- data/lib/tox/proxies/socks5.rb +14 -0
- data/lib/tox/proxy_type.rb +17 -0
- data/lib/tox/public_key.rb +0 -16
- data/lib/tox/status.rb +0 -16
- data/lib/tox/user_status.rb +0 -16
- data/lib/tox/version.rb +1 -17
- data/tox.gemspec +9 -2
- metadata +29 -7
- data/bin/build/libsodium +0 -11
- data/bin/build/libtoxcore +0 -11
- data/lib/tox/friend/out_message.rb +0 -58
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tox
|
4
|
+
##
|
5
|
+
# Outgoing friend message representation in Tox client.
|
6
|
+
#
|
7
|
+
class OutFriendMessage
|
8
|
+
include OutMessage
|
9
|
+
|
10
|
+
attr_reader :friend, :id
|
11
|
+
|
12
|
+
def initialize(friend, id)
|
13
|
+
self.friend = friend
|
14
|
+
self.id = id
|
15
|
+
end
|
16
|
+
|
17
|
+
def client
|
18
|
+
friend.client
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def friend=(value)
|
24
|
+
unless value.is_a? Friend
|
25
|
+
raise TypeError, "Expected #{Friend}, got #{value.class}"
|
26
|
+
end
|
27
|
+
@friend = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def id=(value)
|
31
|
+
unless value.is_a? Integer
|
32
|
+
raise TypeError, "Expected #{Integer}, got #{value.class}"
|
33
|
+
end
|
34
|
+
unless value >= 0
|
35
|
+
raise 'Expected message ID to be greater than or equal to zero'
|
36
|
+
end
|
37
|
+
@id = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/tox/out_message.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# tox.rb - Ruby interface for libtoxcore
|
4
|
-
# Copyright (C) 2015-2017 Braiden Vasco
|
5
|
-
#
|
6
|
-
# This program is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
3
|
module Tox
|
20
4
|
##
|
21
5
|
# Abstract module for outgoing message representation in Tox client.
|
@@ -29,6 +13,12 @@ module Tox
|
|
29
13
|
raise NotImplementedError, "#{self.class}#client"
|
30
14
|
end
|
31
15
|
|
16
|
+
def ==(other)
|
17
|
+
self.class == other.class &&
|
18
|
+
friend == other.friend &&
|
19
|
+
id == other.id
|
20
|
+
end
|
21
|
+
|
32
22
|
class SendQueueAllocError < NoMemoryError; end
|
33
23
|
class TooLongError < RuntimeError; end
|
34
24
|
class EmptyError < RuntimeError; end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tox
|
4
|
+
module Proxies
|
5
|
+
##
|
6
|
+
# @abstract
|
7
|
+
# Base class for proxy used to connect to TCP relays.
|
8
|
+
#
|
9
|
+
class Base
|
10
|
+
HOST_MAX_BYTESIZE = 255
|
11
|
+
PORT_RANGE = 1..65_535
|
12
|
+
|
13
|
+
attr_reader :host, :port
|
14
|
+
|
15
|
+
def initialize(host, port)
|
16
|
+
self.host = host
|
17
|
+
self.port = port
|
18
|
+
end
|
19
|
+
|
20
|
+
def type
|
21
|
+
raise NotImplementedError, "#{self.class}#type"
|
22
|
+
end
|
23
|
+
|
24
|
+
def ==(other)
|
25
|
+
self.class == other.class &&
|
26
|
+
host == other.host &&
|
27
|
+
port == other.port
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def host=(value)
|
33
|
+
unless value.is_a? String
|
34
|
+
raise TypeError, "Expected #{String}, got #{value.class}"
|
35
|
+
end
|
36
|
+
unless value.bytesize <= HOST_MAX_BYTESIZE
|
37
|
+
raise 'Proxy host string can not ' \
|
38
|
+
"be longer than #{HOST_MAX_BYTESIZE} bytes"
|
39
|
+
end
|
40
|
+
@host = value.frozen? ? value : value.dup.freeze
|
41
|
+
end
|
42
|
+
|
43
|
+
def port=(value)
|
44
|
+
unless value.is_a? Integer
|
45
|
+
raise TypeError, "Expected #{Integer}, got #{value.class}"
|
46
|
+
end
|
47
|
+
unless PORT_RANGE.include? value
|
48
|
+
raise "Expected value to be from range #{PORT_RANGE}"
|
49
|
+
end
|
50
|
+
@port = value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tox
|
4
|
+
##
|
5
|
+
# Type of proxy used to connect to TCP relays.
|
6
|
+
#
|
7
|
+
module ProxyType
|
8
|
+
# Don't use a proxy.
|
9
|
+
NONE = :none
|
10
|
+
|
11
|
+
# HTTP proxy using CONNECT.
|
12
|
+
HTTP = :http
|
13
|
+
|
14
|
+
# SOCKS proxy for simple socket pipes.
|
15
|
+
SOCKS5 = :socks5
|
16
|
+
end
|
17
|
+
end
|
data/lib/tox/public_key.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# tox.rb - Ruby interface for libtoxcore
|
4
|
-
# Copyright (C) 2015-2017 Braiden Vasco
|
5
|
-
#
|
6
|
-
# This program is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
3
|
module Tox
|
20
4
|
##
|
21
5
|
# Public key primitive.
|
data/lib/tox/status.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# tox.rb - Ruby interface for libtoxcore
|
4
|
-
# Copyright (C) 2015-2017 Braiden Vasco
|
5
|
-
#
|
6
|
-
# This program is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
3
|
module Tox
|
20
4
|
##
|
21
5
|
# Tox network status received from server running https://github.com/Tox/ToxStatus
|
data/lib/tox/user_status.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# tox.rb - Ruby interface for libtoxcore
|
4
|
-
# Copyright (C) 2015-2017 Braiden Vasco
|
5
|
-
#
|
6
|
-
# This program is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
3
|
module Tox
|
20
4
|
##
|
21
5
|
# Represents the possible statuses a client can have.
|
data/lib/tox/version.rb
CHANGED
@@ -1,28 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# tox.rb - Ruby interface for libtoxcore
|
4
|
-
# Copyright (C) 2015-2017 Braiden Vasco
|
5
|
-
#
|
6
|
-
# This program is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
3
|
module Tox
|
20
4
|
##
|
21
5
|
# Gem, library API and ABI version strings and component numbers.
|
22
6
|
#
|
23
7
|
module Version
|
24
8
|
# Gem version.
|
25
|
-
GEM_VERSION = '0.0.
|
9
|
+
GEM_VERSION = '0.0.3'
|
26
10
|
|
27
11
|
def self.const_missing(name)
|
28
12
|
return "#{API_MAJOR}.#{API_MINOR}.#{API_PATCH}" if name == :API_VERSION
|
data/tox.gemspec
CHANGED
@@ -14,17 +14,23 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.summary = 'Ruby interface for libtoxcore'
|
15
15
|
spec.platform = Gem::Platform::RUBY
|
16
16
|
|
17
|
+
spec.required_ruby_version = '~> 2.3'
|
18
|
+
|
17
19
|
spec.authors = ['Braiden Vasco']
|
18
20
|
spec.email = %w[braiden-vasco@users.noreply.github.com]
|
19
21
|
|
20
|
-
spec.required_ruby_version = '~> 2.3'
|
21
|
-
|
22
22
|
spec.description = <<-END.split.join ' '
|
23
23
|
Ruby interface for libtoxcore. It can be used to create Tox chat client or bot.
|
24
24
|
The interface is object-oriented instead of C-style (raises exceptions
|
25
25
|
instead of returning error codes, uses classes to represent primitives, etc.)
|
26
26
|
END
|
27
27
|
|
28
|
+
spec.metadata = {
|
29
|
+
'homepage_uri' => 'https://github.com/toxon/tox.rb',
|
30
|
+
'source_code_uri' => 'https://github.com/toxon/tox.rb',
|
31
|
+
'bug_tracker_uri' => 'https://github.com/toxon/tox.rb/issues',
|
32
|
+
}.freeze
|
33
|
+
|
28
34
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
29
35
|
f.match %r{^(test|spec|features)/}
|
30
36
|
end
|
@@ -43,4 +49,5 @@ Gem::Specification.new do |spec|
|
|
43
49
|
spec.add_development_dependency 'yard', '~> 0.9'
|
44
50
|
spec.add_development_dependency 'rake-compiler', '~> 1.0'
|
45
51
|
spec.add_development_dependency 'faker', '~> 1.8'
|
52
|
+
spec.add_development_dependency 'celluloid', '~> 0.17'
|
46
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braiden Vasco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.8'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: celluloid
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.17'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.17'
|
139
153
|
description: Ruby interface for libtoxcore. It can be used to create Tox chat client
|
140
154
|
or bot. The interface is object-oriented instead of C-style (raises exceptions instead
|
141
155
|
of returning error codes, uses classes to represent primitives, etc.)
|
@@ -157,8 +171,7 @@ files:
|
|
157
171
|
- LICENSE
|
158
172
|
- README.md
|
159
173
|
- Rakefile
|
160
|
-
- bin/
|
161
|
-
- bin/build/libtoxcore
|
174
|
+
- bin/childprocess
|
162
175
|
- bin/console
|
163
176
|
- examples/echo_bot.rb
|
164
177
|
- ext/tox/client.c
|
@@ -170,14 +183,20 @@ files:
|
|
170
183
|
- ext/tox/version.c
|
171
184
|
- lib/tox.rb
|
172
185
|
- lib/tox/address.rb
|
186
|
+
- lib/tox/address_checksum.rb
|
173
187
|
- lib/tox/binary.rb
|
174
188
|
- lib/tox/client.rb
|
189
|
+
- lib/tox/connection_status.rb
|
175
190
|
- lib/tox/friend.rb
|
176
|
-
- lib/tox/friend/out_message.rb
|
177
191
|
- lib/tox/node.rb
|
178
192
|
- lib/tox/nospam.rb
|
179
193
|
- lib/tox/options.rb
|
194
|
+
- lib/tox/out_friend_message.rb
|
180
195
|
- lib/tox/out_message.rb
|
196
|
+
- lib/tox/proxies/base.rb
|
197
|
+
- lib/tox/proxies/http.rb
|
198
|
+
- lib/tox/proxies/socks5.rb
|
199
|
+
- lib/tox/proxy_type.rb
|
181
200
|
- lib/tox/public_key.rb
|
182
201
|
- lib/tox/status.rb
|
183
202
|
- lib/tox/user_status.rb
|
@@ -186,7 +205,10 @@ files:
|
|
186
205
|
homepage: https://github.com/toxon/tox.rb
|
187
206
|
licenses:
|
188
207
|
- GPL-3.0
|
189
|
-
metadata:
|
208
|
+
metadata:
|
209
|
+
homepage_uri: https://github.com/toxon/tox.rb
|
210
|
+
source_code_uri: https://github.com/toxon/tox.rb
|
211
|
+
bug_tracker_uri: https://github.com/toxon/tox.rb/issues
|
190
212
|
post_install_message:
|
191
213
|
rdoc_options: []
|
192
214
|
require_paths:
|
@@ -203,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
225
|
version: '0'
|
204
226
|
requirements: []
|
205
227
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.6
|
228
|
+
rubygems_version: 2.7.6
|
207
229
|
signing_key:
|
208
230
|
specification_version: 4
|
209
231
|
summary: Ruby interface for libtoxcore
|
data/bin/build/libsodium
DELETED
data/bin/build/libtoxcore
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# tox.rb - Ruby interface for libtoxcore
|
4
|
-
# Copyright (C) 2015-2017 Braiden Vasco
|
5
|
-
#
|
6
|
-
# This program is free software: you can redistribute it and/or modify
|
7
|
-
# it under the terms of the GNU General Public License as published by
|
8
|
-
# the Free Software Foundation, either version 3 of the License, or
|
9
|
-
# (at your option) any later version.
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU General Public License for more details.
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public License
|
17
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
-
|
19
|
-
module Tox
|
20
|
-
class Friend
|
21
|
-
##
|
22
|
-
# Outgoing friend message representation in Tox client.
|
23
|
-
#
|
24
|
-
class OutMessage
|
25
|
-
include Tox::OutMessage
|
26
|
-
|
27
|
-
attr_reader :friend, :id
|
28
|
-
|
29
|
-
def initialize(friend, id)
|
30
|
-
self.friend = friend
|
31
|
-
self.id = id
|
32
|
-
end
|
33
|
-
|
34
|
-
def client
|
35
|
-
friend.client
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def friend=(value)
|
41
|
-
unless value.is_a? Friend
|
42
|
-
raise TypeError, "expected friend to be a #{Friend}"
|
43
|
-
end
|
44
|
-
@friend = value
|
45
|
-
end
|
46
|
-
|
47
|
-
def id=(value)
|
48
|
-
unless value.is_a? Integer
|
49
|
-
raise TypeError, "expected id to be an #{Integer}"
|
50
|
-
end
|
51
|
-
unless value >= 0
|
52
|
-
raise ArgumentError, 'expected id to be greater than or equal to zero'
|
53
|
-
end
|
54
|
-
@id = value
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|