Skip to content

Commit

Permalink
adopt external-controller-cors and must set it in ConfigurationOver…
Browse files Browse the repository at this point in the history
…ride not config.yaml
  • Loading branch information
wwqgtxx committed Sep 30, 2024
1 parent a41fa3f commit 0e867b1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/golang/native/config/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func patchOverride(cfg *config.RawConfig, _ string) error {
func patchExternalController(cfg *config.RawConfig, _ string) error {
cfg.ExternalController = ""
cfg.ExternalControllerTLS = ""
cfg.ExternalControllerCors.AllowOrigins = []string{}
cfg.ExternalControllerCors.AllowPrivateNetwork = false

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ data class ConfigurationOverride(
@SerialName("external-controller-tls")
var externalControllerTLS: String? = null,

@SerialName("external-controller-cors")
var externalControllerCors: ExternalControllerCors = ExternalControllerCors(),

@SerialName("secret")
var secret: String? = null,

Expand Down Expand Up @@ -210,6 +213,15 @@ data class ConfigurationOverride(
var geosite: String? = null,
)

@Serializable
data class ExternalControllerCors(
@SerialName("allow-origins")
var allowOrigins: List<String>? = null,

@SerialName("allow-private-network")
var allowPrivateNetwork: Boolean? = null,
)

override fun writeToParcel(parcel: Parcel, flags: Int) {
Parcelizer.encodeToParcel(serializer(), parcel, this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ class OverrideSettingsDesign(
empty = R.string.default_
)

editableTextList(
value = configuration.externalControllerCors::allowOrigins,
adapter = TextAdapter.String,
title = R.string.allow_origins,
placeholder = R.string.dont_modify,
)

selectableList(
value = configuration.externalControllerCors::allowPrivateNetwork,
values = booleanValues,
valuesText = booleanValuesText,
title = R.string.allow_private_network,
)

editableText(
value = configuration::secret,
adapter = NullableTextAdapter.String,
Expand Down
2 changes: 2 additions & 0 deletions design/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
<string name="ipv6">IPv6</string>
<string name="external_controller">External Controller</string>
<string name="external_controller_tls">External Controller TLS</string>
<string name="allow_origins">External Controller Allow Origins</string>
<string name="allow_private_network">External Controller Allow Private Network</string>
<string name="secret">Secret</string>
<string name="hosts">Hosts</string>
<string name="_new">New</string>
Expand Down

0 comments on commit 0e867b1

Please sign in to comment.