Skip to content
Merged

Dev #125

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/agent-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
- "docs/**"
- "README.md"


jobs:
agent-release:
name: Build - ${{ matrix.platform.release_for }}
Expand Down Expand Up @@ -136,7 +135,7 @@ jobs:
release-dev:
name: Release Dev
needs: [ agent-release, agent-windows, agent-macos ]
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -161,7 +160,7 @@ jobs:
release-main:
name: Release Main
needs: [ agent-release, agent-windows, agent-macos ]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/server-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
- "docs/**"
- "README.md"


jobs:
server-release:
name: Build - ${{ matrix.platform.release_for }}
Expand Down Expand Up @@ -90,7 +89,7 @@ jobs:
release-dev:
name: Release Dev
needs: [ server-release, server-windows, server-macos ]
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -115,7 +114,7 @@ jobs:
release-main:
name: Release Main
needs: [ server-release, server-windows, server-macos ]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ node_modules/
docs/.vitepress/dist
docs/.vitepress/cache
md.md
test-py
test-py
static
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nodeget-agent"
version = "0.3.6"
version = "0.3.7"
edition = "2024"

[dependencies]
Expand Down
21 changes: 14 additions & 7 deletions docs/api/static_bucket/crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": false,
"cors": true
"cors": true,
"enable": true
}
```

Expand All @@ -33,7 +34,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": false,
"cors": true
"cors": true,
"enable": true
}
```

Expand All @@ -50,7 +52,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": false,
"cors": true
"cors": true,
"enable": true
},
"id": 1
}
Expand All @@ -67,7 +70,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": false,
"cors": true
"cors": true,
"enable": true
}
}
```
Expand Down Expand Up @@ -123,7 +127,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": false,
"cors": true
"cors": true,
"enable": true
}
}
```
Expand Down Expand Up @@ -154,7 +159,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": true,
"cors": true
"cors": true,
"enable": false
},
"id": 1
}
Expand All @@ -171,7 +177,8 @@
"name": "my-site",
"path": "sites/my-site",
"is_http_root": true,
"cors": true
"cors": true,
"enable": false
}
}
```
Expand Down
4 changes: 3 additions & 1 deletion docs/api/static_bucket/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Config 中的 `static_path` 字段决定所有 bucket 的顶级磁盘根目录
"name": "my-site",
"path": "sites/my-site",
"is_http_root": false,
"cors": true
"cors": true,
"enable": true
}
```

Expand All @@ -48,6 +49,7 @@ Config 中的 `static_path` 字段决定所有 bucket 的顶级磁盘根目录
- `path`:磁盘相对路径(相对 `static_path`),如 `sites/my-site`,允许 `/` 多级嵌套
- `is_http_root`:是否接管根路由 `/`
- `cors`:是否开启 `Access-Control-Allow-Origin: *`
- `enable`:是否启用 HTTP 访问。`false` 时该 bucket 的 HTTP 入口返回 404(不影响 RPC 操作和 WebDAV)

## 注意事项

Expand Down
2 changes: 1 addition & 1 deletion nodeget-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nodeget-lib"
version = "0.3.6"
version = "0.3.7"
edition = "2024"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nodeget-server"
version = "0.3.6"
version = "0.3.7"
edition = "2024"
description = "Next-generation server monitoring and management tools"
license = "AGPL-3"
Expand Down
5 changes: 2 additions & 3 deletions server/src/rpc/token/change_password.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::utils::{find_target_token, verify_supertoken};
use crate::entity::token;
use crate::token::cache::TokenCache;
use crate::token::hash_string;
use jsonrpsee::core::RpcResult;
use nodeget_lib::error::NodegetError;
use sea_orm::{ActiveModelTrait, Set};
use serde_json::value::RawValue;
use super::utils::{find_target_token, verify_supertoken};
use tracing::debug;

/// 修改指定 token 的密码(Super Token 专用)
Expand Down Expand Up @@ -69,8 +69,7 @@ pub async fn change_password(
);
}

let response =
r#"{"success":true,"message":"Password changed successfully"}"#.to_owned();
let response = r#"{"success":true,"message":"Password changed successfully"}"#.to_owned();
RawValue::from_string(response)
.map_err(|e| NodegetError::SerializationError(format!("{e}")).into())
};
Expand Down
8 changes: 5 additions & 3 deletions server/src/rpc/token/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ impl RpcServer for TokenRpcImpl {
target_token_key = target_tk,
target_username = target_un,
);
async { rpc_exec!(change_password::change_password(token, target_token, new_password).await) }
.instrument(span)
.await
async {
rpc_exec!(change_password::change_password(token, target_token, new_password).await)
}
.instrument(span)
.await
}

async fn roll_token_secret(
Expand Down
9 changes: 4 additions & 5 deletions server/src/rpc/token/roll_token_secret.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::utils::{find_target_token, verify_supertoken};
use crate::entity::token;
use crate::token::cache::TokenCache;
use crate::token::hash_string;
Expand All @@ -6,7 +7,6 @@ use nodeget_lib::error::NodegetError;
use nodeget_lib::utils::generate_random_string;
use sea_orm::{ActiveModelTrait, Set};
use serde_json::value::RawValue;
use super::utils::{find_target_token, verify_supertoken};
use tracing::debug;

/// 重新生成目标 token 的 secret(Super Token 专用)
Expand Down Expand Up @@ -40,10 +40,9 @@ pub async fn roll_token_secret(token: String, target_token: String) -> RpcResult
let mut active_model: token::ActiveModel = target_model.into();
active_model.token_hash = Set(new_token_hash);

let updated = active_model
.update(db)
.await
.map_err(|e| NodegetError::DatabaseError(format!("Failed to update token secret: {e}")))?;
let updated = active_model.update(db).await.map_err(|e| {
NodegetError::DatabaseError(format!("Failed to update token secret: {e}"))
})?;

debug!(
target: "token",
Expand Down
14 changes: 6 additions & 8 deletions server/src/rpc/token/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ use tracing::{debug, warn};
/// 辅助函数:从标识符中提取 token_key(如果是 `key:secret` 格式则取 key 部分)
/// 也支持 `username|password` 格式(取 username 部分)
pub fn extract_target_identifier(identifier: &str) -> &str {
identifier
.split_once(':')
.map_or(
identifier.split_once('|').map_or(identifier, |(u, _)| u),
|(k, _)| k,
)
identifier.split_once(':').map_or(
identifier.split_once('|').map_or(identifier, |(u, _)| u),
|(k, _)| k,
)
}

/// 辅助函数:按 token_key 或 username 查找目标 token
Expand Down Expand Up @@ -54,8 +52,8 @@ pub async fn find_target_token(identifier: &str) -> Result<token::Model, Nodeget

/// 校验调用者是否为 Super Token
pub async fn verify_supertoken(token: &str) -> Result<(), NodegetError> {
let token_or_auth =
TokenOrAuth::from_full_token(token).map_err(|e| NodegetError::ParseError(format!("{e}")))?;
let token_or_auth = TokenOrAuth::from_full_token(token)
.map_err(|e| NodegetError::ParseError(format!("{e}")))?;

let is_super = check_super_token(&token_or_auth)
.await
Expand Down
Loading