Selaa lähdekoodia

tls settings for http proxy

v2ray 9 vuotta sitten
vanhempi
commit
c044234e4a
2 muutettua tiedostoa jossa 28 lisäystä ja 1 poistoa
  1. 8 1
      proxy/http/config.go
  2. 20 0
      proxy/http/config_json.go

+ 8 - 1
proxy/http/config.go

@@ -4,8 +4,15 @@ import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
 )
 
+type TlsConfig struct {
+	Enabled  bool
+	CertFile string
+	KeyFile  string
+}
+
 type Config struct {
-	OwnHosts []v2net.Address
+	OwnHosts  []v2net.Address
+	TlsConfig *TlsConfig
 }
 
 func (this *Config) IsOwnHost(host v2net.Address) bool {

+ 20 - 0
proxy/http/config_json.go

@@ -9,9 +9,27 @@ import (
 	"github.com/v2ray/v2ray-core/proxy/internal/config"
 )
 
+func (this *TlsConfig) UnmarshalJSON(data []byte) error {
+	type JsonConfig struct {
+		Enabled  bool
+		CertFile string
+		KeyFile  string
+	}
+	jsonConfig := new(JsonConfig)
+	if err := json.Unmarshal(data, jsonConfig); err != nil {
+		return err
+	}
+
+	this.Enabled = jsonConfig.Enabled
+	this.CertFile = jsonConfig.CertFile
+	this.KeyFile = jsonConfig.KeyFile
+	return nil
+}
+
 func (this *Config) UnmarshalJSON(data []byte) error {
 	type JsonConfig struct {
 		Hosts []v2net.AddressJson `json:"ownHosts"`
+		Tls   *TlsConfig          `json:"tls"`
 	}
 	jsonConfig := new(JsonConfig)
 	if err := json.Unmarshal(data, jsonConfig); err != nil {
@@ -27,6 +45,8 @@ func (this *Config) UnmarshalJSON(data []byte) error {
 		this.OwnHosts = append(this.OwnHosts, v2rayHost)
 	}
 
+	this.TlsConfig = jsonConfig.Tls
+
 	return nil
 }