summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2015-06-22 21:40:38 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2015-06-22 21:40:38 +0100
commit68f583ddb7a3e1a9fe8d004fef199d3e1c0bb342 (patch)
treef9ae2efa67e3077764d71636bb0837de82f6618a /lib
parent8853dfb3539048b3d3d905b1a41a45860bf2d327 (diff)
downloadNim-68f583ddb7a3e1a9fe8d004fef199d3e1c0bb342.tar.gz
Adjustments to #2610.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/asyncnet.nim11
-rw-r--r--lib/pure/net.nim9
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim
index 4b221eb72..712bba33b 100644
--- a/lib/pure/asyncnet.nim
+++ b/lib/pure/asyncnet.nim
@@ -472,7 +472,16 @@ when defined(ssl):
     socket.bioOut = bioNew(bio_s_mem())
     sslSetBio(socket.sslHandle, socket.bioIn, socket.bioOut)
 
-  proc wrapSocket*(ctx: SslContext, socket: AsyncSocket, handshake: SslHandshakeType) =
+  proc wrapConnectedSocket*(ctx: SslContext, socket: AsyncSocket,
+                            handshake: SslHandshakeType) =
+    ## Wraps a connected socket in an SSL context. This function effectively
+    ## turns ``socket`` into an SSL socket.
+    ##
+    ## This should be called on a connected socket, and will perform
+    ## an SSL handshake immediately.
+    ##
+    ## **Disclaimer**: This code is not well tested, may be very unsafe and
+    ## prone to security vulnerabilities.
     wrapSocket(ctx, socket)
 
     case handshake
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
index 7dcc35495..29e115da1 100644
--- a/lib/pure/net.nim
+++ b/lib/pure/net.nim
@@ -102,7 +102,7 @@ type
 proc isIpAddress*(address_str: string): bool {.tags: [].}
 proc parseIpAddress*(address_str: string): IpAddress
 proc socketError*(socket: Socket, err: int = -1, async = false,
-lastError = (-1).OSErrorCode): void
+                  lastError = (-1).OSErrorCode): void
 
 proc isDisconnectionError*(flags: set[SocketFlag],
     lastError: OSErrorCode): bool =
@@ -259,9 +259,10 @@ when defined(ssl):
     if SSLSetFd(socket.sslHandle, socket.fd) != 1:
       raiseSSLError()
 
-  proc wrapSocket*(ctx: SSLContext, socket: Socket, handshake: SslHandshakeType) =
-    ## Wraps a socket in an SSL context. This function effectively turns
-    ## ``socket`` into an SSL socket.
+  proc wrapConnectedSocket*(ctx: SSLContext, socket: Socket,
+                            handshake: SslHandshakeType) =
+    ## Wraps a connected socket in an SSL context. This function effectively
+    ## turns ``socket`` into an SSL socket.
     ##
     ## This should be called on a connected socket, and will perform
     ## an SSL handshake immediately.