Skip to content

Commit 3a8b683

Browse files
committed
release 2.2.4
1 parent 733d7d4 commit 3a8b683

31 files changed

+605
-209
lines changed

.github/workflows/spa-client-cd.yml

+2-17
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- os: macos-latest
2121
name: mac-spa-client
2222
bash: make release-client-mac
23-
- os: windows-latest
23+
- os: windows-latest
2424
name: windows-spa-client
2525
bash: make release-client-win
2626
runs-on: ${{ matrix.settings.os }}
@@ -29,21 +29,7 @@ jobs:
2929
uses: actions/checkout@v3
3030
with:
3131
submodules: true
32-
33-
- name: Install Rust
34-
uses: actions-rs/toolchain@v1
35-
with:
36-
toolchain: stable
37-
- name: Cache cargo registry
38-
uses: actions/cache@v2
39-
with:
40-
path: ~/.cargo/registry
41-
key: ${{ matrix.settings.os }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
42-
- name: Cache cargo index
43-
uses: actions/cache@v2
44-
with:
45-
path: ~/.cargo/git
46-
key: ${{ matrix.settings.os }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
32+
- uses: Swatinem/rust-cache@v2
4733
- name: Setup MUSL
4834
if: matrix.settings.os == 'ubuntu-latest'
4935
run: |
@@ -53,7 +39,6 @@ jobs:
5339
- name: Build Release
5440
run: ${{ matrix.settings.bash }}
5541

56-
5742
- name: Upload artifact
5843
uses: actions/upload-artifact@v4
5944
with:

.github/workflows/spa-server-cd.yml

+1-18
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,11 @@ jobs:
4747
- uses: actions/checkout@v3
4848
with:
4949
submodules: true
50-
- name: Install Rust
51-
uses: actions-rs/toolchain@v1
52-
with:
53-
toolchain: stable
54-
55-
- name: Cache cargo registry
56-
uses: actions/cache@v2
57-
with:
58-
path: ~/.cargo/registry
59-
key: cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
60-
61-
- name: Cache cargo index
62-
uses: actions/cache@v2
63-
with:
64-
path: ~/.cargo/git
65-
key: cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
66-
50+
- uses: Swatinem/rust-cache@v2
6751
- name: Setup MUSL
6852
run: |
6953
rustup target add x86_64-unknown-linux-musl
7054
sudo apt-get -qq install musl-tools
71-
7255
- name: Build Release Linux
7356
run: make release-linux-server-musl
7457

.github/workflows/spa-server-ci.yml

+6-21
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,16 @@ jobs:
1414
- uses: actions/checkout@v3
1515
with:
1616
submodules: true
17-
- name: Install Rust
18-
uses: actions-rs/toolchain@v1
19-
with:
20-
toolchain: stable
21-
- name: Cache cargo registry
22-
uses: actions/cache@v2
23-
with:
24-
path: ~/.cargo/registry
25-
key: cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
26-
- name: Cache cargo index
27-
uses: actions/cache@v2
28-
with:
29-
path: ~/.cargo/git
30-
key: cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
31-
- name: build all
32-
run: cargo build
33-
- name: run spa-client test
34-
run: cargo test -p spa-client
35-
- name: run spa-client test
36-
run: cargo test -p spa-server
17+
- uses: Swatinem/rust-cache@v2
3718
- name: run integration test
3819
# --show-output
3920
run: cargo test -p tests --test starter -j 1 -- --test-threads 1
4021
- name: run pebble
4122
run: ./run_pebble.sh
4223
working-directory: ./tests/bash/
4324
- name: run acme integration test
44-
run: cargo test -p tests --test acme_test -j 1 -- --test-threads 1
25+
run: cargo test -p tests --test acme_test -j 1 -- --test-threads 1
26+
- name: run spa-client test
27+
run: cargo test -p spa-client
28+
- name: run spa-client test
29+
run: cargo test -p spa-server

Cargo.lock

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spa-client"
3-
version = "2.2.3"
3+
version = "2.2.4"
44
edition = "2021"
55
authors = ["timzaak"]
66
license = "MIT"

client/src/api.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use crate::Config;
22
use anyhow::anyhow;
33
use reqwest::{header, multipart, StatusCode};
4-
use spa_server::admin_server::request::{
5-
DeleteDomainVersionOption, DomainWithOptVersionOption, GetDomainOption,
6-
UpdateUploadingStatusOption,
7-
};
8-
use spa_server::domain_storage::{DomainInfo, ShortMetaData, UploadDomainPosition};
4+
use spa_server::admin_server::request::{DeleteDomainVersionOption, DomainWithOptVersionOption, DomainWithVersionOption, GetDomainOption, UpdateUploadingStatusOption};
5+
use spa_server::domain_storage::{CertInfo, DomainInfo, ShortMetaData, UploadDomainPosition};
96
use std::borrow::Cow;
107
use std::path::PathBuf;
118

@@ -129,6 +126,19 @@ impl API {
129126
handle!(resp)
130127
}
131128

129+
pub async fn revoke_version(&self, domain:String, version:u32) -> anyhow::Result<()> {
130+
let resp = self
131+
.async_client
132+
.post(self.url("files/revoke_version"))
133+
.json(&DomainWithVersionOption {
134+
domain,
135+
version,
136+
})
137+
.send()
138+
.await?;
139+
handle!(resp)
140+
}
141+
132142
//TODO: use thiserror instead of anyhow
133143
pub async fn upload_file<T: Into<Cow<'static, str>>>(
134144
&self,
@@ -185,6 +195,12 @@ impl API {
185195
.await?;
186196
json_resp!(resp, UploadDomainPosition)
187197
}
198+
199+
pub async fn get_acme_cert_info(&self, domain: Option<String>) -> anyhow::Result<Vec<CertInfo>> {
200+
let resp = self.async_client.get(self.url("cert/acme"))
201+
.query(&GetDomainOption{domain}).send().await?;
202+
json_resp!(resp, Vec<CertInfo>)
203+
}
188204
}
189205
#[cfg(test)]
190206
mod test {

client/src/commands.rs

+15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ pub enum Commands {
2525
domain: Option<String>,
2626
max_reserve: Option<u32>,
2727
},
28+
Revoke {
29+
domain: String,
30+
version: u32,
31+
}
2832
}
2933

3034
#[derive(Args, Debug)]
@@ -116,4 +120,15 @@ mod test {
116120
unreachable!()
117121
}
118122
}
123+
124+
#[test]
125+
fn revoke_version() {
126+
let c = CliCommand::parse_from(&["test", "revoke", "www.example.com", "1"]);
127+
if let Commands::Revoke {domain, version} = c.commands {
128+
assert_eq!(domain, "www.example.com".to_string());
129+
assert_eq!(version, 1);
130+
} else {
131+
unreachable!()
132+
}
133+
}
119134
}

client/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ async fn run_with_commands(commands: CliCommand) -> anyhow::Result<()> {
6262
api.remove_files(domain, max_reserve).await?;
6363
success("delete success!");
6464
}
65+
Commands::Revoke {domain, version} => {
66+
api.revoke_version(domain, version).await?;
67+
success("revoke success!");
68+
}
6569
};
6670
Ok(())
6771
}

config.release.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ file_dir = "/data"
2828
// # directory to store account and certificate
2929
// # optional, default is ${file_dir}/acme
3030
// // dir = "/data/acme"
31-
// # ci / stage / prod, default is prod
31+
// # ci / stage / prod, default is prod, ci is just for CI test with Pebble, don't use it.
3232
// //type = prod
3333
// }
3434

docs/develop/change-log.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Change Log
2+
3+
### Version 2.2.4
4+
5+
- feat: add cert query API (no doc, no client SDK support)
6+
- improve: add check when upload of multiple/single domain
7+
- ci: improve GitHub Action speed
8+
- feat: add revoke version API (release JS SDK 2.2.4)
9+
210
### Version 2.2.3
311
- fix: sub_path '' => '/', like GitHub pages
412
- fix: redirect with no querystring

docs/guide/spa-server-api.md

+24-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ number of files.
9494

9595
```shell
9696

97-
curl "http://$ADMIN_SERVER/files/metadata?domain=$DOMAIN&version=$VERSION" -H "Authorization: Bearer $TOKEN"
97+
curl "$ADMIN_SERVER/files/metadata?domain=$DOMAIN&version=$VERSION" -H "Authorization: Bearer $TOKEN"
9898
# return [{path:$path_string,md5:$md5_string, length: $file_length_integer}]
9999
```
100100

@@ -105,7 +105,7 @@ curl "http://$ADMIN_SERVER/files/metadata?domain=$DOMAIN&version=$VERSION" -H "A
105105
```shell
106106
UPLOADING_STATUS=0 # Uploading:0, Finish:1
107107

108-
curl --location --request POST "http://$ADMIN_SERVER/files/upload_status" \
108+
curl --location --request POST "$ADMIN_SERVER/files/upload_status" \
109109
--header "Authorization: Bearer $TOKEN" \
110110
--header 'Content-Type: application/json' \
111111
--data-raw `{
@@ -122,7 +122,7 @@ The http body is `multipart/form-data` format.
122122

123123
```shell
124124
PATH="/upload/file/path"
125-
curl -X POST "http://$ADMIN_SERVER/file/upload?domain=$domain&version=$version&path=$PATH" \
125+
curl -X POST "$ADMIN_SERVER/file/upload?domain=$domain&version=$version&path=$PATH" \
126126
-F "file=@$PATH" -H "Authorization: Bearer $TOKEN"
127127
# return status code:200 if success
128128
```
@@ -131,11 +131,30 @@ curl -X POST "http://$ADMIN_SERVER/file/upload?domain=$domain&version=$version&p
131131

132132
```shell
133133
# keep 2 versions.
134-
MAX_RESERVE = 1
134+
MAX_RESERVE_OPT = 1
135135
curl -X POST "http://$ADMIN_SERVER/files/delete" \
136+
-H "Authorization: Bearer $TOKEN" \
136137
--data-raw `{
137138
"domain":$DOMAIN,
138-
"max_reserve": $MAX_RESERVE
139+
"max_reserve": $MAX_RESERVE_OPT
139140
}`
140141
# return status code:200 if success
142+
```
143+
144+
### Revoke version
145+
**Attention: revoke version now is temp, when you reload or restart server, then It would use the max version.**
146+
```shell
147+
TARGET_VERSION=1
148+
curl -X POST "$ADMIN_SERVER/files/revoke_version" \
149+
-H "Authorization: Bearer $TOKEN" \
150+
--data-raw `{
151+
"domain":$DOMAIN,
152+
"version": $TARGET_VERSION
153+
}`
154+
```
155+
156+
### Get Cert version
157+
```shell
158+
curl -X POST "$ADMIN_SERVER/cert?domain=$DOMAIN_OPT" \
159+
- H "Authorization: Bearer $TOKEN"
141160
```

docs/guide/spa-server-configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ file_dir = "/data"
4040
// # directory to store account and certificate
4141
// # optional, default is ${file_dir}/acme
4242
// // dir = "/data/acme"
43-
// # ci / stage / prod, default is prod
43+
// # ci / stage / prod, default is prod, ci is just for CI test with Pebble, don't use it.
4444
// //type = prod
4545
// }
4646

jsclient/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spa-client",
3-
"version": "2.2.2",
3+
"version": "2.2.4",
44
"description": "js sdk for spa-server",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

jsclient/src/command.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,29 @@ const deleteCmd = command({
135135
})
136136
}
137137
})
138+
const revokeVersionCmd = command({
139+
name: 'revoke',
140+
args: {
141+
domain,
142+
version,
143+
config: configDirOption
144+
},
145+
handler({domain, version, config}) {
146+
writeResult(async() => {
147+
const client = await getClient(config)
148+
await client.revokeVersion(domain, version)
149+
return "revoke successful"
150+
})
151+
}
152+
})
138153

139154

140155
export const cmd = subcommands({
141156
name: 'spa-client',
142157
description: 'js command line for spa-server',
143158
version: Version,
144-
cmds: {info, upload, release, reload, delete: deleteCmd}
159+
cmds: {info, upload, release, reload, delete: deleteCmd, revoke: revokeVersionCmd}
145160
})
146161
export default function runCommand() {
147162
run(binary(cmd), process.argv)
148-
}
163+
}

jsclient/src/index.ts

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export interface UploadDomainPositionResp {
3131
status: GetDomainPositionStatus
3232
}
3333

34+
export interface CertInfoResp {
35+
begin: string,
36+
end: string,
37+
host: string,
38+
}
39+
3440
export interface ShortMetaData {
3541
path: string
3642
md5: string
@@ -202,6 +208,12 @@ export default class SPAClient {
202208
params: {domain, format: 'Json'}
203209
}).then(resp<UploadDomainPositionResp>)
204210
}
211+
public revokeVersion(domain:String, version: number) {
212+
return this.http.post(`/files/revoke_version`, {domain, version}).then(emptyResp)
213+
}
214+
public getCertInfo(domain?:string) {
215+
return this.http.get('/cert/acme', {params: {domain}}).then(resp<CertInfoResp[]>)
216+
}
205217
}
206218

207219

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spa-server-doc",
3-
"version": "2.2.3",
3+
"version": "2.2.4",
44
"description": "This is for docs powered by VitePress",
55
"private": true,
66
"type": "module",

0 commit comments

Comments
 (0)