@@ -19,6 +19,7 @@ import (
1919 "bufio"
2020 "bytes"
2121 "crypto/tls"
22+ "fmt"
2223 "io"
2324 "net"
2425 "runtime/debug"
@@ -48,6 +49,7 @@ type Acceptor struct {
4849 sessionHostPort map [SessionID ]int
4950 listeners map [string ]net.Listener
5051 connectionValidator ConnectionValidator
52+ tlsConfig * tls.Config
5153 sessionFactory
5254}
5355
@@ -81,9 +83,12 @@ func (a *Acceptor) Start() (err error) {
8183 a .listeners [address ] = nil
8284 }
8385
84- var tlsConfig * tls.Config
85- if tlsConfig , err = loadTLSConfig (a .settings .GlobalSettings ()); err != nil {
86- return
86+ if a .tlsConfig == nil {
87+ var tlsConfig * tls.Config
88+ if tlsConfig , err = loadTLSConfig (a .settings .GlobalSettings ()); err != nil {
89+ return
90+ }
91+ a .tlsConfig = tlsConfig
8792 }
8893
8994 var useTCPProxy bool
@@ -94,8 +99,8 @@ func (a *Acceptor) Start() (err error) {
9499 }
95100
96101 for address := range a .listeners {
97- if tlsConfig != nil {
98- if a .listeners [address ], err = tls .Listen ("tcp" , address , tlsConfig ); err != nil {
102+ if a . tlsConfig != nil {
103+ if a .listeners [address ], err = tls .Listen ("tcp" , address , a . tlsConfig ); err != nil {
99104 return
100105 }
101106 } else if a .listeners [address ], err = net .Listen ("tcp" , address ); err != nil {
@@ -228,6 +233,7 @@ func (a *Acceptor) invalidMessage(msg *bytes.Buffer, err error) {
228233func (a * Acceptor ) handleConnection (netConn net.Conn ) {
229234 defer func () {
230235 if err := recover (); err != nil {
236+ fmt .Println ("asdqwe" , a .globalLog )
231237 a .globalLog .OnEventf ("Connection Terminated with Panic: %s" , debug .Stack ())
232238 }
233239
@@ -421,3 +427,12 @@ LOOP:
421427func (a * Acceptor ) SetConnectionValidator (validator ConnectionValidator ) {
422428 a .connectionValidator = validator
423429}
430+
431+ // SetTLSConfig allows the creator of the Acceptor to specify a fully customizable tls.Config.
432+
433+ // When the caller explicitly provides a tls.Config with this function,
434+ // it takes precendent over TLS settings specified in the acceptor's settings.GlobalSettings(),
435+ // meaning that the setting object is not inspected or used for the creation of the tls.Config.
436+ func (a * Acceptor ) SetTLSConfig (tlsConfig * tls.Config ) {
437+ a .tlsConfig = tlsConfig
438+ }
0 commit comments