Code optimization

This commit is contained in:
刘河
2019-03-23 22:19:59 +08:00
parent efa341c7e8
commit b189fb1b6e
260 changed files with 50746 additions and 851 deletions

View File

@@ -2,15 +2,20 @@ package crypt
import (
"crypto/tls"
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
"github.com/cnlh/nps/vender/github.com/astaxie/beego/logs"
"net"
"os"
"path/filepath"
)
var pemPath, keyPath string
func InitTls(pem, key string) {
pemPath = pem
keyPath = key
}
func NewTlsServerConn(conn net.Conn) net.Conn {
cert, err := tls.LoadX509KeyPair(filepath.Join(beego.AppPath, "conf", "server.pem"), filepath.Join(beego.AppPath, "conf", "server.key"))
cert, err := tls.LoadX509KeyPair(pemPath, keyPath)
if err != nil {
logs.Error(err)
os.Exit(0)