mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-06 03:54:22 -04:00
19 lines
410 B
Go
19 lines
410 B
Go
|
package ws
|
||
|
|
||
|
import "crypto/tls"
|
||
|
|
||
|
func getstopableTLSlistener(cert, key, listenaddr string) (*StoppableListener, error) {
|
||
|
cer, err := tls.LoadX509KeyPair(cert, key)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
config := &tls.Config{Certificates: []tls.Certificate{cer}}
|
||
|
ln, err := tls.Listen("tcp", listenaddr, config)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
lns, err := NewStoppableListener(ln)
|
||
|
return lns, err
|
||
|
}
|