func Server(cn net.Conn, p ServerParam) *ServerConn {
	conf := new(tls.Config)
	if p.TLSConfig != nil {
		*conf = *p.TLSConfig
	}
	sc := new(ServerConn)
	conf.GetCertificate = func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {
		sc.ServerName = hello.ServerName
		return getCert(p.CA, hello.ServerName)
	}
	sc.Conn = tls.Server(cn, conf)
	return sc
}
Server wraps cn with a ServerConn configured with p so that during its
Handshake, it will generate a new certificate using p.CA. After a successful
Handshake, its ServerName field will be set to the clients requested
ServerName in the SNI header.
package mitm
import (
	"crypto/tls"
	"errors"
	"io"
	"log"
	"net"
	"net/http"
	"time"
)
type ServerParam struct {
	CA        *tls.Certificate  
	TLSConfig *tls.Config       
}
type ServerConn struct {
	*tls.Conn
	ServerName string
}