Merge pull request #388 from opnsense/tor

security/tor: fix control socket issue
This commit is contained in:
Fabian Franz, BSc 2017-11-23 17:17:05 +01:00 committed by GitHub
commit 79cd319ed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -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>

View file

@ -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