mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
831 B
51 lines
831 B
package http
|
|
|
|
import (
|
|
"crypto/tls"
|
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
)
|
|
|
|
type CertificateConfig struct {
|
|
Domain string
|
|
Certificate tls.Certificate
|
|
}
|
|
|
|
type TlsConfig struct {
|
|
Enabled bool
|
|
Certs []*CertificateConfig
|
|
}
|
|
|
|
func (this *TlsConfig) GetConfig() *tls.Config {
|
|
if !this.Enabled {
|
|
return nil
|
|
}
|
|
|
|
config := &tls.Config{
|
|
InsecureSkipVerify: false,
|
|
}
|
|
|
|
config.Certificates = make([]tls.Certificate, len(this.Certs))
|
|
for index, cert := range this.Certs {
|
|
config.Certificates[index] = cert.Certificate
|
|
}
|
|
|
|
config.BuildNameToCertificate()
|
|
|
|
return config
|
|
}
|
|
|
|
type Config struct {
|
|
OwnHosts []v2net.Address
|
|
TlsConfig *TlsConfig
|
|
}
|
|
|
|
func (this *Config) IsOwnHost(host v2net.Address) bool {
|
|
for _, ownHost := range this.OwnHosts {
|
|
if ownHost.Equals(host) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|