mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-03 20:27:31 +00:00
feat: add external-controller-cors can config allow-origins and allow-private-network
This commit is contained in:
@@ -107,6 +107,12 @@ type Controller struct {
|
||||
ExternalUI string
|
||||
ExternalDohServer string
|
||||
Secret string
|
||||
Cors Cors
|
||||
}
|
||||
|
||||
type Cors struct {
|
||||
AllowOrigins []string
|
||||
AllowPrivateNetwork bool
|
||||
}
|
||||
|
||||
// Experimental config
|
||||
@@ -191,6 +197,11 @@ type Config struct {
|
||||
TLS *TLS
|
||||
}
|
||||
|
||||
type RawCors struct {
|
||||
AllowOrigins []string `yaml:"allow-origins" json:"allow-origins"`
|
||||
AllowPrivateNetwork bool `yaml:"allow-private-network" json:"allow-private-network"`
|
||||
}
|
||||
|
||||
type RawDNS struct {
|
||||
Enable bool `yaml:"enable" json:"enable"`
|
||||
PreferH3 bool `yaml:"prefer-h3" json:"prefer-h3"`
|
||||
@@ -368,6 +379,7 @@ type RawConfig struct {
|
||||
ExternalControllerPipe string `yaml:"external-controller-pipe" json:"external-controller-pipe"`
|
||||
ExternalControllerUnix string `yaml:"external-controller-unix" json:"external-controller-unix"`
|
||||
ExternalControllerTLS string `yaml:"external-controller-tls" json:"external-controller-tls"`
|
||||
ExternalControllerCors RawCors `yaml:"external-controller-cors" json:"external-controller-cors"`
|
||||
ExternalUI string `yaml:"external-ui" json:"external-ui"`
|
||||
ExternalUIURL string `yaml:"external-ui-url" json:"external-ui-url"`
|
||||
ExternalUIName string `yaml:"external-ui-name" json:"external-ui-name"`
|
||||
@@ -541,6 +553,10 @@ func DefaultRawConfig() *RawConfig {
|
||||
OverrideDest: true,
|
||||
},
|
||||
ExternalUIURL: "https://github.com/MetaCubeX/metacubexd/archive/refs/heads/gh-pages.zip",
|
||||
ExternalControllerCors: RawCors{
|
||||
AllowOrigins: []string{"*"},
|
||||
AllowPrivateNetwork: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,6 +791,10 @@ func parseController(cfg *RawConfig) (*Controller, error) {
|
||||
ExternalControllerUnix: cfg.ExternalControllerUnix,
|
||||
ExternalControllerTLS: cfg.ExternalControllerTLS,
|
||||
ExternalDohServer: cfg.ExternalDohServer,
|
||||
Cors: Cors{
|
||||
AllowOrigins: cfg.ExternalControllerCors.AllowOrigins,
|
||||
AllowPrivateNetwork: cfg.ExternalControllerCors.AllowPrivateNetwork,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user