mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
Merge pull request #388 from opnsense/tor
security/tor: fix control socket issue
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
</socks_listen_port>
|
||||
<control_port type="IntegerField">
|
||||
<default>9051</default>
|
||||
<MinimumValue>0</MinimumValue>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<Required>N</Required>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>A valid Port number must be specified.</ValidationMessage>
|
||||
|
||||
@@ -36,11 +36,23 @@ $TOR_DEBUG = false
|
||||
|
||||
config = REXML::Document.new(File.new("/conf/config.xml"))
|
||||
$TOR_PASSWORD = config.elements['opnsense/OPNsense/tor/general/control_port_password'].text
|
||||
$TOR_CONTROL_PORT = 9051
|
||||
if port = config.elements['opnsense/OPNsense/tor/general/control_port']&.text&.to_i
|
||||
if port > 0
|
||||
$TOR_CONTROL_PORT = port
|
||||
else
|
||||
puts '{"error":"invalid control port found"}'
|
||||
exit
|
||||
end
|
||||
else
|
||||
puts '{"error":"no control port found"}'
|
||||
exit
|
||||
end
|
||||
|
||||
class TorCTL
|
||||
|
||||
def initialize
|
||||
@tor = TCPSocket.new("127.0.0.1", 9051)
|
||||
@tor = TCPSocket.new("127.0.0.1", $TOR_CONTROL_PORT)
|
||||
send_query("AUTHENTICATE \"#{$TOR_PASSWORD}\"")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user