inwx 0.1.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4e66fb5d434a2533deedf01443f3f61de3c4452
4
+ data.tar.gz: 648e9beab6d9397b9d4a6b9772b2549858fdba36
5
+ SHA512:
6
+ metadata.gz: c6aee9f386318f12217432f9eec1a984ffe806dfc50976abe670d81f988d7378570ca14f055d0c26287f907637412c95095c014752e7fabcf01eb671d1fa9603
7
+ data.tar.gz: b370446333ab7b750390b35c73146b8aa9ff3431c17edc62603ff1e88f62075a1eb14aaa4192a7e2b54cb5ac6e5b43e9472b08201fa02369a4d28d90d647a399
@@ -0,0 +1,20 @@
1
+ Copyright 2016
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Inwx
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'inwx'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install inwx
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Inwx'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,126 @@
1
+ require "xmlrpc/client"
2
+ require "digest/sha2"
3
+ require "yaml"
4
+ module Inwx
5
+ DEFAULT_WEB_IP = "0.0.0.0"
6
+ DEFAULT_NAMESERVER_TYPE = "MASTER"
7
+ DEFAULT_NAMESERVER_LIST = ["ns.danielthal.de", "ns2.danielthal.de", "ns3.danielthal.de", "ns4.danielthal.de", "ns5.danielthal.de"]
8
+ DEFAULT_MAILSERVER_IP = "0.0.0.0"
9
+ DEFAULT_SOA_MAIL = "hostmaster@inwx.de"
10
+
11
+ class Nameserver
12
+ attr_accessor :api_client
13
+
14
+ def initialize(user=false, pass=false, address="api.domrobot.com", lang="en")
15
+ self.api_client = DomainRobot.new(address, user, pass, lang)
16
+ end
17
+
18
+ def user=(u)
19
+ self.api_client.username=u
20
+ end
21
+
22
+ def pass=(p)
23
+ self.api_client.password=p
24
+ end
25
+
26
+ def address=(a)
27
+ self.api_client.address=(a)
28
+ end
29
+
30
+ def add_domain(domain_name, send_params={}) # IS WORKING CORRECT
31
+ params = {:domain => domain_name, :type => DEFAULT_NAMESERVER_TYPE, :ns => DEFAULT_NAMESERVER_LIST, :web => DEFAULT_WEB_IP, :mail => DEFAULT_MAILSERVER_IP, :soaEmail => DEFAULT_SOA_MAIL}
32
+ params.merge! send_params
33
+ response = self.api_client.call("nameserver", "create", params)
34
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
35
+ [false, response]
36
+ end
37
+
38
+ def delete_domain(domain_name, roId) # IS WORKING CORRECT
39
+ params = {:domain => domain_name, :roId => roId}
40
+ response = self.api_client.call("nameserver", "delete", params)
41
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
42
+ [false, response]
43
+ end
44
+
45
+ def list_domains(page=0, pagelimit=0) # IS WORKING CORRECT
46
+ params = {:page => page, :pagelimit => pagelimit}
47
+ response = self.api_client.call("nameserver", "list", params)
48
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
49
+ [false, response]
50
+ end
51
+
52
+ def search_domain(domain, page=0, pagelimit=0) # IS WORKING CORRECT
53
+ params = {:domain => domain, :page => page, :pagelimit => pagelimit}
54
+ response = self.api_client.call("nameserver", "list", params)
55
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
56
+ [false, response]
57
+ end
58
+
59
+ def info_domain(roId) # IS WORKING CORRECT
60
+ params = {:roId => roId}
61
+ response = self.api_client.call("nameserver", "info", params)
62
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
63
+ [false, response]
64
+ end
65
+
66
+ def create_domain_record(roId, type, content, send_params={}) # IS WORKING CORRECT
67
+ params = {:roId => roId, :type => type, :content => content}
68
+ params.merge! send_params
69
+ response = self.api_client.call("nameserver", "createRecord", params)
70
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
71
+ [false, response]
72
+ end
73
+
74
+ def delete_domain_record(id) # IS WORKING CORRECT
75
+ params = {:id => id}
76
+ response = self.api_client.call("nameserver", "deleteRecord", params)
77
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
78
+ [false, response]
79
+ end
80
+
81
+ def update_domain_record(id, send_params={}) # IS WORKING CORRECT
82
+ params = {:id => id}
83
+ params.merge! send_params
84
+ response = self.api_client.call("nameserver", "updateRecord", params)
85
+ return [true, response] if response["code"] == 1000 or response["code"] == 1001
86
+ [false, response]
87
+ end
88
+ end
89
+
90
+
91
+ class DomainRobot
92
+ attr_accessor :address, :username, :password, :language, :secure
93
+
94
+ def initialize(address, username = false, password = false, language = 'en', secure = false)
95
+ @address = address
96
+ @username = username
97
+ @password = password
98
+ @language = language
99
+ @secure = secure
100
+ end
101
+
102
+ def call(object, method, params = {})
103
+ if self.secure
104
+ # Get a one-time-"random" nonce
105
+ nonce = Time.now.to_f
106
+
107
+ # Generate hash from nonce and password.
108
+ hash = Digest::SHA2.new(bitlen = 256) << nonce.to_s + self.password.to_s
109
+
110
+ # Merge both into params
111
+ params.merge! :pass => hash.to_s
112
+ else
113
+ params.merge! :pass => self.password
114
+ end
115
+
116
+ # Merge username into params
117
+ params.merge! :user => self.username
118
+
119
+ # Create a new client instance
120
+ client = XMLRPC::Client.new(self.address, "/xmlrpc/", "443", nil, nil, nil, nil, true, 900)
121
+
122
+ # Call the remote method
123
+ client.call(object+"."+method, params)
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,3 @@
1
+ module Inwx
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :inwx do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inwx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Thal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: sqlite3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: An XML-RPC Client for the API of INWX.
48
+ email:
49
+ - gems@danielthal.de
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - lib/inwx.rb
58
+ - lib/inwx/version.rb
59
+ - lib/tasks/inwx_tasks.rake
60
+ homepage: http://www.danielthal.de
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.5.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: INWX API Client
84
+ test_files: []