mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Added (untested) proxying; load default settings sensibly.
This commit is contained in:
parent
4643ced19f
commit
2f3741f7a3
@ -267,7 +267,7 @@ class SimpleSantiago(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
request = DefaultDict(lambda: None)
|
request = DefaultDict(lambda: None)
|
||||||
for k,v in kwargs.iteritems():
|
for k, v in kwargs.iteritems():
|
||||||
request[k] = v
|
request[k] = v
|
||||||
return request
|
return request
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ class SimpleSantiago(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not self.am_i(host):
|
if not self.am_i(host):
|
||||||
self.proxy()
|
self.proxy(to, host, client, service, reply_to)
|
||||||
else:
|
else:
|
||||||
self.learn_service(client, "santiago", reply_to)
|
self.learn_service(client, "santiago", reply_to)
|
||||||
|
|
||||||
@ -303,13 +303,17 @@ class SimpleSantiago(object):
|
|||||||
service, self.get_host_locations(client, service),
|
service, self.get_host_locations(client, service),
|
||||||
self.get_host_locations(client, "santiago"))
|
self.get_host_locations(client, "santiago"))
|
||||||
|
|
||||||
def proxy(self):
|
def proxy(self, to, host, client, service, reply_to):
|
||||||
"""Pass off a request to another Santiago.
|
"""Pass off a request to another Santiago.
|
||||||
|
|
||||||
TODO: complete.
|
Attempt to contact the other Santiago and ask it to reply both to the
|
||||||
|
original host as well as me.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
pass
|
self.request(self.me, to, host, client,
|
||||||
|
service, reply_to)
|
||||||
|
self.request(self.me, to, host, client,
|
||||||
|
service, self.get_client_locations(host, "santiago"))
|
||||||
|
|
||||||
def handle_reply(self, from_, to, host, client,
|
def handle_reply(self, from_, to, host, client,
|
||||||
service, locations, reply_to):
|
service, locations, reply_to):
|
||||||
@ -358,29 +362,45 @@ class SimpleSantiago(object):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# FIXME: convert this to the withsqlite setup.
|
# FIXME: convert this to the withsqlite setup.
|
||||||
for datum in ("listeners", "senders", "hosting", "consuming"):
|
|
||||||
locals()[datum] = load_data("b", datum)
|
|
||||||
|
|
||||||
# Dummy Settings:
|
# load listeners
|
||||||
#
|
try:
|
||||||
# https_port = 8090
|
listeners = load_data("b", "listeners")
|
||||||
# cert = "/tmp/santiagoTest/santiagoTest1.crt"
|
except IOError:
|
||||||
# listeners = { "https": { "socket_port": https_port,
|
https_port = 8090
|
||||||
# "ssl_certificate": cert,
|
cert = "/tmp/santiagoTest/santiagoTest1.crt"
|
||||||
# "ssl_private_key": cert }, }
|
listeners = { "https": { "socket_port": https_port,
|
||||||
# senders = { "https": { "host": tor_proxy,
|
"ssl_certificate": cert,
|
||||||
# "port": tor_proxy_port} }
|
"ssl_private_key": cert }, }
|
||||||
# hosting = { "a": { "santiago": set( ["https://localhost:8090"] )},
|
# load senders
|
||||||
# "b": { "santiago": set( ["https://localhost:8090"] )}}
|
try:
|
||||||
# consuming = { "santiago": { "b": set( ["https://localhost:8090"] ),
|
senders = load_data("b", "senders")
|
||||||
# "a": set( ["someAddress.onion"] )}}
|
except IOError:
|
||||||
|
tor_proxy = "localhost"
|
||||||
|
tor_proxy_port = 8118
|
||||||
|
senders = { "https": { "host": tor_proxy,
|
||||||
|
"port": tor_proxy_port} }
|
||||||
|
# load hosting
|
||||||
|
try:
|
||||||
|
hosting = load_data("b", "hosting")
|
||||||
|
except IOError:
|
||||||
|
hosting = { "a": { "santiago": set( ["https://localhost:8090"] )},
|
||||||
|
"b": { "santiago": set( ["https://localhost:8090"] )}}
|
||||||
|
# load consuming
|
||||||
|
try:
|
||||||
|
consuming = load_data("b", "consuming")
|
||||||
|
except IOError:
|
||||||
|
consuming = { "santiago": { "b": set( ["https://localhost:8090"] ),
|
||||||
|
"a": set( ["someAddress.onion"] )}}
|
||||||
|
|
||||||
|
# load the Santiago
|
||||||
santiago_b = SimpleSantiago(listeners, senders,
|
santiago_b = SimpleSantiago(listeners, senders,
|
||||||
hosting, consuming, "b")
|
hosting, consuming, "b")
|
||||||
|
|
||||||
# TODO: integrate multiple servers:
|
# TODO: integrate multiple servers:
|
||||||
# http://docs.cherrypy.org/dev/refman/process/servers.html
|
# http://docs.cherrypy.org/dev/refman/process/servers.html
|
||||||
|
|
||||||
|
# Start the application.
|
||||||
# cherrypy.Application(
|
# cherrypy.Application(
|
||||||
cherrypy.quickstart(
|
cherrypy.quickstart(
|
||||||
santiago_b, '/')
|
santiago_b, '/')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user