The Trunk: Network-pre.192.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Network-pre.192.mcz

commits-2
Patrick Rein uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-pre.192.mcz

==================== Summary ====================

Name: Network-pre.192
Author: pre
Time: 4 May 2017, 6:00:28.490322 pm
UUID: b6465341-6977-454c-b78f-dcef0d8e9bf5
Ancestors: Network-pre.191

Adds basic starttls capabilities to the SMTP client. Required an extension of ProtocolClient to also store the hostName.

=============== Diff against Network-pre.191 ===============

Item was changed:
  ----- Method: ProtocolClient class>>openOnHostNamed:port: (in category 'instance creation') -----
  openOnHostNamed: hostName port: portNumber
  | serverIP |
  serverIP := NetNameResolver addressForName: hostName timeout: 20.
+ ^ (self openOnHost: serverIP port: portNumber)
+ hostName: hostName;
+ yourself
- ^self openOnHost: serverIP port: portNumber
  !

Item was added:
+ ----- Method: ProtocolClient>>hostName (in category 'private') -----
+ hostName
+
+ ^ self connectionInfo at: #hostName ifAbsent: [NetNameResolver nameForAddress: self host]!

Item was added:
+ ----- Method: ProtocolClient>>hostName: (in category 'private') -----
+ hostName: aString
+
+ ^ self connectionInfo at: #hostName put: aString!

Item was changed:
  ----- Method: SMTPClient>>data: (in category 'private protocol') -----
  data: messageData
  "send the data of a message"
  "DATA <CRLF>"
 
-
-
  "inform the server we are sending the message data"
  self sendCommand: 'DATA'.
  self checkResponse.
 
  "process the data one line at a time"
  messageData linesDo:  [ :messageLine | | cookedLine |
  cookedLine := messageLine.
  (cookedLine beginsWith: '.') ifTrue: [
  "lines beginning with a dot must have the dot doubled"
  cookedLine := '.', cookedLine ].
  self sendCommand: cookedLine ].
 
  "inform the server the entire message text has arrived"
  self sendCommand: '.'.
  self checkResponse.!

Item was added:
+ ----- Method: SMTPClient>>starttls (in category 'private protocol') -----
+ starttls
+ "Send HELO first"
+ Smalltalk at: #SqueakSSL ifAbsent:[self error: 'SqueakSSL is missing'].
+
+ self initiateSession.
+ self sendCommand: 'STARTTLS'.
+ self checkResponse.
+ self determineResponseCode = 220 ifTrue: [
+ stream := SqueakSSL secureSocketStream on: stream socket.
+ stream sslConnectTo: self hostName].!