mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
allow tls connection in http proxy
This commit is contained in:
parent
b65017d28d
commit
f2c656843e
@ -16,6 +16,25 @@ type TlsConfig struct {
|
|||||||
Certs []*CertificateConfig
|
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 {
|
type Config struct {
|
||||||
OwnHosts []v2net.Address
|
OwnHosts []v2net.Address
|
||||||
TlsConfig *TlsConfig
|
TlsConfig *TlsConfig
|
||||||
|
@ -2,6 +2,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"crypto/tls"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -60,7 +61,11 @@ func (this *HttpProxyServer) Listen(port v2net.Port) error {
|
|||||||
}
|
}
|
||||||
this.listeningPort = port
|
this.listeningPort = port
|
||||||
|
|
||||||
tcpListener, err := hub.ListenTCP(port, this.handleConnection, nil)
|
var tlsConfig *tls.Config = nil
|
||||||
|
if this.config.TlsConfig != nil {
|
||||||
|
tlsConfig = this.config.TlsConfig.GetConfig()
|
||||||
|
}
|
||||||
|
tcpListener, err := hub.ListenTCP(port, this.handleConnection, tlsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Http: Failed listen on port ", port, ": ", err)
|
log.Error("Http: Failed listen on port ", port, ": ", err)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user