Module: PiholeApi::AuthorisedFormEndpoints
Constant Summary
Constants included from Constants
Constants::API_PATH, Constants::INDEX_PATH, Constants::LOGIN_PATH, Constants::TELEPORTER_PATH, Constants::TOKEN_REGEX, Constants::TOKEN_SEPERATOR
Instance Method Summary collapse
-
#auth_form_token ⇒ Object
These endpoints need to be authorised They are non API backed endpoints the require separate auth discourse.pi-hole.net/t/pi-hole-api/1863.
-
#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) ⇒ Object
This does not use the API.
Instance Method Details
#auth_form_token ⇒ Object
These endpoints need to be authorised They are non API backed endpoints the require separate auth discourse.pi-hole.net/t/pi-hole-api/1863
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pihole-api/authorised_form_endpoints.rb', line 9 def auth_form_token # Login login_response = HTTParty.post( "#{base_path}/#{LOGIN_PATH}", body: { pw: password } ) = login_response.headers["set-cookie"].split(TOKEN_SEPERATOR).first # Index index_response = HTTParty.get( "#{base_path}/#{INDEX_PATH}", headers: { "Cookie": } ) # Get form token @form_token = TOKEN_REGEX.match(index_response.body)[1] end |
#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) ⇒ Object
This does not use the API
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pihole-api/authorised_form_endpoints.rb', line 29 def 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) auth_form_token unless @form_token # authorise_and_send(http_method:, command:, payload: {}, params: {}, custom_path: nil) # Content-Type: application/octet-stream # zip_file ; filename="" custom_path = "#{base_path}/#{TELEPORTER_PATH}" payload = { "token": @form_token, "whitelist": whitelist, "regex_whitelist": regex_whitelist, "blacklist": blacklist, "regexlist": regexlist, "adlist": adlist, "client": client, "group": group, "auditlog": auditlog, "staticdhcpleases": staticdhcpleases, "localdnsrecords": localdnsrecords, "localcnamerecords": localcnamerecords, "flushtables": flushtables } HTTParty.post(custom_path, body: payload, headers: { "Cookie": }) end |