Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Add configuration item for versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nonexistent committed Jun 30, 2018
1 parent 0168254 commit 0d17859
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 8 additions & 3 deletions oregano/configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from gnutls.crypto import X509Certificate, X509CRL, X509PrivateKey
from gnutls.connection import X509Credentials

# Default settings for what is undeclared.
default_settings = {
"address": "0.0.0.0",
Expand Down Expand Up @@ -47,6 +44,14 @@
# base64 encode of our ntor onion key, the private part
"ntor_onion_secret_key": "MAnGt1ArmYV1/W8AwfVlyxIQXV+NIMRttytfD2+J1F4=",

# the link protocol versions we are offering to the upstream server
# see https://gitweb.torproject.org/torspec.git/tree/tor-spec.txt#n571 for available values
"versions_offered_to_server": (3, 4, 5),

# the link protocol versions we are offering to our clients
# see https://gitweb.torproject.org/torspec.git/tree/tor-spec.txt#n571 for available values
"versions_offered_to_client": (3, 4, 5),

# the SNI to be sent to the upstream server
# for example
# "server_name_indicator": "example.org",
Expand Down
6 changes: 4 additions & 2 deletions oregano/onion.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ def cell_is_var_length(command):

class ORConnImpl:

our_versions = frozenset((3, 4, 5))
supported_versions = frozenset((3, 4, 5))

def __init__(self, conn):
def __init__(self, conn, our_versions):
self.conn = conn
self.buf = ''

self.circid_len = 0
self.version = 0

self.our_versions = self.supported_versions & our_versions

def read_from_conn(self):
data = self.conn.recv(4096)

Expand Down
4 changes: 2 additions & 2 deletions oregano/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def send_to_remote(self, data):
self.remote.sendall(data)

def or_handshake_with_client(self):
self.client_or_conn = ORConnImpl(self.session)
self.client_or_conn = ORConnImpl(self.session, frozenset(self.server.config.versions_offered_to_client))

self.client_or_conn.process_versions_cell(self.client_or_conn.get_one_cell())

Expand All @@ -227,7 +227,7 @@ def or_handshake_with_client(self):
self.client_or_conn.process_netinfo_cell(self.client_or_conn.get_one_cell())

def or_handshake_with_server(self):
self.server_or_conn = ORConnImpl(self.remote)
self.server_or_conn = ORConnImpl(self.remote, frozenset(self.server.config.versions_offered_to_server))

self.send_to_remote(self.server_or_conn.versions_cell())

Expand Down

0 comments on commit 0d17859

Please sign in to comment.