Skip to content

Commit

Permalink
fixed issue with qbit auth
Browse files Browse the repository at this point in the history
  • Loading branch information
clajiness committed Dec 27, 2024
1 parent 515aad3 commit e83237d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion qbop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
# reset counter
counter.reset_opnsense_change
counter.reset_opnsense_attempt
else
@logger.error("OPNsense's change was not applied - response code: #{changes.status}")
end
else
@logger.error("OPNsense's alias was not updated - response code: #{response.status}")
end
end
rescue StandardError => e
Expand Down Expand Up @@ -160,7 +164,7 @@
counter.reset_qbit_change
counter.reset_qbit_attempt
else
@logger.error("qBit's port was not updated")
@logger.error("qBit's port was not updated - response code: #{response.status}")
end
end
rescue StandardError => e
Expand Down
4 changes: 2 additions & 2 deletions service/opnsense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def get_alias_value(uuid)

def set_alias_value(forwarded_port, uuid)
@conn.post do |req|
req.url "#{@config[:opnsense_interface_addr]}/api/firewall/alias/setItem/#{uuid}"
req.url "/api/firewall/alias/setItem/#{uuid}"
req.headers = { 'Content-Type' => 'application/json' }
req.body = { 'alias': { 'content': forwarded_port } }.to_json
end
end

def apply_changes
@conn.post do |req|
req.url "#{@config[:opnsense_interface_addr]}/api/firewall/alias/reconfigure"
req.url '/api/firewall/alias/reconfigure'
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions service/qbit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initialize(config)

def qbt_auth_login # rubocop:disable Metrics/MethodLength
response = @conn.post do |req|
req.url "#{@config[:qbit_addr]}/api/v2/auth/login"
req.headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
req.url '/api/v2/auth/login'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = URI.encode_www_form(
{
'username': @config[:qbit_user],
Expand All @@ -26,7 +26,7 @@ def qbt_auth_login # rubocop:disable Metrics/MethodLength

def qbt_app_preferences(sid)
response = @conn.get do |req|
req.url "#{@config[:qbit_addr]}/api/v2/app/preferences"
req.url '/api/v2/app/preferences'
req.headers['Cookie'] = sid
end

Expand All @@ -35,9 +35,9 @@ def qbt_app_preferences(sid)

def qbt_app_set_preferences(forwarded_port, sid)
@conn.post do |req|
req.url "#{@config[:qbit_addr]}/api/v2/app/setPreferences"
req.headers = { 'Cookie' => sid }
req.headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
req.url '/api/v2/app/setPreferences'
req.headers['Cookie'] = sid
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = URI.encode_www_form({ 'json': "{\"listen_port\": #{forwarded_port.to_i}}" })
end
end
Expand Down
2 changes: 1 addition & 1 deletion version.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
version: 0.9.2
version: 0.9.3

0 comments on commit e83237d

Please sign in to comment.