cleaned up deprecations and warnings
This commit is contained in:
		
							parent
							
								
									006a4f9d6d
								
							
						
					
					
						commit
						e4e75cf975
					
				
					 7 changed files with 12 additions and 10 deletions
				
			
		|  | @ -4,7 +4,6 @@ package main | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"flag" | 	"flag" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"log" | 	"log" | ||||||
| 	"net/smtp" | 	"net/smtp" | ||||||
| 
 | 
 | ||||||
|  | @ -60,7 +59,7 @@ func main() { | ||||||
| 		log.Fatalf("DKIM configuration error: %v", err) | 		log.Fatalf("DKIM configuration error: %v", err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	privKey, err = ioutil.ReadFile(*privKeyFile) | 	privKey, err = io.ReadFile(*privKeyFile) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.Fatalf("Couldn't read private key: %v", err) | 		log.Fatalf("Couldn't read private key: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -20,7 +20,6 @@ func (env *Envelope) AddReceivedLine(peer Peer) { | ||||||
| 	tlsDetails := "" | 	tlsDetails := "" | ||||||
| 
 | 
 | ||||||
| 	tlsVersions := map[uint16]string{ | 	tlsVersions := map[uint16]string{ | ||||||
| 		tls.VersionSSL30: "SSL3.0", |  | ||||||
| 		tls.VersionTLS10: "TLS1.0", | 		tls.VersionTLS10: "TLS1.0", | ||||||
| 		tls.VersionTLS11: "TLS1.1", | 		tls.VersionTLS11: "TLS1.1", | ||||||
| 		tls.VersionTLS12: "TLS1.2", | 		tls.VersionTLS12: "TLS1.2", | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ import ( | ||||||
| 	"net/smtp" | 	"net/smtp" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/chrj/smtpd" | 	"git.jmbit.de/jmb/smtpd" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func ExampleServer() { | func ExampleServer() { | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								go.mod
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
										
									
									
									
								
							|  | @ -1,3 +1,3 @@ | ||||||
| module github.com/chrj/smtpd | module git.jmbit.de/jmb/smtpd | ||||||
| 
 | 
 | ||||||
| go 1.14 | go 1.24 | ||||||
|  |  | ||||||
|  | @ -7,7 +7,6 @@ import ( | ||||||
| 	"encoding/base64" | 	"encoding/base64" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" |  | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/textproto" | 	"net/textproto" | ||||||
| 	"strconv" | 	"strconv" | ||||||
|  | @ -288,6 +287,7 @@ func (session *session) handleRCPT(cmd command) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (session *session) handleSTARTTLS(cmd command) { | func (session *session) handleSTARTTLS(cmd command) { | ||||||
|  |   _ = cmd | ||||||
| 
 | 
 | ||||||
| 	if session.tls { | 	if session.tls { | ||||||
| 		session.reply(502, "Already running in TLS") | 		session.reply(502, "Already running in TLS") | ||||||
|  | @ -334,6 +334,7 @@ func (session *session) handleSTARTTLS(cmd command) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (session *session) handleDATA(cmd command) { | func (session *session) handleDATA(cmd command) { | ||||||
|  |   _ = cmd | ||||||
| 
 | 
 | ||||||
| 	if session.envelope == nil || len(session.envelope.Recipients) == 0 { | 	if session.envelope == nil || len(session.envelope.Recipients) == 0 { | ||||||
| 		session.reply(502, "Missing RCPT TO command.") | 		session.reply(502, "Missing RCPT TO command.") | ||||||
|  | @ -371,7 +372,7 @@ func (session *session) handleDATA(cmd command) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Discard the rest and report an error. | 	// Discard the rest and report an error. | ||||||
| 	_, err = io.Copy(ioutil.Discard, reader) | 	_, err = io.Copy(io.Discard, reader) | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		// Network error, ignore | 		// Network error, ignore | ||||||
|  | @ -390,17 +391,20 @@ func (session *session) handleDATA(cmd command) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (session *session) handleRSET(cmd command) { | func (session *session) handleRSET(cmd command) { | ||||||
|  |   _ = cmd | ||||||
| 	session.reset() | 	session.reset() | ||||||
| 	session.reply(250, "Go ahead") | 	session.reply(250, "Go ahead") | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (session *session) handleNOOP(cmd command) { | func (session *session) handleNOOP(cmd command) { | ||||||
|  |   _ = cmd | ||||||
| 	session.reply(250, "Go ahead") | 	session.reply(250, "Go ahead") | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (session *session) handleQUIT(cmd command) { | func (session *session) handleQUIT(cmd command) { | ||||||
|  |   _ = cmd | ||||||
| 	session.reply(221, "OK, bye") | 	session.reply(221, "OK, bye") | ||||||
| 	session.close() | 	session.close() | ||||||
| 	return | 	return | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								smtpd.go
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								smtpd.go
									
										
									
									
									
								
							|  | @ -190,7 +190,7 @@ func (srv *Server) Serve(l net.Listener) error { | ||||||
| 			default: | 			default: | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if ne, ok := e.(net.Error); ok && ne.Temporary() { | 			if ne, ok := e.(net.Error); ok && ne.Timeout() { | ||||||
| 				time.Sleep(time.Second) | 				time.Sleep(time.Second) | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ import ( | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/chrj/smtpd" | 	"git.jmbit.de/jmb/smtpd" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var localhostCert = []byte(`-----BEGIN CERTIFICATE----- | var localhostCert = []byte(`-----BEGIN CERTIFICATE----- | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue