Skip to content

Commit d45beaf

Browse files
authored
Merge branch 'master' into dev/dashboard
2 parents 0df6954 + a2085fc commit d45beaf

20 files changed

+363
-411
lines changed

README.md

Lines changed: 1 addition & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
🎉 __*新增功能!*__ WebDAV 支持。通过基于 Web 的分布式编写和版本控制(英语:Web-based Distributed Authoring and Versioning,缩写:WebDAV),用户可以协同编辑和管理存储在万维网服务器文件。
2929

30-
3130
</div>
3231

3332
# 简介
@@ -36,181 +35,9 @@
3635

3736
如果你想加入 OpenBMCLAPI,可以寻找 [bangbang93](https://github.com/bangbang93) 获取 `CLUSTER_ID``CLUSTER_SECRET`
3837

39-
# 部署
40-
41-
## 从源码运行
42-
43-
建议 Python 版本:3.10+。
44-
45-
1. 克隆仓库或从 [Releases](https://github.com/TTB-Network/python-openbmclapi/releases) 中下载代码:
46-
47-
温馨提示:master 分支提供的代码暂不稳定,建议下载稳定的 Release 版本。
48-
49-
```sh
50-
git clone https://github.com/tianxiu2b2t/python-openbmclapi.git
51-
cd python-openbmclapi
52-
```
53-
54-
仓库镜像地址:https://gitee.com/ttb-network/python-openbmclapi
55-
56-
3. 安装依赖:
57-
58-
```sh
59-
pip install -r requirements.txt
60-
```
61-
62-
> 你可能需要先安装 [Microsoft C++ 生成工具](https://visualstudio.microsoft.com/visual-cpp-build-tools/)。
63-
64-
4. 运行一次主程序生成配置文件:
65-
66-
```sh
67-
python main.py
68-
```
69-
70-
如果你看到以下报错信息:`core.exceptions.ClusterIdNotSet`,那么你就可以进行下一步的配置。
71-
72-
5. 在 `config/config.yml` 中,填写你的 `id`(即 `CLUSTER_ID`)和 `secret`(即 `CLUSTER_SECRET`)。
73-
74-
6. 重新启动程序。
75-
76-
## 使用 Docker 部署
77-
78-
1. 拉取镜像:
79-
80-
```sh
81-
docker pull silianz/python-openbmclapi:latest
82-
```
83-
84-
你也可使用镜像源进行拉取:
85-
86-
```sh
87-
docker pull registry.cn-hangzhou.aliyuncs.com/silianz/python-openbmclapi:latest
88-
```
89-
90-
2. 创建容器:
91-
92-
```sh
93-
docker run -d \
94-
-v ${/path/to/your/cache}:/opt/python-openbmclapi/bmclapi \
95-
-e cluster.id=${cluster.id} \
96-
-e cluster.secret=${cluster.secret} \
97-
-e cluster.public_port=${cluster.public_port} \
98-
-p ${cluster.public_port}:8080 \
99-
--restart always \
100-
--name python-openbmclapi \
101-
silianz/python-openbmclapi
102-
```
103-
104-
**参数说明:**
105-
106-
`web.public_port` - 对外开放的端口。
107-
108-
`cluster.id` - 即 `CLUSTER_ID`
109-
110-
`cluster.secret` - 即 `CLUSTER_SECRET`
111-
112-
`/path/to/your/cache` - `bmclapi` 文件夹(即缓存 `cache` 文件夹)挂载的路径。
113-
114-
## 配置文件
115-
116-
```yml
117-
advanced:
118-
# 是否启用调试模式
119-
debug: false
120-
# 新连接读取数据头大小
121-
header_bytes: 4096
122-
# 数据传输缓存大小
123-
io_buffer: 16777216
124-
# 语言
125-
language: zh_cn
126-
# 最小读取速率(Bytes)
127-
min_rate: 500
128-
# 最小读取速率时间
129-
min_rate_timestamp: 1000
130-
# 请求缓存大小
131-
request_buffer: 8192
132-
# OpenBMCLAPI 的 BaseURL
133-
url: https://openbmclapi.bangbang93.com/
134-
# 超时时间
135-
timeout: 30
136-
# 是否跳过签名检测
137-
skip_sign: false
138-
file:
139-
# 文件检查模式,可选值为 exists(检查文件是否存在,不推荐)、
140-
# size(检查文件大小)和 hash(检查文件哈希值)
141-
check: size
142-
cache:
143-
# 缓存大小(Bytes)
144-
buffer: 536870912
145-
# 检查过时文件时间,单位为秒
146-
check: 360
147-
# 文件存在时间,单位为秒
148-
time: 1800
149-
cluster:
150-
# 是否不使用 BMCLAPI 分发的证书, 同 CLUSTER_BYOC
151-
byoc: false
152-
# 是否启用节点
153-
enable: true
154-
# OpenBMCLAPI 的 CLUSTER_ID
155-
id: ''
156-
# 实际开放的公网主机名, 同 CLUSTER_IP
157-
public_host: ''
158-
# 实际开放的公网端口, 同 CLUSTER_PUBLIC_PORT
159-
public_port: 8800
160-
# 重连
161-
reconnect:
162-
# 重试间隔
163-
delay: 60
164-
# 重试次数,-1 为无限次数
165-
retry: -1
166-
# OpenBMCLAPI 的 CLUSTER_SECRET
167-
secret: ''
168-
# 超时设置
169-
timeout:
170-
# 发送启用数据包超时时间
171-
enable: 120
172-
dashboard:
173-
# 仪表盘密码
174-
password: ''
175-
type: websocket
176-
# 仪表盘用户名
177-
username: admin
178-
download:
179-
# 最高下载线程
180-
threads: 64
181-
# 存储设置
182-
storages:
183-
bmclapi: # 你的存储名字
184-
# 存储路径
185-
path: ./bmclapi
186-
# 存储类型,可选值为 file(本地存储)和 webdav(WebDAV)
187-
type: file
188-
# 选用存储下载权重,-1 为禁用,不选择,但会下载文件
189-
width: 0
190-
bmclapi_webdav:
191-
path: /bmclapidev
192-
type: webdav
193-
width: 2
194-
# 你的 WebDAV 端点
195-
endpoint: http://localhost:5244/dav
196-
# WebDAV 用户名
197-
username: user
198-
# WebDAV 用户密码
199-
password: password
200-
web:
201-
# 是否强制使用 SSL
202-
force_ssl: false
203-
# 要监听的本地端口, 同 CLUSTER_PORT
204-
port: 8080
205-
# 服务器名字
206-
server_name: TTB-Network
207-
# SSL 端口
208-
ssl_port: 8800
209-
```
210-
21138
# 贡献
21239

213-
如果你有能力,你可以向我们的[团队](mailto://administrator@ttb-network.top)或[团队所有者](mailto://silian_zheng@outlook.com)发送邮件并申请加入开发者行列
40+
如果你有能力,你可以向我们的仓库提交 Pull Request
21441

21542
# 鸣谢
21643

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.10.3-6b2e6c5
1+
v1.10.4-bb3ac7a

config/config.yml.example

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
advanced:
2+
auto_update: false
23
debug: false
4+
download_threads: 64
5+
file_check_mode: size
36
header_bytes: 4096
47
io_buffer: 16777216
58
language: zh_cn
@@ -12,6 +15,7 @@ advanced:
1215
cache:
1316
buffer: 536870912
1417
check: 360
18+
enable: true
1519
time: 1800
1620
cluster:
1721
byoc: false
@@ -28,12 +32,8 @@ cluster:
2832
keepalive: 300
2933
dashboard:
3034
password: ''
31-
type: websocket
3235
username: admin
33-
download:
34-
threads: 64
35-
file:
36-
check: size
36+
websocket: true
3737
storages:
3838
bmclapi:
3939
path: ./bmclapi
@@ -44,3 +44,4 @@ web:
4444
port: 8080
4545
server_name: TTB-Network
4646
ssl_port: 8800
47+
x_forwarded_for: 0

core/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,27 @@
88
from .scheduler import exit as scheduler_exit
99
from .utils import WaitLock
1010

11-
env['MONOTONIC'] = time.monotonic()
12-
env['STARTUP'] = time.time()
11+
env["MONOTONIC"] = time.monotonic()
12+
env["STARTUP"] = time.time()
1313

1414
wait_exit: WaitLock = WaitLock()
1515

16+
1617
def init():
1718
wait_exit.acquire()
1819
logger.tinfo("core.info.loading")
1920
version = sys.version_info
20-
logger.tinfo("core.info.python_version",
21-
v=f"{version.major}.{version.minor}.{version.micro}")
21+
logger.tinfo(
22+
"core.info.python_version", v=f"{version.major}.{version.minor}.{version.micro}"
23+
)
2224
atexit.register(exit)
2325
try:
2426
asyncio.run(async_init())
2527
except KeyboardInterrupt:
2628
if wait_exit.locked:
2729
wait_exit.release()
2830

31+
2932
async def async_init():
3033
# first init
3134
await scheduler_init()
@@ -36,13 +39,14 @@ async def async_init():
3639
from .cluster import exit as cluster_exit
3740
from .stats import init as stats_init
3841
from .update import init as update_init
42+
3943
update_init()
4044
scheduler.delay(network_init)
4145
stats_init()
4246
await cluster_init()
4347

4448
await wait_exit.wait()
45-
env['EXIT'] = True
49+
env["EXIT"] = True
4650
network_exit()
4751
await cluster_exit()
4852
scheduler_exit()

core/certificate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def load_text(cert: str, key: str):
4444
if load_cert(cert_file, key_file):
4545
logger.tsuccess("cert.success.loaded_cert")
4646
from core.network import restart
47+
4748
restart()
4849
cert_file.unlink()
4950
key_file.unlink()

0 commit comments

Comments
 (0)