Skip to content

Commit

Permalink
removed delegated completely
Browse files Browse the repository at this point in the history
  • Loading branch information
mattes committed Apr 16, 2014
1 parent 8e93fa6 commit 806985c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 37 deletions.
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ RUN apt-get install tor -y
RUN service tor stop
RUN update-rc.d -f tor remove

# DeleGate
# RUN wget -P /tmp http://www.delegate.org/anonftp/DeleGate/bin/linux/9.9.7/fc6_64-dg.gz
# RUN gunzip /tmp/fc6_64-dg.gz
# RUN mv /tmp/fc6_64-dg /usr/local/bin/delegated
# RUN chmod +x /usr/local/bin/delegated

# Polipo
RUN apt-get install polipo -y
RUN update-rc.d -f polipo remove
Expand Down
45 changes: 14 additions & 31 deletions usr/local/bin/start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,33 @@ def self.which(executable)


class Tor < Base
attr_reader :port, :delegated_port
attr_reader :port, :polipo_port

def initialize(port)
@exec = self.class.which('tor')
@delegated_exec = self.class.which('delegated')
@polipo_exec = self.class.which('polipo')
@port = port
@tor_port = @port
@delegated_port = @port + 10000
@polipo_port = @port + 10000
end

def start
Dir.mkdir("/var/lib/tor") unless Dir.exists?("/var/lib/tor")
Dir.mkdir("/var/run/tor") unless Dir.exists?("/var/run/tor")
Dir.mkdir("/var/log/tor") unless Dir.exists?("/var/log/tor")
self.class.fire_and_forget(@exec,
"--SocksPort #{@tor_port}",
"--NewCircuitPeriod 120",
"--DataDirectory /var/lib/tor/#{@tor_port}",
"--PidFile /var/run/tor/#{@tor_port}.pid",
"--Log \"warn syslog\"",
'--RunAsDaemon 1',
"| logger 2>&1")
"| logger -t 'tor' 2>&1")


# polipo proxyPort=9080 socksParentProxy=127.0.0.1:9050 socksProxyType=socks5 diskCacheRoot="" disableLocalInterface=true allowedClients=127.0.0.1 localDocumentRoot="" disableConfiguration=true dnsUseGethostbyname="yes" disableVia = true

Dir.mkdir("/var/lib/delegated") unless Dir.exists?("/var/lib/delegated")
Dir.mkdir("/var/run/delegated") unless Dir.exists?("/var/run/delegated")
Dir.mkdir("/var/log/delegated") unless Dir.exists?("/var/log/delegated")
# self.class.fire_and_forget(@delegated_exec,
# "-P#{@delegated_port}",
# "SERVER=http",
# "DGROOT=/var/lib/delegated/#{@delegated_port}",
# "SOCKS=127.0.0.1:#{@tor_port}",
# "PIDFILE=/var/run/delegated/#{@delegated_port}.pid",
# "LOGFILE=/var/log/delegated/#{@delegated_port}.log",
# "[email protected]",
# "DYLIB='+,lib*.so.X.Y.Z'",
# "HTTPCONF=kill-qhead:Via",
# "OWNER=root/root",
# "| logger 2>&1")

# https://gitweb.torproject.org/torbrowser.git/blob_plain/1ffcd9dafb9dd76c3a29dd686e05a71a95599fb5:/build-scripts/config/polipo.conf
Dir.mkdir("/var/run/polipo") unless Dir.exists?("/var/run/polipo")
self.class.fire_and_forget(@polipo_exec,
"proxyPort=#{@delegated_port}",
"proxyPort=#{@polipo_port}",
"socksParentProxy=127.0.0.1:#{@tor_port}",
"socksProxyType=socks5",
"diskCacheRoot=''",
Expand All @@ -87,9 +69,9 @@ def start
"dnsUseGethostbyname='yes'",
"logSyslog=true",
"daemonise=true",
"pidFile=/var/run/delegated/#{@delegated_port}.pid",
"pidFile=/var/run/polipo/#{@polipo_port}.pid",
"disableVia=true",
"| logger 2>&1")
"| logger -t 'polipo' 2>&1")
end

def stop
Expand All @@ -98,9 +80,9 @@ def stop
self.class.kill(tor_pid)
end

if File.exists?("/var/run/delegated/#{@delegated_port}.pid")
delegated_pid = IO.read("/var/run/delegated/#{@delegated_port}.pid").strip()
self.class.kill(delegated_pid)
if File.exists?("/var/run/polipo/#{@polipo_port}.pid")
polipo_pid = IO.read("/var/run/polipo/#{@polipo_port}.pid").strip()
self.class.kill(polipo_pid)
end
end

Expand Down Expand Up @@ -128,7 +110,8 @@ def soft_reload
self.class.fire_and_forget(@exec,
"-f #{@config_path}",
"-p #{@pidfile_path}",
"-sf #{IO.read(@pidfile_path)}")
"-sf #{IO.read(@pidfile_path)}",
"| logger 2>&1")
end

def kill
Expand All @@ -155,7 +138,7 @@ def compile_config
tor_instances = ENV['tors'] || 10
tor_instances.to_i.times.each do
t = Service::Tor.new(port)
h.add_tor('127.0.0.1', t.delegated_port)
h.add_tor('127.0.0.1', t.polipo_port)
t.start
port += 1
end
Expand Down

0 comments on commit 806985c

Please sign in to comment.