Skip to content

Commit 4451be6

Browse files
committed
build: 更新 rustls platform verifier
1 parent c036e41 commit 4451be6

7 files changed

Lines changed: 110 additions & 36 deletions

File tree

LLM.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# LLM.md - AI-Assisted Contribution Guidelines
2+
3+
This document outlines the requirements for contributions that involve AI assistance in this project.
4+
5+
## Assisted-by Tag Requirement
6+
7+
When AI tools are used during development, the source must be clearly documented so everyone can understand the extent of AI involvement in each submission. All code contributions involving AI assistance must include an `Assisted-by` tag using the following format:
8+
9+
```
10+
Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]
11+
```
12+
13+
### Format Specification
14+
15+
| Component | Description |
16+
|-----------|-------------|
17+
| `AGENT_NAME` | The name of the AI tool or framework used (e.g., Claude, OpenClaw, Copilot) |
18+
| `MODEL_VERSION` | The specific model version (e.g., claude-3-opus, gemini-2.5-pro, k2p5) |
19+
| `[TOOL1] [TOOL2]` | Optional: Additional specialized analysis tools used (e.g., coccinelle, sparse, smatch, clang-tidy) |
20+
21+
### Notes
22+
23+
- **Do not include** common everyday tools like git, gcc, make, or text editors
24+
- Only list specialized analysis or transformation tools that significantly contributed to the code
25+
- Multiple `Assisted-by` tags may be used if different AI tools were used for different parts of the contribution
26+
27+
### Examples
28+
29+
**Using Claude with coccinelle and sparse:**
30+
```
31+
Assisted-by: Claude:claude-3-opus coccinelle sparse
32+
```
33+
34+
**Using OpenClaw with no additional tools:**
35+
```
36+
Assisted-by: OpenClaw:k2p5
37+
```
38+
39+
**Using GitHub Copilot:**
40+
```
41+
Assisted-by: Copilot:gpt-4o
42+
```
43+
44+
**Multiple AI tools used:**
45+
```
46+
Assisted-by: Claude:claude-3-opus clang-tidy
47+
Assisted-by: OpenClaw:gemini-3.1-pro-preview
48+
```
49+
50+
## Where to Include
51+
52+
Add the `Assisted-by` tag(s) at the end of your commit message, after the sign-off line (if present):
53+
54+
```
55+
Fix memory leak in request handler
56+
57+
This patch fixes a use-after-free bug in the async request handler
58+
that could occur during rapid create/destroy cycles.
59+
60+
Signed-off-by: John Doe <john@example.com>
61+
Assisted-by: Claude:claude-3-opus coccinelle sparse
62+
```
63+
64+
## Why This Matters
65+
66+
1. **Transparency**: Maintainers and reviewers should know when AI has assisted in code creation
67+
2. **Attribution**: Proper credit for AI contributions helps track the evolution of development practices
68+
3. **Quality Assurance**: Understanding AI involvement helps set appropriate review standards
69+
4. **Audit Trail**: Creates a clear record for future reference and analysis
70+
71+
## Scope
72+
73+
This requirement applies to:
74+
- Code changes (any language)
75+
- Configuration files
76+
- Build scripts
77+
- Documentation (if substantially AI-generated)
78+
79+
This requirement does **not** apply to:
80+
- Minor typo fixes
81+
- Pure formatting changes
82+
- Changes made entirely without AI assistance

build.gradle.kts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,9 @@ plugins {
1111
val buildToolsVersion by extra("36.0.0")
1212
val ndkVersion by extra("29.0.14206865")
1313

14-
// https://github.com/rustls/rustls-platform-verifier/issues/67#issuecomment-2265598462
15-
fun RepositoryHandler.rustlsPlatformVerifier(): MavenArtifactRepository {
16-
val manifestPath = let {
17-
val dependencyJson = providers.exec {
18-
workingDir = File(project.rootDir, "./uniffi")
19-
commandLine("cargo", "metadata", "--format-version", "1", "--filter-platform", "aarch64-linux-android", "--manifest-path", "clash-android-ffi/Cargo.toml")
20-
}.standardOutput.asText
21-
22-
val jsonSlurper = groovy.json.JsonSlurper()
23-
val jsonData = jsonSlurper.parseText(dependencyJson.get()) as Map<*, *>
24-
val packages = jsonData["packages"] as List<*>
25-
val path = packages
26-
.first { element ->
27-
val pkg = element as Map<*, *>
28-
pkg["name"] == "rustls-platform-verifier-android"
29-
}.let { it as Map<*, *> }["manifest_path"] as String
30-
31-
File(path)
32-
}
33-
34-
return maven {
35-
url = uri(File(manifestPath.parentFile, "maven").path)
36-
metadataSources.artifact()
37-
}
38-
}
39-
4014
allprojects {
4115
repositories {
4216
google()
4317
mavenCentral()
44-
rustlsPlatformVerifier()
4518
}
4619
}

core/build.gradle.kts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
import groovy.json.JsonSlurper
2+
13
plugins {
24
alias(libs.plugins.android.library)
35
alias(libs.plugins.kotlin.android)
46
alias(libs.plugins.kotlin.compose)
57
alias(libs.plugins.cargo.ndk)
68
}
79

10+
fun findRustlsPlatformVerifierClasses(): File {
11+
val dependencyJson = providers.exec {
12+
workingDir = File(project.rootDir, "uniffi")
13+
commandLine("cargo", "metadata", "--format-version", "1")
14+
}.standardOutput.asText
15+
16+
val jsonSlurper = JsonSlurper()
17+
val jsonData = jsonSlurper.parseText(dependencyJson.get()) as Map<*, *>
18+
val packages = jsonData["packages"] as List<*>
19+
val path = packages
20+
.first { element ->
21+
val pkg = element as Map<*, *>
22+
pkg["name"] == "rustls-platform-verifier-android"
23+
}.let { it as Map<*, *> }["manifest_path"] as String
24+
25+
val manifestFile = File(path)
26+
return File(manifestFile.parentFile, "classes.jar")
27+
}
28+
829
android {
930
namespace = "rs.clash.android.ffi"
1031
compileSdk = 36
@@ -31,7 +52,7 @@ kotlin {
3152
}
3253

3354
dependencies {
34-
implementation(libs.rustls.platform.verifier)
55+
implementation(files(findRustlsPlatformVerifierClasses()))
3556
implementation(libs.androidx.core.ktx)
3657
implementation(libs.androidx.appcompat)
3758
implementation(libs.androidx.runtime)

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ compose-destinations-ksp = { group = "io.github.raamcosta.compose-destinations",
4848
ktlint-compose-rules = { group = "io.nlopez.compose.rules", name = "ktlint", version.ref = "ktlint-compose" }
4949
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "material3" }
5050

51-
rustls-platform-verifier = { group = "rustls", name = "rustls-platform-verifier", version = "latest.release" }
5251

5352
[plugins]
5453
android-application = { id = "com.android.application", version.ref = "agp" }

uniffi/clash-android-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ urlencoding = "2"
4444
rustls = { version = "0.23", default-features = false, features = ["std", "aws-lc-rs"] }
4545
reqwest = { version = "0.13", default-features = false, features = ["rustls", "stream"] }
4646
tokio-stream = "0.1"
47-
rustls-platform-verifier = "0.7" # sync with gradle/libs.versions.toml
47+
rustls-platform-verifier = "0.7"
4848
tempfile = "3"
4949

5050
[target.'cfg(unix)'.dependencies]

uniffi/clash-android-ffi/src/controller.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl ClashController {
266266
let response = client.request(request).await.wrap_err("HTTP request failed")?;
267267

268268
if !response.status().is_success() {
269-
return Err(eyre::eyre!("HTTP status error: {}", response.status()).into());
269+
return Err(eyre::eyre!("HTTP status error: {}", response.status()));
270270
}
271271

272272
Ok(())
@@ -297,7 +297,7 @@ impl ClashController {
297297
let response = client.request(request).await.wrap_err("HTTP request failed")?;
298298

299299
if !response.status().is_success() {
300-
return Err(eyre::eyre!("HTTP status error: {}", response.status()).into());
300+
return Err(eyre::eyre!("HTTP status error: {}", response.status()));
301301
}
302302

303303
let body_bytes = response
@@ -309,7 +309,6 @@ impl ClashController {
309309

310310
serde_json::from_slice(&body_bytes)
311311
.wrap_err_with(|| format!("Failed to parse JSON response: {}", String::from_utf8_lossy(&body_bytes)))
312-
.map_err(Into::into)
313312
}
314313
}
315314

uniffi/clash-android-ffi/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct EyreError;
3434

3535
#[uniffi::export]
3636
pub fn format_eyre_error(err: &EyreError) -> String {
37-
format!("{}", err.to_string())
37+
err.to_string()
3838
}
3939

4040
#[derive(uniffi::Record)]
@@ -146,7 +146,7 @@ async fn run_clash(config_path: String, work_dir: String, over: ProfileOverride)
146146
device_id: format!("fd://{}", over.tun_fd),
147147
route_all: false,
148148
routes: Vec::new(),
149-
gateway: ipnet::Ipv4Net::new(Ipv4Addr::new(10, 0, 0, 1), 30)?.into(),
149+
gateway: ipnet::Ipv4Net::new(Ipv4Addr::new(10, 0, 0, 1), 30)?,
150150
gateway_v6: None,
151151
mtu: None,
152152
so_mark: None,
@@ -258,7 +258,7 @@ async fn run_clash(config_path: String, work_dir: String, over: ProfileOverride)
258258

259259
info!("Config path: {config_path}\n\tTUN fd: {}", over.tun_fd);
260260

261-
let _: JoinHandle<eyre::Result<()>> = tokio::spawn(async {
261+
let _handle: JoinHandle<eyre::Result<()>> = tokio::spawn(async {
262262
let (log_tx, _) = broadcast::channel(100);
263263
info!("Starting clash-rs");
264264
if let Err(err) = start(config, work_dir, log_tx).await {

0 commit comments

Comments
 (0)