mirror of
https://github.com/opnsense/plugins.git
synced 2026-04-20 21:58:57 -04:00
Merge pull request #388 from opnsense/tor
security/tor: fix control socket issue
This commit is contained in:
commit
79cd319ed4
2 changed files with 14 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue