pihole-api 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +79 -43
- data/README.md +7 -1
- data/lib/pihole-api/client.rb +7 -3
- data/lib/pihole-api/constants.rb +6 -0
- data/lib/pihole-api/version.rb +1 -1
- data/lib/pihole-api.rb +2 -0
- data/pihole-api.gemspec +3 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0819b5dbc059b9bded89781059e55824fc94d102e4e2b4aec8d54ecec1d1d5fb'
|
4
|
+
data.tar.gz: 3f44a5bc69c7037aa2078b2c662ed216f2a153e0af42853f2ac19872046f0b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 479bdb784791d1fb764b05f710f146d34ec21d5887246eab3e3cc04b20fbab43547550859442d1cd0ff37a0b77fd2049fd17adbe48b8140ee312aa5e5c2d5658
|
7
|
+
data.tar.gz: 4048e62ab0cff87b404da183fa13e82d9d7c798a5b297e6e3436b485190bdfc8368d4a7d9224e0c6a9c7905bc65b7608f5bbaa7640590d03ded9f81f1d4926c9
|
data/Gemfile.lock
CHANGED
@@ -1,59 +1,74 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pihole-api (0.0.
|
4
|
+
pihole-api (0.0.5)
|
5
5
|
active_attr (~> 0.16.0)
|
6
|
-
httparty (~> 0.
|
7
|
-
nokogiri (~> 1.16.
|
6
|
+
httparty (~> 0.22.0)
|
7
|
+
nokogiri (~> 1.16.5)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (7.
|
13
|
-
actionview (= 7.
|
14
|
-
activesupport (= 7.
|
15
|
-
|
12
|
+
actionpack (7.1.3.3)
|
13
|
+
actionview (= 7.1.3.3)
|
14
|
+
activesupport (= 7.1.3.3)
|
15
|
+
nokogiri (>= 1.8.5)
|
16
|
+
racc
|
17
|
+
rack (>= 2.2.4)
|
18
|
+
rack-session (>= 1.0.1)
|
16
19
|
rack-test (>= 0.6.3)
|
17
|
-
rails-dom-testing (~> 2.
|
18
|
-
rails-html-sanitizer (~> 1.
|
19
|
-
actionview (7.
|
20
|
-
activesupport (= 7.
|
20
|
+
rails-dom-testing (~> 2.2)
|
21
|
+
rails-html-sanitizer (~> 1.6)
|
22
|
+
actionview (7.1.3.3)
|
23
|
+
activesupport (= 7.1.3.3)
|
21
24
|
builder (~> 3.1)
|
22
|
-
erubi (~> 1.
|
23
|
-
rails-dom-testing (~> 2.
|
24
|
-
rails-html-sanitizer (~> 1.
|
25
|
+
erubi (~> 1.11)
|
26
|
+
rails-dom-testing (~> 2.2)
|
27
|
+
rails-html-sanitizer (~> 1.6)
|
25
28
|
active_attr (0.16.0)
|
26
29
|
actionpack (>= 3.0.2, < 7.2)
|
27
30
|
activemodel (>= 3.0.2, < 7.2)
|
28
31
|
activesupport (>= 3.0.2, < 7.2)
|
29
|
-
activemodel (7.
|
30
|
-
activesupport (= 7.
|
31
|
-
activesupport (7.
|
32
|
+
activemodel (7.1.3.3)
|
33
|
+
activesupport (= 7.1.3.3)
|
34
|
+
activesupport (7.1.3.3)
|
35
|
+
base64
|
36
|
+
bigdecimal
|
32
37
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
38
|
+
connection_pool (>= 2.2.5)
|
39
|
+
drb
|
33
40
|
i18n (>= 1.6, < 2)
|
34
41
|
minitest (>= 5.1)
|
42
|
+
mutex_m
|
35
43
|
tzinfo (~> 2.0)
|
36
|
-
addressable (2.8.
|
44
|
+
addressable (2.8.6)
|
37
45
|
public_suffix (>= 2.0.2, < 6.0)
|
38
46
|
ansi (1.5.0)
|
47
|
+
base64 (0.2.0)
|
48
|
+
bigdecimal (3.1.8)
|
39
49
|
builder (3.2.4)
|
40
50
|
coderay (1.1.3)
|
41
|
-
concurrent-ruby (1.2.
|
42
|
-
|
51
|
+
concurrent-ruby (1.2.3)
|
52
|
+
connection_pool (2.4.1)
|
53
|
+
crack (1.0.0)
|
54
|
+
bigdecimal
|
43
55
|
rexml
|
44
56
|
crass (1.0.6)
|
57
|
+
csv (3.3.0)
|
58
|
+
drb (2.2.1)
|
45
59
|
erubi (1.12.0)
|
46
|
-
hashdiff (1.0
|
47
|
-
httparty (0.
|
60
|
+
hashdiff (1.1.0)
|
61
|
+
httparty (0.22.0)
|
62
|
+
csv
|
48
63
|
mini_mime (>= 1.0.0)
|
49
64
|
multi_xml (>= 0.5.2)
|
50
|
-
i18n (1.
|
65
|
+
i18n (1.14.5)
|
51
66
|
concurrent-ruby (~> 1.0)
|
52
|
-
loofah (2.
|
67
|
+
loofah (2.22.0)
|
53
68
|
crass (~> 1.0.2)
|
54
|
-
nokogiri (>= 1.
|
55
|
-
method_source (1.
|
56
|
-
mini_mime (1.1.
|
69
|
+
nokogiri (>= 1.12.0)
|
70
|
+
method_source (1.1.0)
|
71
|
+
mini_mime (1.1.5)
|
57
72
|
minitest (5.21.2)
|
58
73
|
minitest-focus (1.4.0)
|
59
74
|
minitest (>= 4, < 6)
|
@@ -64,28 +79,46 @@ GEM
|
|
64
79
|
ruby-progressbar
|
65
80
|
mocha (2.1.0)
|
66
81
|
ruby2_keywords (>= 0.0.5)
|
67
|
-
multi_xml (0.
|
68
|
-
|
82
|
+
multi_xml (0.7.1)
|
83
|
+
bigdecimal (~> 3.1)
|
84
|
+
mutex_m (0.2.0)
|
85
|
+
nokogiri (1.16.5-aarch64-linux)
|
86
|
+
racc (~> 1.4)
|
87
|
+
nokogiri (1.16.5-arm-linux)
|
88
|
+
racc (~> 1.4)
|
89
|
+
nokogiri (1.16.5-arm64-darwin)
|
90
|
+
racc (~> 1.4)
|
91
|
+
nokogiri (1.16.5-x86-linux)
|
92
|
+
racc (~> 1.4)
|
93
|
+
nokogiri (1.16.5-x86_64-darwin)
|
94
|
+
racc (~> 1.4)
|
95
|
+
nokogiri (1.16.5-x86_64-linux)
|
69
96
|
racc (~> 1.4)
|
70
97
|
pry (0.14.2)
|
71
98
|
coderay (~> 1.1)
|
72
99
|
method_source (~> 1.0)
|
73
|
-
public_suffix (5.0.
|
74
|
-
racc (1.
|
75
|
-
rack (
|
76
|
-
rack-
|
100
|
+
public_suffix (5.0.5)
|
101
|
+
racc (1.8.0)
|
102
|
+
rack (3.0.11)
|
103
|
+
rack-session (2.0.0)
|
104
|
+
rack (>= 3.0.0)
|
105
|
+
rack-test (2.1.0)
|
77
106
|
rack (>= 1.3)
|
78
|
-
rails-dom-testing (2.0
|
79
|
-
activesupport (>=
|
107
|
+
rails-dom-testing (2.2.0)
|
108
|
+
activesupport (>= 5.0.0)
|
109
|
+
minitest
|
80
110
|
nokogiri (>= 1.6)
|
81
|
-
rails-html-sanitizer (1.
|
82
|
-
loofah (~> 2.
|
111
|
+
rails-html-sanitizer (1.6.0)
|
112
|
+
loofah (~> 2.21)
|
113
|
+
nokogiri (~> 1.14)
|
83
114
|
rake (13.1.0)
|
84
|
-
rexml (3.2.
|
115
|
+
rexml (3.2.8)
|
116
|
+
strscan (>= 3.0.9)
|
85
117
|
ruby-progressbar (1.13.0)
|
86
118
|
ruby2_keywords (0.0.5)
|
119
|
+
strscan (3.1.0)
|
87
120
|
timecop (0.9.8)
|
88
|
-
tzinfo (2.0.
|
121
|
+
tzinfo (2.0.6)
|
89
122
|
concurrent-ruby (~> 1.0)
|
90
123
|
webmock (3.19.1)
|
91
124
|
addressable (>= 2.8.0)
|
@@ -93,9 +126,12 @@ GEM
|
|
93
126
|
hashdiff (>= 0.4.0, < 2.0.0)
|
94
127
|
|
95
128
|
PLATFORMS
|
96
|
-
|
97
|
-
|
98
|
-
arm64-darwin
|
129
|
+
aarch64-linux
|
130
|
+
arm-linux
|
131
|
+
arm64-darwin
|
132
|
+
x86-linux
|
133
|
+
x86_64-darwin
|
134
|
+
x86_64-linux
|
99
135
|
|
100
136
|
DEPENDENCIES
|
101
137
|
minitest (~> 5.21.2)
|
@@ -109,4 +145,4 @@ DEPENDENCIES
|
|
109
145
|
webmock (~> 3.19.1)
|
110
146
|
|
111
147
|
BUNDLED WITH
|
112
|
-
2.5.
|
148
|
+
2.5.9
|
data/README.md
CHANGED
@@ -45,13 +45,16 @@ Or install it yourself as:
|
|
45
45
|
client.type
|
46
46
|
```
|
47
47
|
|
48
|
-
Double hash web password to get the api_token.
|
48
|
+
Double hash web password to get the api_token.
|
49
|
+
A helper method exists on the client to do this:
|
49
50
|
```ruby
|
50
51
|
require 'pihole-api'
|
51
52
|
api_token = PiholeApi::Client.hash_password(password)
|
52
53
|
end
|
53
54
|
```
|
54
55
|
|
56
|
+
However the client now generates the API token automatically from the given password
|
57
|
+
|
55
58
|
### Endpoints
|
56
59
|
#### Authorised
|
57
60
|
- `summary_raw`
|
@@ -66,6 +69,9 @@ end
|
|
66
69
|
- `recent_blocked`
|
67
70
|
- `enable`
|
68
71
|
- `disable`
|
72
|
+
#### Authorised Non API
|
73
|
+
- auth_form_token
|
74
|
+
- `teleport(whitelist: true, regex_whitelist: true, blacklist: true, regexlist: true, adlist: true, client: true, group: true, auditlog: true, staticdhcpleases: true, localdnsrecords: true, localcnamerecords: true, flushtables: true)`
|
69
75
|
|
70
76
|
#### Unauthorised
|
71
77
|
- `type`
|
data/lib/pihole-api/client.rb
CHANGED
@@ -5,11 +5,14 @@ module PiholeApi
|
|
5
5
|
# Endpoints
|
6
6
|
include ::PiholeApi::UnauthorisedEndpoints
|
7
7
|
include ::PiholeApi::AuthorisedEndpoints
|
8
|
+
include ::PiholeApi::AuthorisedFormEndpoints
|
8
9
|
|
9
|
-
attr_reader :api_token, :base_path, :port
|
10
|
+
attr_reader :password, :api_token, :form_token, :cookie, :base_path, :port
|
11
|
+
|
12
|
+
def initialize(base_path:, password:, port: 80)
|
13
|
+
@password = password
|
14
|
+
@api_token = PiholeApi::Client.hash_password(password)
|
10
15
|
|
11
|
-
def initialize(base_path:, api_token:, port: 80)
|
12
|
-
@api_token = api_token
|
13
16
|
@base_path = base_path
|
14
17
|
@port = port
|
15
18
|
end
|
@@ -25,6 +28,7 @@ module PiholeApi
|
|
25
28
|
|
26
29
|
def self.hash_password(password)
|
27
30
|
require 'digest'
|
31
|
+
|
28
32
|
hash1 = Digest::SHA256.hexdigest(password)
|
29
33
|
Digest::SHA256.hexdigest(hash1) # Use as hash password for client
|
30
34
|
end
|
data/lib/pihole-api/constants.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module PiholeApi
|
2
2
|
module Constants
|
3
3
|
API_PATH = 'admin/api.php'
|
4
|
+
LOGIN_PATH = 'admin/login.php'
|
5
|
+
INDEX_PATH = 'admin'
|
6
|
+
TELEPORTER_PATH = 'admin/scripts/pi-hole/php/teleporter.php'
|
7
|
+
|
8
|
+
TOKEN_REGEX = /div\s+id="token"\s+hidden>([^<]+)<\/div>/
|
9
|
+
TOKEN_SEPERATOR = ";"
|
4
10
|
end
|
5
11
|
end
|
data/lib/pihole-api/version.rb
CHANGED
data/lib/pihole-api.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'nokogiri'
|
3
|
+
# require 'oj'
|
3
4
|
|
4
5
|
require 'pihole-api/version'
|
5
6
|
require 'pihole-api/constants'
|
@@ -7,6 +8,7 @@ require 'pihole-api/constants'
|
|
7
8
|
# Endpoints
|
8
9
|
require 'pihole-api/unauthorised_endpoints'
|
9
10
|
require 'pihole-api/authorised_endpoints'
|
11
|
+
require 'pihole-api/authorised_form_endpoints'
|
10
12
|
|
11
13
|
require 'pihole-api/client'
|
12
14
|
|
data/pihole-api.gemspec
CHANGED
@@ -22,9 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency "httparty", "~> 0.
|
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.
|
27
|
+
spec.add_dependency "nokogiri", "~> 1.16.5"
|
28
|
+
# spec.add_dependency "oj", "~> 3.16.3"
|
28
29
|
|
29
30
|
# Development dependancies
|
30
31
|
spec.add_development_dependency "rake", "~> 13.1.0"
|
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.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trex22
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.22.0
|
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: 0.
|
26
|
+
version: 0.22.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: active_attr
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.16.
|
47
|
+
version: 1.16.5
|
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.
|
54
|
+
version: 1.16.5
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.3.26
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: A client for using the PiholeApi API in Ruby.
|