mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-24 23:19:44 +00:00
own hosts in http config
This commit is contained in:
1 parent
befd24c83e
commit
6b894c719d
3 files changed
+73
-1
No files matched your search
@@ -3,12 +3,38 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
"github.com/v2ray/v2ray-core/proxy/internal/config"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Hosts []v2net.AddressJson `json:"ownHosts"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
this.OwnHosts = make([]v2net.Address, len(jsonConfig.Hosts), len(jsonConfig.Hosts)+1)
|
||||
for idx, host := range jsonConfig.Hosts {
|
||||
this.OwnHosts[idx] = host.Address
|
||||
}
|
||||
|
||||
v2rayHost := v2net.DomainAddress("local.v2ray.com")
|
||||
if !this.IsOwnHost(v2rayHost) {
|
||||
this.OwnHosts = append(this.OwnHosts, v2rayHost)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
config.RegisterInboundConfig("http",
|
||||
func(data []byte) (interface{}, error) {
|
||||
return new(Config), nil
|
||||
rawConfig := new(Config)
|
||||
err := json.Unmarshal(data, rawConfig)
|
||||
return rawConfig, err
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user