Skip to content

Commit 0e867b1

Browse files
committed
adopt external-controller-cors and must set it in ConfigurationOverride not config.yaml
1 parent a41fa3f commit 0e867b1

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

core/src/main/golang/native/config/process.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func patchOverride(cfg *config.RawConfig, _ string) error {
4444
func patchExternalController(cfg *config.RawConfig, _ string) error {
4545
cfg.ExternalController = ""
4646
cfg.ExternalControllerTLS = ""
47+
cfg.ExternalControllerCors.AllowOrigins = []string{}
48+
cfg.ExternalControllerCors.AllowPrivateNetwork = false
4749

4850
return nil
4951
}

core/src/main/java/com/github/kr328/clash/core/model/ConfigurationOverride.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ data class ConfigurationOverride(
4747
@SerialName("external-controller-tls")
4848
var externalControllerTLS: String? = null,
4949

50+
@SerialName("external-controller-cors")
51+
var externalControllerCors: ExternalControllerCors = ExternalControllerCors(),
52+
5053
@SerialName("secret")
5154
var secret: String? = null,
5255

@@ -210,6 +213,15 @@ data class ConfigurationOverride(
210213
var geosite: String? = null,
211214
)
212215

216+
@Serializable
217+
data class ExternalControllerCors(
218+
@SerialName("allow-origins")
219+
var allowOrigins: List<String>? = null,
220+
221+
@SerialName("allow-private-network")
222+
var allowPrivateNetwork: Boolean? = null,
223+
)
224+
213225
override fun writeToParcel(parcel: Parcel, flags: Int) {
214226
Parcelizer.encodeToParcel(serializer(), parcel, this)
215227
}

design/src/main/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@ class OverrideSettingsDesign(
157157
empty = R.string.default_
158158
)
159159

160+
editableTextList(
161+
value = configuration.externalControllerCors::allowOrigins,
162+
adapter = TextAdapter.String,
163+
title = R.string.allow_origins,
164+
placeholder = R.string.dont_modify,
165+
)
166+
167+
selectableList(
168+
value = configuration.externalControllerCors::allowPrivateNetwork,
169+
values = booleanValues,
170+
valuesText = booleanValuesText,
171+
title = R.string.allow_private_network,
172+
)
173+
160174
editableText(
161175
value = configuration::secret,
162176
adapter = NullableTextAdapter.String,

design/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@
150150
<string name="ipv6">IPv6</string>
151151
<string name="external_controller">External Controller</string>
152152
<string name="external_controller_tls">External Controller TLS</string>
153+
<string name="allow_origins">External Controller Allow Origins</string>
154+
<string name="allow_private_network">External Controller Allow Private Network</string>
153155
<string name="secret">Secret</string>
154156
<string name="hosts">Hosts</string>
155157
<string name="_new">New</string>

0 commit comments

Comments
 (0)