pihole-api 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0819b5dbc059b9bded89781059e55824fc94d102e4e2b4aec8d54ecec1d1d5fb'
4
- data.tar.gz: 3f44a5bc69c7037aa2078b2c662ed216f2a153e0af42853f2ac19872046f0b90
3
+ metadata.gz: 72274b476c945fb672d06332375555bc2aec2defb464238619f263e1aa3de808
4
+ data.tar.gz: 4b033a3662517060589a5203cd03c75ad28b7a662f72932339fe4582ef3abe81
5
5
  SHA512:
6
- metadata.gz: 479bdb784791d1fb764b05f710f146d34ec21d5887246eab3e3cc04b20fbab43547550859442d1cd0ff37a0b77fd2049fd17adbe48b8140ee312aa5e5c2d5658
7
- data.tar.gz: 4048e62ab0cff87b404da183fa13e82d9d7c798a5b297e6e3436b485190bdfc8368d4a7d9224e0c6a9c7905bc65b7608f5bbaa7640590d03ded9f81f1d4926c9
6
+ metadata.gz: bc1f224963cc84e0ac8f2574fd83667aec056e224b1d8d884d943460f5cc740adbf24059f8ddb6fbdbf74e3f5512f006c64687281a5ea21e13152a9f806d03ec
7
+ data.tar.gz: 76a8fe962a747f5ec7e138f7e394441f0ecbf32a93ca1aa4946058f3ea5f5b9041d156f24f5ff4bd64767c077fc3fc9559a018a85483fae30cdc131ff8ea81c4
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.4
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pihole-api (0.0.5)
4
+ pihole-api (0.0.6)
5
5
  active_attr (~> 0.16.0)
6
6
  httparty (~> 0.22.0)
7
- nokogiri (~> 1.16.5)
7
+ nokogiri (~> 1.16.7)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -41,8 +41,8 @@ GEM
41
41
  minitest (>= 5.1)
42
42
  mutex_m
43
43
  tzinfo (~> 2.0)
44
- addressable (2.8.6)
45
- public_suffix (>= 2.0.2, < 6.0)
44
+ addressable (2.8.7)
45
+ public_suffix (>= 2.0.2, < 7.0)
46
46
  ansi (1.5.0)
47
47
  base64 (0.2.0)
48
48
  bigdecimal (3.1.8)
@@ -57,7 +57,7 @@ GEM
57
57
  csv (3.3.0)
58
58
  drb (2.2.1)
59
59
  erubi (1.12.0)
60
- hashdiff (1.1.0)
60
+ hashdiff (1.1.1)
61
61
  httparty (0.22.0)
62
62
  csv
63
63
  mini_mime (>= 1.0.0)
@@ -69,35 +69,35 @@ GEM
69
69
  nokogiri (>= 1.12.0)
70
70
  method_source (1.1.0)
71
71
  mini_mime (1.1.5)
72
- minitest (5.21.2)
72
+ minitest (5.25.1)
73
73
  minitest-focus (1.4.0)
74
74
  minitest (>= 4, < 6)
75
- minitest-reporters (1.6.1)
75
+ minitest-reporters (1.7.1)
76
76
  ansi
77
77
  builder
78
78
  minitest (>= 5.0)
79
79
  ruby-progressbar
80
- mocha (2.1.0)
80
+ mocha (2.4.5)
81
81
  ruby2_keywords (>= 0.0.5)
82
82
  multi_xml (0.7.1)
83
83
  bigdecimal (~> 3.1)
84
84
  mutex_m (0.2.0)
85
- nokogiri (1.16.5-aarch64-linux)
85
+ nokogiri (1.16.7-aarch64-linux)
86
86
  racc (~> 1.4)
87
- nokogiri (1.16.5-arm-linux)
87
+ nokogiri (1.16.7-arm-linux)
88
88
  racc (~> 1.4)
89
- nokogiri (1.16.5-arm64-darwin)
89
+ nokogiri (1.16.7-arm64-darwin)
90
90
  racc (~> 1.4)
91
- nokogiri (1.16.5-x86-linux)
91
+ nokogiri (1.16.7-x86-linux)
92
92
  racc (~> 1.4)
93
- nokogiri (1.16.5-x86_64-darwin)
93
+ nokogiri (1.16.7-x86_64-darwin)
94
94
  racc (~> 1.4)
95
- nokogiri (1.16.5-x86_64-linux)
95
+ nokogiri (1.16.7-x86_64-linux)
96
96
  racc (~> 1.4)
97
97
  pry (0.14.2)
98
98
  coderay (~> 1.1)
99
99
  method_source (~> 1.0)
100
- public_suffix (5.0.5)
100
+ public_suffix (6.0.1)
101
101
  racc (1.8.0)
102
102
  rack (3.0.11)
103
103
  rack-session (2.0.0)
@@ -111,16 +111,16 @@ GEM
111
111
  rails-html-sanitizer (1.6.0)
112
112
  loofah (~> 2.21)
113
113
  nokogiri (~> 1.14)
114
- rake (13.1.0)
115
- rexml (3.2.8)
116
- strscan (>= 3.0.9)
114
+ rake (13.2.1)
115
+ rexml (3.3.5)
116
+ strscan
117
117
  ruby-progressbar (1.13.0)
118
118
  ruby2_keywords (0.0.5)
119
119
  strscan (3.1.0)
120
- timecop (0.9.8)
120
+ timecop (0.9.10)
121
121
  tzinfo (2.0.6)
122
122
  concurrent-ruby (~> 1.0)
123
- webmock (3.19.1)
123
+ webmock (3.23.1)
124
124
  addressable (>= 2.8.0)
125
125
  crack (>= 0.3.2)
126
126
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -134,15 +134,15 @@ PLATFORMS
134
134
  x86_64-linux
135
135
 
136
136
  DEPENDENCIES
137
- minitest (~> 5.21.2)
137
+ minitest (~> 5.25.1)
138
138
  minitest-focus (~> 1.4.0)
139
- minitest-reporters (~> 1.6.1)
140
- mocha (~> 2.1.0)
139
+ minitest-reporters (~> 1.7.1)
140
+ mocha (~> 2.4.5)
141
141
  pihole-api!
142
142
  pry (~> 0.14.2)
143
- rake (~> 13.1.0)
144
- timecop (~> 0.9.8)
145
- webmock (~> 3.19.1)
143
+ rake (~> 13.2.1)
144
+ timecop (~> 0.9.10)
145
+ webmock (~> 3.23.1)
146
146
 
147
147
  BUNDLED WITH
148
- 2.5.9
148
+ 2.5.17
@@ -0,0 +1,67 @@
1
+ module PiholeApi
2
+ module AuthorisedFormEndpoints
3
+ include ::PiholeApi::Constants
4
+
5
+ # These endpoints need to be authorised
6
+ # They are non API backed endpoints the require separate auth
7
+ # https://discourse.pi-hole.net/t/pi-hole-api/1863
8
+
9
+ def auth_form_token
10
+ # Login
11
+ login_response = HTTParty.post(
12
+ "#{base_path}/#{LOGIN_PATH}",
13
+ body: { pw: password }
14
+ )
15
+
16
+ @cookie = login_response.headers["set-cookie"].split(TOKEN_SEPERATOR).first
17
+
18
+ # Index
19
+ index_response = HTTParty.get(
20
+ "#{base_path}/#{INDEX_PATH}",
21
+ headers: { "Cookie": @cookie }
22
+ )
23
+
24
+ # Get form token
25
+ @form_token = TOKEN_REGEX.match(index_response.body)[1]
26
+ end
27
+
28
+ # This does not use the API
29
+ def teleport(whitelist: true,
30
+ regex_whitelist: true,
31
+ blacklist: true,
32
+ regexlist: true,
33
+ adlist: true,
34
+ client: true,
35
+ group: true,
36
+ auditlog: true,
37
+ staticdhcpleases: true,
38
+ localdnsrecords: true,
39
+ localcnamerecords: true,
40
+ flushtables: true)
41
+
42
+ auth_form_token unless @form_token
43
+
44
+ # authorise_and_send(http_method:, command:, payload: {}, params: {}, custom_path: nil)
45
+ # Content-Type: application/octet-stream
46
+ # zip_file ; filename=""
47
+ custom_path = "#{base_path}/#{TELEPORTER_PATH}"
48
+ payload = {
49
+ "token": @form_token,
50
+ "whitelist": whitelist,
51
+ "regex_whitelist": regex_whitelist,
52
+ "blacklist": blacklist,
53
+ "regexlist": regexlist,
54
+ "adlist": adlist,
55
+ "client": client,
56
+ "group": group,
57
+ "auditlog": auditlog,
58
+ "staticdhcpleases": staticdhcpleases,
59
+ "localdnsrecords": localdnsrecords,
60
+ "localcnamerecords": localcnamerecords,
61
+ "flushtables": flushtables
62
+ }
63
+
64
+ HTTParty.post(custom_path, body: payload, headers: { "Cookie": @cookie })
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module PiholeApi
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data/pihole-api.gemspec CHANGED
@@ -24,16 +24,16 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency "httparty", "~> 0.22.0"
26
26
  spec.add_dependency "active_attr", "~> 0.16.0"
27
- spec.add_dependency "nokogiri", "~> 1.16.5"
27
+ spec.add_dependency "nokogiri", "~> 1.16.7"
28
28
  # spec.add_dependency "oj", "~> 3.16.3"
29
29
 
30
30
  # Development dependancies
31
- spec.add_development_dependency "rake", "~> 13.1.0"
32
- spec.add_development_dependency "minitest", "~> 5.21.2"
31
+ spec.add_development_dependency "rake", "~> 13.2.1"
32
+ spec.add_development_dependency "minitest", "~> 5.25.1"
33
33
  spec.add_development_dependency "minitest-focus", "~> 1.4.0"
34
- spec.add_development_dependency "minitest-reporters", "~> 1.6.1"
35
- spec.add_development_dependency "timecop", "~> 0.9.8"
36
- spec.add_development_dependency "mocha", "~> 2.1.0"
34
+ spec.add_development_dependency "minitest-reporters", "~> 1.7.1"
35
+ spec.add_development_dependency "timecop", "~> 0.9.10"
36
+ spec.add_development_dependency "mocha", "~> 2.4.5"
37
37
  spec.add_development_dependency "pry", "~> 0.14.2"
38
- spec.add_development_dependency "webmock", "~> 3.19.1"
38
+ spec.add_development_dependency "webmock", "~> 3.23.1"
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pihole-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-02 00:00:00.000000000 Z
11
+ date: 2024-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.16.5
47
+ version: 1.16.7
48
48
  type: :runtime
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: 1.16.5
54
+ version: 1.16.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 13.1.0
61
+ version: 13.2.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 13.1.0
68
+ version: 13.2.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 5.21.2
75
+ version: 5.25.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 5.21.2
82
+ version: 5.25.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: minitest-focus
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,42 +100,42 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.6.1
103
+ version: 1.7.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.6.1
110
+ version: 1.7.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: timecop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.9.8
117
+ version: 0.9.10
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.9.8
124
+ version: 0.9.10
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: mocha
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 2.1.0
131
+ version: 2.4.5
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 2.1.0
138
+ version: 2.4.5
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 3.19.1
159
+ version: 3.23.1
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 3.19.1
166
+ version: 3.23.1
167
167
  description: A client for using the PiholeApi API in Ruby. Built form their api documentation.
168
168
  https://discourse.pi-hole.net/t/using-the-api/976/6. This is an unofficial project.
169
169
  email:
@@ -186,6 +186,7 @@ files:
186
186
  - bin/setup
187
187
  - lib/pihole-api.rb
188
188
  - lib/pihole-api/authorised_endpoints.rb
189
+ - lib/pihole-api/authorised_form_endpoints.rb
189
190
  - lib/pihole-api/client.rb
190
191
  - lib/pihole-api/constants.rb
191
192
  - lib/pihole-api/unauthorised_endpoints.rb
@@ -210,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  - !ruby/object:Gem::Version
211
212
  version: '0'
212
213
  requirements: []
213
- rubygems_version: 3.3.26
214
+ rubygems_version: 3.5.11
214
215
  signing_key:
215
216
  specification_version: 4
216
217
  summary: A client for using the PiholeApi API in Ruby.