deluge-rpc 0.1.3 → 0.2.2
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/.ruby-version +1 -1
- data/README.md +22 -12
- data/deluge-rpc.gemspec +7 -4
- data/lib/deluge/rpc/connection.rb +22 -13
- data/lib/deluge/rpc/version.rb +1 -1
- metadata +31 -19
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: fae94aca88e0cdf01efdc40596aea1d07b24d48d475f7302723bf82abdeb7a64
         | 
| 4 | 
            +
              data.tar.gz: ffa497496c6caa1027eab7dde89a6676df48a34634344c109863cf974509f4b3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f670476d2ab81393c6b0db0393293c1ca2e4db7c3170bf19c7d17d623e3596447b5e622b4ad5287e9dde8e4c38a3f027f7a909f608f35267788b65c05e9b442e
         | 
| 7 | 
            +
              data.tar.gz: 4fde233a805d65cccde068bf7838a2407682902ecb88bb42e9d1454dd67f0153e94703a75d984fd62aa7337dc34b5bf8e1628e65d293e87133140e3a99a4cd76
         | 
    
        data/.ruby-version
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            3.0.3
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,14 +1,19 @@ | |
| 1 1 | 
             
            # Deluge::RPC
         | 
| 2 2 |  | 
| 3 | 
            -
            Ruby RPC client library for Deluge torrent client. | 
| 4 | 
            -
            Provides dynamic API bindings depending on RPC server. | 
| 3 | 
            +
            Ruby RPC client library for [Deluge 2.0+ torrent client](https://deluge-torrent.org/).
         | 
| 4 | 
            +
            Provides dynamic API bindings depending on RPC server.
         | 
| 5 5 | 
             
            Multi-threading friendly, thanks to ``concurrent-ruby`` gem.
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
            http://deluge.readthedocs.org/en/develop/core/rpc.html
         | 
| 7 | 
            +
            *Deluge 1.x is not supported anymore*.
         | 
| 9 8 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 9 | 
            +
            ## Reference
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * [Official RPC protocol documentation](https://deluge.readthedocs.io/en/latest/reference/rpc.html)
         | 
| 12 | 
            +
            * [Deluge RPC API reference](https://deluge.readthedocs.io/en/latest/reference/api.html)
         | 
| 13 | 
            +
            * [Official repository](https://github.com/deluge-torrent/deluge)
         | 
| 14 | 
            +
            * Other client implementations:
         | 
| 15 | 
            +
              [Go](https://github.com/gdm85/go-libdeluge),
         | 
| 16 | 
            +
              [Python](https://github.com/JohnDoee/deluge-client)
         | 
| 12 17 |  | 
| 13 18 | 
             
            ## Usage
         | 
| 14 19 |  | 
| @@ -72,10 +77,10 @@ client.register_event(:torrent_removed) do |torrent_id| | |
| 72 77 | 
             
            end
         | 
| 73 78 | 
             
            ```
         | 
| 74 79 |  | 
| 75 | 
            -
            Unfortunately there is no way to listen ALL events, due to Deluge architecture. | 
| 80 | 
            +
            Unfortunately there is no way to listen ALL events, due to Deluge architecture.
         | 
| 76 81 | 
             
            You have to register each event you need.
         | 
| 77 82 |  | 
| 78 | 
            -
            **Keep in mind event blocks would be executed in connection thread, NOT main thread!** | 
| 83 | 
            +
            **Keep in mind event blocks would be executed in connection thread, NOT main thread!**
         | 
| 79 84 | 
             
            Avoid time-consuming code!
         | 
| 80 85 |  | 
| 81 86 | 
             
            ### Known events
         | 
| @@ -100,10 +105,11 @@ Avoid time-consuming code! | |
| 100 105 | 
             
            ``PluginEnabledEvent``        | name                    | Plugin is enabled in the Core.
         | 
| 101 106 | 
             
            ``PluginDisabledEvent``       | name                    | Plugin is disabled in the Core.
         | 
| 102 107 |  | 
| 103 | 
            -
            This list was extracted from Deluge 1.3.11 sources. Events for your version could be different. | 
| 108 | 
            +
            This list was extracted from Deluge 1.3.11 sources. Events for your version could be different.
         | 
| 104 109 | 
             
            There is no official documentation.
         | 
| 105 110 |  | 
| 106 | 
            -
            Current events could be found here: | 
| 111 | 
            +
            Current events could be found here:
         | 
| 112 | 
            +
            https://github.com/deluge-torrent/deluge/blob/master/deluge/event.py
         | 
| 107 113 |  | 
| 108 114 | 
             
            ## Installation
         | 
| 109 115 |  | 
| @@ -115,8 +121,12 @@ gem 'deluge-rpc' | |
| 115 121 |  | 
| 116 122 | 
             
            And then execute:
         | 
| 117 123 |  | 
| 118 | 
            -
             | 
| 124 | 
            +
            ```shell
         | 
| 125 | 
            +
            $ bundle
         | 
| 126 | 
            +
            ```
         | 
| 119 127 |  | 
| 120 128 | 
             
            Or install it yourself as:
         | 
| 121 129 |  | 
| 122 | 
            -
             | 
| 130 | 
            +
            ```shell
         | 
| 131 | 
            +
            $ gem install deluge-rpc
         | 
| 132 | 
            +
            ```
         | 
    
        data/deluge-rpc.gemspec
    CHANGED
    
    | @@ -12,14 +12,17 @@ Gem::Specification.new do |spec| | |
| 12 12 | 
             
              spec.description   = %q{Communicate with Deluge torrent client via RPC protocol}
         | 
| 13 13 | 
             
              spec.homepage      = "https://github.com/t3hk0d3/deluge-rpc"
         | 
| 14 14 | 
             
              spec.license       = "MIT"
         | 
| 15 | 
            +
              spec.required_ruby_version = '>= 2.6' # rubocop:disable Gemspec/RequiredRubyVersion
         | 
| 15 16 |  | 
| 16 17 | 
             
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 18 | 
             
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 19 | 
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 20 | 
             
              spec.require_paths = ["lib"]
         | 
| 20 21 |  | 
| 21 | 
            -
              spec.add_dependency 'concurrent-ruby', '~>  | 
| 22 | 
            -
              spec.add_dependency 'rencoder', '~> 0. | 
| 23 | 
            -
             | 
| 24 | 
            -
              spec.add_development_dependency 'rspec', '~> 3. | 
| 22 | 
            +
              spec.add_dependency 'concurrent-ruby', '~> 1.1.8'
         | 
| 23 | 
            +
              spec.add_dependency 'rencoder', '~> 0.2'
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              spec.add_development_dependency 'rspec', '~> 3.10.0'
         | 
| 26 | 
            +
              spec.add_development_dependency 'rubocop', '~> 0.90'
         | 
| 27 | 
            +
              spec.add_development_dependency 'rubocop-rspec', '~> 1.43'
         | 
| 25 28 | 
             
            end
         | 
| @@ -1,4 +1,7 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'rencoder'
         | 
| 4 | 
            +
             | 
| 2 5 | 
             
            require 'socket'
         | 
| 3 6 | 
             
            require 'openssl'
         | 
| 4 7 | 
             
            require 'thread'
         | 
| @@ -14,6 +17,8 @@ module Deluge | |
| 14 17 | 
             
                  class InvokeTimeoutError < StandardError; end
         | 
| 15 18 | 
             
                  class ConnectionClosedError < StandardError; end
         | 
| 16 19 |  | 
| 20 | 
            +
                  PROTOCOL_VERSION = 0x01
         | 
| 21 | 
            +
             | 
| 17 22 | 
             
                  DAEMON_LOGIN = 'daemon.login'
         | 
| 18 23 | 
             
                  DAEMON_METHOD_LIST = 'daemon.get_method_list'
         | 
| 19 24 | 
             
                  DAEMON_REGISTER_EVENT = 'daemon.set_event_interest'
         | 
| @@ -62,7 +67,7 @@ module Deluge | |
| 62 67 | 
             
                  end
         | 
| 63 68 |  | 
| 64 69 | 
             
                  def authenticate(login, password)
         | 
| 65 | 
            -
                    self.call(DAEMON_LOGIN, login, password)
         | 
| 70 | 
            +
                    self.call(DAEMON_LOGIN, [login, password, {'client_version' => Deluge::Rpc::VERSION.to_s}])
         | 
| 66 71 | 
             
                  end
         | 
| 67 72 |  | 
| 68 73 | 
             
                  def method_list
         | 
| @@ -88,7 +93,10 @@ module Deluge | |
| 88 93 | 
             
                    raise "Not connected!" unless @connection
         | 
| 89 94 |  | 
| 90 95 | 
             
                    kwargs = {}
         | 
| 91 | 
            -
                     | 
| 96 | 
            +
                    if args.size == 1 && args[0].last.is_a?(Hash)
         | 
| 97 | 
            +
                      kwargs = args[0].pop
         | 
| 98 | 
            +
                      args   = args[0]
         | 
| 99 | 
            +
                    end
         | 
| 92 100 |  | 
| 93 101 | 
             
                    future = Concurrent::IVar.new
         | 
| 94 102 |  | 
| @@ -102,7 +110,7 @@ module Deluge | |
| 102 110 | 
             
                    result = future.value!(@call_timeout)
         | 
| 103 111 |  | 
| 104 112 | 
             
                    if result.nil? && future.pending?
         | 
| 105 | 
            -
                      raise InvokeTimeoutError.new("Failed to  | 
| 113 | 
            +
                      raise InvokeTimeoutError.new("Failed to retrieve response for '#{method}' in #{@call_timeout} seconds. Probably method not exists.")
         | 
| 106 114 | 
             
                    end
         | 
| 107 115 |  | 
| 108 116 | 
             
                    result
         | 
| @@ -167,6 +175,7 @@ module Deluge | |
| 167 175 |  | 
| 168 176 | 
             
                  def write_packet(packet)
         | 
| 169 177 | 
             
                    raw = Zlib::Deflate.deflate Rencoder.dump(packet)
         | 
| 178 | 
            +
                    raw = [PROTOCOL_VERSION, raw.bytesize].pack("CN") + raw
         | 
| 170 179 |  | 
| 171 180 | 
             
                    @write_mutex.synchronize do
         | 
| 172 181 | 
             
                      if IO.select([], [@connection], nil, nil)
         | 
| @@ -177,11 +186,16 @@ module Deluge | |
| 177 186 |  | 
| 178 187 | 
             
                  def read_packets(socket)
         | 
| 179 188 | 
             
                    raw = ""
         | 
| 180 | 
            -
                    begin
         | 
| 181 | 
            -
                      buffer = socket.readpartial(1024)
         | 
| 182 | 
            -
                      raw += buffer
         | 
| 183 | 
            -
                    end until(buffer.size < 1024)
         | 
| 184 189 |  | 
| 190 | 
            +
                    # Read message header
         | 
| 191 | 
            +
                    protocol_version, buffer_size = socket.readpartial(5).unpack('CN')
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                    raise('Received response with unknown protocol_version=' + protocol_version) if protocol_version != PROTOCOL_VERSION
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                    # a big response requires some extra reads because deluged may be
         | 
| 196 | 
            +
                    # slow to generate and send all the data through the socket
         | 
| 197 | 
            +
                    raw += socket.readpartial(buffer_size - raw.bytesize) while raw.bytesize < buffer_size
         | 
| 198 | 
            +
                    
         | 
| 185 199 | 
             
                    raw = Zlib::Inflate.inflate(raw)
         | 
| 186 200 |  | 
| 187 201 | 
             
                    parse_packets(raw)
         | 
| @@ -210,12 +224,7 @@ module Deluge | |
| 210 224 | 
             
                  end
         | 
| 211 225 |  | 
| 212 226 | 
             
                  def ssl_context
         | 
| 213 | 
            -
                     | 
| 214 | 
            -
                    context = OpenSSL::SSL::SSLContext.new('SSLv23')
         | 
| 215 | 
            -
                    # TODO: Consider allowing server certificate validation
         | 
| 216 | 
            -
                    context.set_params(verify_mode: OpenSSL::SSL::VERIFY_NONE)
         | 
| 217 | 
            -
             | 
| 218 | 
            -
                    context
         | 
| 227 | 
            +
                    OpenSSL::SSL::SSLContext.new
         | 
| 219 228 | 
             
                  end
         | 
| 220 229 |  | 
| 221 230 | 
             
                  def parse_packets(raw)
         | 
    
        data/lib/deluge/rpc/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: deluge-rpc
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Igor Yamolov
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2023-03-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: concurrent-ruby
         | 
| @@ -16,56 +16,70 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 1.1.8
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 26 | 
            +
                    version: 1.1.8
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: rencoder
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: '0. | 
| 33 | 
            +
                    version: '0.2'
         | 
| 34 34 | 
             
              type: :runtime
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 38 | 
             
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: '0. | 
| 40 | 
            +
                    version: '0.2'
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name:  | 
| 42 | 
            +
              name: rspec
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 45 | 
             
                - - "~>"
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version:  | 
| 47 | 
            +
                    version: 3.10.0
         | 
| 48 48 | 
             
              type: :development
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - "~>"
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version:  | 
| 54 | 
            +
                    version: 3.10.0
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name:  | 
| 56 | 
            +
              name: rubocop
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0.90'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0.90'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rubocop-rspec
         | 
| 57 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 72 | 
             
                requirements:
         | 
| 59 73 | 
             
                - - "~>"
         | 
| 60 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 75 | 
            +
                    version: '1.43'
         | 
| 62 76 | 
             
              type: :development
         | 
| 63 77 | 
             
              prerelease: false
         | 
| 64 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 79 | 
             
                requirements:
         | 
| 66 80 | 
             
                - - "~>"
         | 
| 67 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: ' | 
| 82 | 
            +
                    version: '1.43'
         | 
| 69 83 | 
             
            description: Communicate with Deluge torrent client via RPC protocol
         | 
| 70 84 | 
             
            email:
         | 
| 71 85 | 
             
            - clouster@yandex.ru
         | 
| @@ -93,7 +107,7 @@ homepage: https://github.com/t3hk0d3/deluge-rpc | |
| 93 107 | 
             
            licenses:
         | 
| 94 108 | 
             
            - MIT
         | 
| 95 109 | 
             
            metadata: {}
         | 
| 96 | 
            -
            post_install_message: | 
| 110 | 
            +
            post_install_message:
         | 
| 97 111 | 
             
            rdoc_options: []
         | 
| 98 112 | 
             
            require_paths:
         | 
| 99 113 | 
             
            - lib
         | 
| @@ -101,20 +115,18 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 101 115 | 
             
              requirements:
         | 
| 102 116 | 
             
              - - ">="
         | 
| 103 117 | 
             
                - !ruby/object:Gem::Version
         | 
| 104 | 
            -
                  version: ' | 
| 118 | 
            +
                  version: '2.6'
         | 
| 105 119 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 106 120 | 
             
              requirements:
         | 
| 107 121 | 
             
              - - ">="
         | 
| 108 122 | 
             
                - !ruby/object:Gem::Version
         | 
| 109 123 | 
             
                  version: '0'
         | 
| 110 124 | 
             
            requirements: []
         | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
            signing_key: 
         | 
| 125 | 
            +
            rubygems_version: 3.2.32
         | 
| 126 | 
            +
            signing_key:
         | 
| 114 127 | 
             
            specification_version: 4
         | 
| 115 128 | 
             
            summary: Deluge RPC protocol wrapper
         | 
| 116 129 | 
             
            test_files:
         | 
| 117 130 | 
             
            - spec/deluge/api/client_spec.rb
         | 
| 118 131 | 
             
            - spec/deluge/api/namespace_spec.rb
         | 
| 119 132 | 
             
            - spec/spec_helper.rb
         | 
| 120 | 
            -
            has_rdoc: 
         |