From cc85a00bfd6a118e3dc7e7c66b0b9f18895f22b2 Mon Sep 17 00:00:00 2001
From: aum <aum>
Date: Fri, 30 Jul 2004 17:43:39 +0000
Subject: [PATCH] Added 'dontResolve' keyword to Socket.connect, which if set
 to True, will prevent the hostname lookup. This gives the caller the option
 of passing in a physical destination base64, instead of being limited to
 known hosts.

---
 apps/sam/python/src/i2p/sam.py | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/apps/sam/python/src/i2p/sam.py b/apps/sam/python/src/i2p/sam.py
index f9e8fb15b9..041dbaf8b6 100644
--- a/apps/sam/python/src/i2p/sam.py
+++ b/apps/sam/python/src/i2p/sam.py
@@ -238,7 +238,21 @@ class Socket:
       pass
     self.closed = True
 
-  def connect(self, address):
+  def connect(self, address, **kw):
+    """
+    Attempts to connect to a remote dest, identified in local
+    SAM bridge's hosts file as host 'address'.
+
+    For example:
+      s.connect("duck.i2p")
+
+    You can pass a keyword 'dontResolve', which if true,
+    allows you to pass the base64 destination as the address, and
+    override the hostname lookup.
+
+    For example:
+      s.connect("238797sdfh2k34kjh....AAAA")
+    """
     # Synchronized.  Lock prevents two connects from occurring at the
     # same time in different threads.
     self.lock.acquire()
@@ -249,7 +263,11 @@ class Socket:
         return
 
       self._verify_not_connected()
-      address = resolve(address, self.samaddr)
+
+      # patched by aum - allow caller to pass in raw base64 dest,
+      # and prevent the name lookup attempt
+      if not kw.get('dontResolve', 1):
+        address = resolve(address, self.samaddr)
 
       timeout = self.timeout
       unwrap = self.sessobj.connect(address, timeout=timeout)
-- 
GitLab