vault backup: 2026-01-05 13:03:55
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
|
||||
key : 272f337c0d2c4407b930bde5e9846072
|
||||
endpoint: https://my-chatgpt.openai.azure.com/
|
||||
|
||||
```bash
|
||||
export AZURE_OPENAI_API_KEY="272f337c0d2c4407b930bde5e9846072"
|
||||
export AZURE_OPENAI_ENDPOINT="https://my-chatgpt.openai.azure.com/"
|
||||
```
|
||||
```
|
||||
|
||||
```.env
|
||||
# ChatGPT Settings (required)
|
||||
# Set the API Key from OpenAI
|
||||
OPENAI_API_KEY=272f337c0d2c4407b930bde5e9846072
|
||||
# To use Azure OpenAI API, set `OPENAI_AZURE` to true and `CHATGPT_REVERSE_PROXY` to your completion endpoint
|
||||
# OPENAI_AZURE=false
|
||||
OPENAI_AZURE=true
|
||||
CHATGPT_REVERSE_PROXY=https://my-chatgpt.openai.azure.com/
|
||||
|
||||
# Set the ChatGPT conversation context to 'thread', 'room' or 'both'.
|
||||
CHATGPT_CONTEXT=thread
|
||||
# Set the ChatGPT model to be used by the API. 'gpt-3.5-turbo' is the official ChatGPT-model from OpenAI
|
||||
# Note that the models are not free and will charge your OpenAI account depending on the usage of tokens
|
||||
#CHATGPT_API_MODEL=gpt-3.5-turbo
|
||||
CHATGPT_API_MODEL=gpt-4o
|
||||
# (Optional) Explicitly set the prefix sent to model at the beginning of a conversation
|
||||
#CHATGPT_PROMPT_PREFIX=Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.
|
||||
# (Optional) Set to true if ChatGPT should ignore any messages which are not text
|
||||
#CHATGPT_IGNORE_MEDIA=false
|
||||
# (Optional) You can change the api url to use another (OpenAI-compatible) API endpoint
|
||||
#CHATGPT_REVERSE_PROXY=https://api.openai.com/v1/chat/completions
|
||||
# (Optional) Set the temperature of the model. 0.0 is deterministic, 1.0 is very creative.
|
||||
CHATGPT_TEMPERATURE=0.1
|
||||
# (Optional) (Optional) Davinci models have a max context length of 4097 tokens, but you may need to change this for other models.
|
||||
CHATGPT_MAX_CONTEXT_TOKENS=8192
|
||||
# You might want to lower this to save money if using a paid model. Earlier messages will be dropped until the prompt is within the limit.
|
||||
# CHATGPT_MAX_PROMPT_TOKENS=3097
|
||||
|
||||
# Set data store settings
|
||||
KEYV_BACKEND=file
|
||||
KEYV_URL=
|
||||
KEYV_BOT_ENCRYPTION=false
|
||||
KEYV_BOT_STORAGE=true
|
||||
|
||||
# Matrix Static Settings (required, see notes)
|
||||
# Defaults to "https://matrix.org"
|
||||
MATRIX_HOMESERVER_URL=
|
||||
# With the @ and :DOMAIN, ie @SOMETHING:DOMAIN - Not used if `MATRIX_ACCESS_TOKEN` is set.
|
||||
MATRIX_BOT_USERNAME=
|
||||
# Set `MATRIX_BOT_PASSWORD` the bot will print an `MATRIX_ACCESS_TOKEN` to the terminal
|
||||
MATRIX_ACCESS_TOKEN=
|
||||
# Not used if `MATRIX_ACCESS_TOKEN` is set.
|
||||
MATRIX_BOT_PASSWORD=
|
||||
|
||||
# Matrix Configurable Settings Defaults (optional)
|
||||
# Leave prefix blank to reply to all messages
|
||||
MATRIX_DEFAULT_PREFIX=!chatgpt
|
||||
MATRIX_DEFAULT_PREFIX_REPLY=false
|
||||
|
||||
# Matrix Access Control (optional)
|
||||
# Can be set to user:homeserver or a wildcard like :anotherhomeserver.example
|
||||
MATRIX_BLACKLIST=
|
||||
# `MATRIX_WHITELIST` is overriden by `MATRIX_BLACKLIST` if they contain same entry
|
||||
MATRIX_WHITELIST=
|
||||
|
||||
# Matrix Feature Flags (optional)
|
||||
MATRIX_AUTOJOIN=true
|
||||
MATRIX_ENCRYPTION=true
|
||||
# If you turn threads off you will have problems if you don't set CHATGPT_CONTEXT=room
|
||||
MATRIX_THREADS=true
|
||||
MATRIX_PREFIX_DM=false
|
||||
MATRIX_RICH_TEXT=true
|
||||
```
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
api key
|
||||
vscode:
|
||||
```
|
||||
sk-b3426ba1862543bd876be65b7f830499
|
||||
```
|
||||
|
||||
|
||||
zed:
|
||||
```
|
||||
sk-2f351b2c4d084e7c98a53311cf09e3da
|
||||
```
|
||||
@@ -0,0 +1,261 @@
|
||||
|
||||
|
||||
openapi key:
|
||||
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
|
||||
|
||||
[[Creating user accounts Dendrite]]
|
||||
|
||||
|
||||
synapse:
|
||||
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml
|
||||
New user localpart: gpt
|
||||
Password: windyboy@2006
|
||||
token from element: syt_Z3B0_yBPDcvVUmXFgHeNPGRWa_32nnGL
|
||||
new token: syt_Z3B0_PPffEqKjnAjaIpcuRRuj_0LE1j5
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
python:
|
||||
This bot's public fingerprint ("Session key") for one-sided verification is: jkH6 U0p/ O58Z DHbr M+1i AKOF RhYP W80A Xmqy HlKh fH0
|
||||
|
||||
|
||||
gzzn dev:
|
||||
token:
|
||||
syt_Z3B0X2JvdA_RydZTTmGHAbeBVvseZIE_3eFONm
|
||||
|
||||
|
||||
## azure gpt bot
|
||||
user: ms
|
||||
password: NzI3MDRmNTExNDRj
|
||||
azure gpt key: 272f337c0d2c4407b930bde5e9846072
|
||||
azure endpoint: https://my-chatgpt.openai.azure.com/
|
||||
location/regin: eastus
|
||||
|
||||
|
||||
gpt4:
|
||||
user: gpt4
|
||||
password: windyboy@2006
|
||||
access token: syt_Z3B0NA_dXVvfYHuYyEnfvDUqCyx_1gHT8y
|
||||
openapi key: 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
|
||||
|
||||
|
||||
new google account openai
|
||||
matrix api: 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
|
||||
|
||||
mail gpt4:
|
||||
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
|
||||
|
||||
|
||||
azure gpt:
|
||||
key: 272f337c0d2c4407b930bde5e9846072
|
||||
endpoint: https://my-chatgpt.openai.azure.com/
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
# Role & Identity
|
||||
你是由 Google 研发的先进 AI 助手 {{ baibot_name }},基于 {{ baibot_model_id }} 架构。
|
||||
当前会话启动时间: {{ baibot_conversation_start_time_utc }}。
|
||||
# Core Capabilities (针对 Gemini 优化)
|
||||
1. **深度推理**:拥有强大的逻辑分析、代码生成和数学计算能力。
|
||||
2. **长程记忆**:能够精准回顾和关联长对话历史中的细节,保持上下文一致性。
|
||||
3. **思维透明**:对于非显而易见的问题,必须通过"显式推理"展示你的思考路径。
|
||||
|
||||
# Thinking Protocol (思维协议)
|
||||
在回答用户之前,你必须执行以下思维循环:
|
||||
4. **意图识别**:用户真正想要解决的核心痛点是什么?隐含需求是什么?
|
||||
5. **知识检索**:在你的知识库和当前对话历史中检索相关信息。
|
||||
6. **逻辑推导**:构建解决路径,预判潜在的错误或陷阱。
|
||||
7. **自我修正**:检查生成的答案是否准确、无害且符合逻辑。
|
||||
|
||||
# Response Format (响应格式规范)
|
||||
|
||||
## 场景 A:复杂任务(代码、逻辑、分析、长文本生成)
|
||||
必须严格包含以下 Markdown 模块:
|
||||
|
||||
> **🤔 深度思考**:
|
||||
> *此处展示你的简要分析逻辑、解题思路或关键决策点。*
|
||||
|
||||
> **📋 详细解答**:
|
||||
> *此处提供具体的答案、代码实现或详细论述。*
|
||||
|
||||
> **💡 专家建议**:
|
||||
> *提供优化建议、潜在风险预警或延伸知识。*
|
||||
|
||||
## 场景 B:简单任务(问候、明确的短问题)
|
||||
- 直接给出简洁、准确的回答,无需展示思考过程。
|
||||
|
||||
# Interaction Guidelines (交互准则)
|
||||
- **准确性优先**:严禁编造事实。如果不知道,请直接说明。
|
||||
- **代码质量**:生成的代码必须是完整的、可执行的,并包含必要的注释。
|
||||
- **语言风格**:专业、客观、有条理。避免使用过度情绪化的词语。
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
grok:
|
||||
|
||||
```
|
||||
base_url: https://openrouter.ai/api/v1
|
||||
api_key: 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
|
||||
|
||||
text_generation:
|
||||
model_id: x-ai/grok-4.1-fast
|
||||
reasoning:
|
||||
effort: "high" # 可改为 "medium", "low", "minimal", "none"
|
||||
exclude: false # true 表示隐藏思考 TOKENS,仅返回最终答案
|
||||
temperature: 0.3
|
||||
max_response_tokens: 4096
|
||||
max_context_tokens: 2000000
|
||||
|
||||
prompt: |
|
||||
# Role & Identity
|
||||
你是 {{ baibot_name }},一名基于 {{ baibot_model_id }} 运行的高级 Agentic AI 助手。
|
||||
{{ baibot_model_id }} 是 xAI 的顶级模型之一,拥有 2M 超长上下文、强推理能力、可靠的工具调用机制。
|
||||
你的任务是:解决问题、提供高价值分析、执行工具调用,并保持专业性与安全性。
|
||||
当前会话启动时间:{{ baibot_conversation_start_time_utc }}。
|
||||
|
||||
# Core Capabilities(专为 Grok-4.1-Fast 调校)
|
||||
1. **Agentic Tool Calling**:在必要时自主调用工具,以实现精准查询、复杂任务分解与可执行方案。
|
||||
2. **Ultra-Long Context (2M tokens)**:可处理长文档、长代码库、研究型内容而不丢失上下文。
|
||||
3. **Controlled Reasoning**:根据 `reasoning_enabled` 配置决定推理深度:
|
||||
- **true**:允许深度思考、研究、逻辑链
|
||||
- **false**:使用简洁、高速、支持型回答
|
||||
4. **Real-World Use Case Optimization**:特别适用于技术支持、调试、研究、大型代码理解、系统架构分析。
|
||||
5. **安全与事实性优先**:对事实错误零容忍;不清楚时应明确说明。
|
||||
|
||||
# Thinking Protocol(思维协议)
|
||||
在回答前你必须执行以下内部流程(用户仅看到摘要):
|
||||
1. **意图分析**:识别显性与隐性需求
|
||||
2. **上下文吸收**:使用 2M 上下文能力读取相关内容
|
||||
3. **方案构建**:必要时通过工具解决复杂任务
|
||||
4. **逻辑校验**:检查一致性、事实性、安全性
|
||||
5. **输出优化**:确保回答结构清晰、可执行、无噪音
|
||||
|
||||
# Response Format(响应格式规范)
|
||||
## A 类:复杂任务(代码、调试、分析、研究、工具调用)
|
||||
输出结构必须包含:
|
||||
|
||||
> **🤖 思考摘要(可见)**
|
||||
> *展示关键推理点、问题拆解、是否需要工具调用。*
|
||||
|
||||
> **📘 详细解答**
|
||||
> *提供最终答案、步骤、分析或代码。所有代码必须可运行并附注释。*
|
||||
|
||||
> **🛠 工具策略(如适用)**
|
||||
> *如果需要调用工具,请明确指出你的调用目的与预期结果。*
|
||||
|
||||
> **⚡ 延伸建议**
|
||||
> *给出进一步改进、潜在风险或扩展方向。*
|
||||
|
||||
---
|
||||
|
||||
## B 类:简单任务(问候、轻量知识问答、简短建议)
|
||||
- 直接输出简洁、明确的答案
|
||||
- 不展示“思考摘要”
|
||||
|
||||
---
|
||||
|
||||
# Interaction Guidelines(交互准则)
|
||||
- **准确性第一**:如果缺乏足够信息,请请求澄清或说明不确定性
|
||||
- **风格**:专业、逻辑、清晰,不使用夸张性语言
|
||||
- **工具调用**:仅在确实有助于结果时调用
|
||||
- **代码质量**:必须可执行、含注释、结构化
|
||||
- **尊重上下文**:善用 2M context,不遗忘信息
|
||||
- **用户至上**:目标是解决问题,而不是展示能力
|
||||
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
base_url: https://openrouter.ai/api/v1
|
||||
api_key: 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
|
||||
|
||||
text_generation:
|
||||
model_id: x-ai/grok-4.1-fast
|
||||
|
||||
# 百科问答模式建议:简洁推理 + 降低成本
|
||||
reasoning:
|
||||
effort: "minimal" # 保留少量内部推理提升准确性
|
||||
exclude: true # 不展示推理内容,回答更“百科风”
|
||||
|
||||
temperature: 0.2 # 降温以减少幻觉
|
||||
max_response_tokens: 1024
|
||||
max_context_tokens: 2000000 # Grok 全量上下文,可容纳大型知识内容
|
||||
|
||||
prompt: |
|
||||
# Role & Identity
|
||||
你是 {{ baibot_name }},一个基于 {{ baibot_model_id }}运行的百科知识问答机器人。
|
||||
职责是提供:**准确、权威、可验证** 的知识性回答。
|
||||
当前会话启动时间:{{ baibot_conversation_start_time_utc }}。
|
||||
|
||||
# Core Capabilities(百科问答优化)
|
||||
1. **事实性优先**:必须确保回答可验证,杜绝编造。
|
||||
2. **知识覆盖广**:历史、科技、文化、地理、生物、工程、生活常识等都能回答。
|
||||
3. **解释简洁清晰**:像百科一样用客观语言描述,不夸张,不情绪化。
|
||||
4. **引用型表述**:如知识存在争议,应说明“在主流观点中…”。
|
||||
5. **安全稳妥**:避免医学诊断、金融投资、法律判断等高风险输出。
|
||||
|
||||
# Response Format(回答格式)
|
||||
## 简单知识问答 / 百科问答(默认)
|
||||
- 直接输出明确、准确的答案。
|
||||
- 信息按分点或短段落组织,易读易理解。
|
||||
|
||||
## 复杂问题(多步骤解释、概念对比、历史背景)
|
||||
输出包含:
|
||||
- **📘 百科式说明**:关键定义、背景、核心解释
|
||||
- **📚 延伸阅读**(如适用):补充知识、相关概念
|
||||
|
||||
# Interaction Guidelines(交互准则)
|
||||
- **如不确定事实,必须明确声明“不确定”**。
|
||||
- 不讨论阴谋论、不可靠数据源、不严谨的统计。
|
||||
- 避免提供专业医学、法律、投资建议。
|
||||
- 保持中立、客观、权威的语气。
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
```
|
||||
base_url: "https://zenmux.ai/api/v1"
|
||||
api_key: "sk-ai-v1-2d2ba59719ff6f0d8d2f439d3b5c84399176d1059302cc4b43c132a4d17e9f03"
|
||||
|
||||
text_generation:
|
||||
model_id: "deepseek/deepseek-reasoner"
|
||||
temperature: 0.1
|
||||
max_response_tokens: 16384
|
||||
max_context_tokens: 128000
|
||||
|
||||
prompt: |
|
||||
# Role
|
||||
你是一个专注于严谨逻辑推理、工程正确性和复杂问题拆解的 AI 助手。
|
||||
|
||||
你的核心目标是:
|
||||
- 给出结论正确、可执行、可复查的答案
|
||||
- 在内部进行充分推理,但不显式暴露完整思维链
|
||||
|
||||
# Reasoning Policy
|
||||
- 对复杂问题进行深度推理(内部完成)
|
||||
- 输出时仅提供:
|
||||
- 明确结论
|
||||
- 关键步骤或必要的简化推理说明
|
||||
- 可验证的事实与假设
|
||||
- 不输出逐 token 的思维链
|
||||
|
||||
# Engineering Standards
|
||||
- 所有代码必须可直接运行,包含必要注释与错误处理
|
||||
- 架构或配置建议必须说明原因
|
||||
- 对不确定性必须明确标注
|
||||
|
||||
# Style
|
||||
- 专业、冷静、工程师视角
|
||||
- 少废话,高密度信息
|
||||
|
||||
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
emb:
|
||||
```
|
||||
634442642d294d5cb1b83f5d3790bd98.VH4nn223ldRdyyi_Fuk6MpWz
|
||||
```
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
## Key
|
||||
vscode:
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
matrix-bot
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
local rag:
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
key
|
||||
```
|
||||
sk-scalJeWNKxWMePXVwiGVnCMjrDpeSkCFxyowSSYp7C9yDpFqX3wY6zg9N7ovJ0MR
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
coder :
|
||||
```
|
||||
sk-ai-v1-875cd41da6e117609e850e4c594d0116f2e128bee9bf6890eb6a48fe23e69764
|
||||
```
|
||||
|
||||
url:
|
||||
```
|
||||
https://zenmux.ai/api/v1
|
||||
```
|
||||
|
||||
```
|
||||
https://zenmux.ai/api/anthropic
|
||||
```
|
||||
|
||||
```
|
||||
https://zenmux.ai/api/vertex-ai
|
||||
```
|
||||
|
||||
obsidian:
|
||||
```
|
||||
sk-ai-v1-82f1a2df15721ca5d5afc633842b91719fea95c6c449cbb78db0dd03f7ed1aa2
|
||||
```
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Code:
|
||||
```
|
||||
32f3aa3e5c3848fbad264e83b848b226.BVXajLMpbRPaHfv7
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
code token:
|
||||
```
|
||||
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
|
||||
```
|
||||
@@ -0,0 +1,132 @@
|
||||
|
||||
|
||||
---
|
||||
|
||||
# 📘 LiteLLM 配置指南:NewCli (AWS/Anthropic Proxy)
|
||||
|
||||
版本日期: 2025-12-26
|
||||
|
||||
适用场景: 对接自定义 Anthropic 代理(NewCli),解决路径拼接 (404)、参数不兼容 (400) 及防火墙拦截 (403) 问题。
|
||||
|
||||
## 1. 核心参数规范 (Critical Specs)
|
||||
|
||||
无论使用 UI 还是 YAML,必须严格遵守以下三条铁律:
|
||||
|
||||
1. **Provider (提供商)**: 必须选 `Anthropic`。
|
||||
|
||||
- _原因_: 让 LiteLLM 自动处理 `/v1/messages` 路径拼接和 JSON 格式转换。
|
||||
|
||||
2. **Base URL (基准地址)**: `https://code.newcli.com/claude/aws`
|
||||
|
||||
- > [!WARNING] 警告
|
||||
|
||||
- > **严禁**在末尾加 `/v1`。LiteLLM 会自动追加,加了会导致双重路径 (`/v1/v1`) 报 **404**。
|
||||
|
||||
3. **Model ID (模型名)**: `claude-sonnet-4-5`
|
||||
|
||||
- _原因_: 代理商白名单仅支持此 ID。
|
||||
|
||||
|
||||
---
|
||||
|
||||
## 2. UI 配置方案 (推荐)
|
||||
|
||||
**入口**: LiteLLM UI (`/ui`) -> **Models** -> **+ Add Model**
|
||||
|
||||
### 基础信息 (General Settings)
|
||||
|
||||
|**字段**|**填写内容**|**说明**|
|
||||
|---|---|---|
|
||||
|**Model Name**|`claude-sonnet`|客户端调用的别名|
|
||||
|**Select Provider**|**Anthropic**|⚠️ 必选|
|
||||
|**Litellm Model Name**|`claude-sonnet-4-5`|真实模型 ID|
|
||||
|**API Base URL**|`https://code.newcli.com/claude/aws`|⚠️ 末尾无 `/v1`|
|
||||
|**API Key**|`sk-ant-oat01...`|填入完整 Key|
|
||||
|
||||
### 高级参数 (LiteLLM Params / Metadata)
|
||||
|
||||
> [!TIP] 关键步骤
|
||||
>
|
||||
> 在 JSON 输入框填入以下内容,用于解决参数兼容性和防火墙拦截。
|
||||
|
||||
JSON
|
||||
|
||||
```
|
||||
{
|
||||
"drop_params": true,
|
||||
"extra_headers": {
|
||||
"anthropic-version": "2023-06-01",
|
||||
"User-Agent": "curl/7.68.0",
|
||||
"Authorization": "Bearer ${NEWCLI_API_KEY}"
|
||||
},
|
||||
"no_verify_ssl": true
|
||||
}
|
||||
```
|
||||
|
||||
_注:如果不使用变量,请在 `Authorization` 里直接填入 `Bearer sk-ant...`_
|
||||
|
||||
---
|
||||
|
||||
## 3. YAML 文件配置方案 (IaC)
|
||||
|
||||
适用于 `docker-compose` 挂载配置。
|
||||
|
||||
YAML
|
||||
|
||||
```
|
||||
model_list:
|
||||
- model_name: claude-sonnet
|
||||
litellm_params:
|
||||
model: anthropic/claude-sonnet-4-5
|
||||
# ⚠️ 重点:Base URL 不带 /v1
|
||||
api_base: https://code.newcli.com/claude/aws
|
||||
# 建议使用环境变量
|
||||
api_key: os.environ/NEWCLI_API_KEY
|
||||
extra_headers:
|
||||
anthropic-version: "2023-06-01"
|
||||
# 伪装 UA 防拦截
|
||||
User-Agent: "curl/7.68.0"
|
||||
# 强制 Bearer 鉴权 (可选,视代理商严格程度)
|
||||
Authorization: "Bearer ${NEWCLI_API_KEY}"
|
||||
|
||||
general_settings:
|
||||
master_key: sk-1234
|
||||
database_url: postgresql://litellm:litellm@litellm-postgres:5432/litellm
|
||||
|
||||
litellm_settings:
|
||||
# ⚠️ 核心修复:丢弃不兼容参数(如 user, frequency_penalty),解决 400 错误
|
||||
drop_params: true
|
||||
set_verbose: true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 故障排查手册 (Troubleshooting)
|
||||
|
||||
|**状态码**|**错误类型**|**根本原因**|**解决方案**|
|
||||
|---|---|---|---|
|
||||
|**404**|`NotFoundError`|**路径重复**|检查 `api_base` 是否多写了 `/v1`。应该让 LiteLLM 自动拼接。|
|
||||
|**400**|`BadRequest`|**参数冗余**|LiteLLM 传了 OpenAI 专有参数给 Anthropic。需开启 `drop_params: true`。|
|
||||
|**403**|`Forbidden`|**WAF 拦截**|缺少 User-Agent 伪装。需在 header 添加 `"User-Agent": "curl/..."`。|
|
||||
|**401**|`AuthError`|**鉴权失败**|Key 错误或格式不对。尝试在 `extra_headers` 强制注入 `Authorization: Bearer <key>`。|
|
||||
|
||||
---
|
||||
|
||||
## 5. 客户端调用示例
|
||||
|
||||
验证配置是否成功的标准命令(访问 LiteLLM 端口):
|
||||
|
||||
Bash
|
||||
|
||||
```
|
||||
curl -X POST http://localhost:4000/v1/chat/completions \
|
||||
-H "Authorization: Bearer sk-1234" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "claude-sonnet",
|
||||
"messages": [
|
||||
{ "role": "user", "content": "Config Test: OK?" }
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
context7 mcp key:
|
||||
```
|
||||
ctx7sk-92c2c98e-817e-41d4-bb85-94824444e2bf
|
||||
```
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
compose.yml
|
||||
```yaml
|
||||
services:
|
||||
db:
|
||||
image: postgres:17-alpine
|
||||
container_name: oui-db
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=webui
|
||||
- POSTGRES_PASSWORD=webui_password
|
||||
- POSTGRES_DB=open_webui
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
|
||||
open-webui:
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
container_name: oui
|
||||
restart: always
|
||||
ports:
|
||||
- "3000:8080"
|
||||
depends_on:
|
||||
- db
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
environment:
|
||||
- 'DATABASE_URL=postgresql://webui:webui_password@db:5432/open_webui'
|
||||
- 'OPENAI_API_BASE_URL=http://host.docker.internal:4000/v1'
|
||||
- 'OPENAI_API_KEY=sk-1234'
|
||||
- 'WEBUI_SECRET_KEY=super_secret_key'
|
||||
volumes:
|
||||
- oui_data:/app/data
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
oui_data:
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
api key
|
||||
```
|
||||
xai-FDgOu9cZhAkeEBGnkFp61gyTIeqNmWuJ8CLABHIkqTUR1RYzm08hlXabnCTBrj91ee0pYjk0ZWtmRjhS
|
||||
```
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 275 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
@@ -0,0 +1,21 @@
|
||||
账号:
|
||||
18813973711@1826109533440870.onaliyun.com
|
||||
密码:
|
||||
Jinke@202403
|
||||
|
||||
|
||||
服务器:
|
||||
root
|
||||
Passw0rd
|
||||
|
||||
|
||||
nginx:
|
||||
|
||||
```nginx
|
||||
location /jsc/ {
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Server $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://172.16.0.13:8082/;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,193 @@
|
||||
|
||||
|
||||
130.120.3.75:
|
||||
|
||||
```bash
|
||||
cat /etc/redhat-release
|
||||
CentOS Linux release 7.5.1804 (Core)
|
||||
```
|
||||
|
||||
|
||||
download :
|
||||
```url
|
||||
https://download.dameng.com/eco/adapter/DM8/202405/dm8_20240408_x86_rh7_64_ent_8.1.3.140.zip
|
||||
```
|
||||
|
||||
|
||||
create user:
|
||||
```bash
|
||||
sudo groupadd dinstall
|
||||
sudo useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
|
||||
```
|
||||
|
||||
|
||||
disable selinux
|
||||
```bash
|
||||
sudo vim /etc/selinux/config
|
||||
```
|
||||
|
||||
limit
|
||||
```
|
||||
sudo vim /etc/security/limits.d/dmdba.conf
|
||||
dmdba soft nofile 65536
|
||||
dmdba hard nofile 65536
|
||||
dmdba soft nproc 4096
|
||||
dmdba hard nproc 63653
|
||||
dmdba soft core unlimited
|
||||
dmdba hard core unlimited
|
||||
|
||||
|
||||
```
|
||||
|
||||
install
|
||||
```bash
|
||||
|
||||
sudo mkdir -p /opt/db/dm
|
||||
|
||||
sudo chown -R dmdba:dinstall /opt/db/dm
|
||||
|
||||
sudo chmod -R 775 /opt/db/dm
|
||||
|
||||
su - dmdba
|
||||
|
||||
cd /opt/db/dm
|
||||
unzip dm8_20240408_x86_rh7_64_ent_8.1.3.140.zip
|
||||
Archive: dm8_20240408_x86_rh7_64_ent_8.1.3.140.zip
|
||||
inflating: dm8_20240408_x86_rh7_64.iso
|
||||
inflating: dm8_20240408_x86_rh7_64.iso_SHA256.txt
|
||||
|
||||
sudo mkdir /mnt/iso
|
||||
sudo mount -o loop /opt/db/dm/dm8_20240408_x86_rh7_64.iso /mnt/iso
|
||||
su - dmdba
|
||||
./DMInstall.bin -i
|
||||
Installer Language:
|
||||
[1]: 简体中文
|
||||
[2]: English
|
||||
Please select the installer's language [2]:
|
||||
Extract install files.........
|
||||
Welcome to DM DBMS Installer
|
||||
|
||||
Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n
|
||||
|
||||
Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
|
||||
TimeZone:
|
||||
[ 1]: (GTM-12:00) West Date Line
|
||||
[ 2]: (GTM-11:00) Samoa
|
||||
[ 3]: (GTM-10:00) Hawaii
|
||||
[ 4]: (GTM-09:00) Alaska
|
||||
[ 5]: (GTM-08:00) Pacific(America and Canada)
|
||||
[ 6]: (GTM-07:00) Arizona
|
||||
[ 7]: (GTM-06:00) Central(America and Canada)
|
||||
[ 8]: (GTM-05:00) East(America and Canada)
|
||||
[ 9]: (GTM-04:00) Atlantic(America and Canada)
|
||||
[10]: (GTM-03:00) Brasilia
|
||||
[11]: (GTM-02:00) Middle Atlantic
|
||||
[12]: (GTM-01:00) Azores
|
||||
[13]: (GTM) Greenwich Mean Time
|
||||
[14]: (GTM+01:00) Sarajevo
|
||||
[15]: (GTM+02:00) Cairo
|
||||
[16]: (GTM+03:00) Moscow
|
||||
[17]: (GTM+04:00) AbuDhabi
|
||||
[18]: (GTM+05:00) Islamabad
|
||||
[19]: (GTM+06:00) Dakar
|
||||
[20]: (GTM+07:00) BangKok,Hanoi
|
||||
[21]: (GTM+08:00) China
|
||||
[22]: (GTM+09:00) Seoul
|
||||
[23]: (GTM+10:00) Guam
|
||||
[24]: (GTM+11:00) Solomon
|
||||
[25]: (GTM+12:00) Fiji
|
||||
[26]: (GTM+13:00) Nukualofa
|
||||
[27]: (GTM+14:00) Kiribati
|
||||
Please Select the TimeZone [9]:21
|
||||
|
||||
Installation Type:
|
||||
1 Typical
|
||||
2 Server
|
||||
3 Client
|
||||
4 Custom
|
||||
Please Input the number of the Installation Type [1 Typical]:1
|
||||
Require Space: 2310M
|
||||
|
||||
Please Input the install path [/home/dmdba/dmdbms]:/opt/db/dm/dmdbms
|
||||
Available Space:32G
|
||||
Please Confirm the install path(/opt/db/dm/dmdbms)? (Y/y:Yes N/n:No) [Y/y]:y
|
||||
|
||||
Pre-Installation Summary
|
||||
Installation Location: /opt/db/dm/dmdbms
|
||||
Require Space: 2310M
|
||||
Available Space: 32G
|
||||
Version Information:
|
||||
Expire Date:
|
||||
Installation Type: Typical
|
||||
Confirm to Install? (Y/y:Yes N/n:No):y
|
||||
2024-06-28 04:55:28
|
||||
[INFO] Installing DM DBMS...
|
||||
2024-06-28 04:55:28
|
||||
[INFO] Installing BASE Module...
|
||||
2024-06-28 04:55:38
|
||||
[INFO] Installing SERVER Module...
|
||||
2024-06-28 04:55:41
|
||||
[INFO] Installing CLIENT Module...
|
||||
2024-06-28 04:55:46
|
||||
[INFO] Installing DRIVERS Module...
|
||||
2024-06-28 04:55:50
|
||||
[INFO] Installing MANUAL Module...
|
||||
2024-06-28 04:55:51
|
||||
[INFO] Installing SERVICE Module...
|
||||
2024-06-28 04:55:51
|
||||
[INFO] Move log file to log directory.
|
||||
2024-06-28 04:55:52
|
||||
[INFO] Installed DM DBMS completely.
|
||||
|
||||
Please execute the commands by root:
|
||||
/opt/db/dm/dmdbms/script/root/root_installer.sh
|
||||
|
||||
End
|
||||
|
||||
[dmdba@localhost iso]$ su -
|
||||
/opt/db/dm/dmdbms/script/root/root_installer.sh
|
||||
Move /opt/db/dm/dmdbms/bin/dm_svc.conf to /etc
|
||||
Create the DmAPService service
|
||||
Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service.
|
||||
Finished to create the service (DmAPService)
|
||||
Start the DmAPService service
|
||||
|
||||
```
|
||||
|
||||
init db
|
||||
```bash
|
||||
cd /opt/db/dm/dmdbms/bin
|
||||
|
||||
./dminit PATH=/opt/db/dm/dmdbms/data DB_NAME=DMDB INSTANCE_NAME=DMDW PORT_NUM=5236
|
||||
initdb V8
|
||||
db version: 0x7000c
|
||||
file dm.key not found, use default license!
|
||||
License will expire on 2025-03-21
|
||||
Normal of FAST
|
||||
Normal of DEFAULT
|
||||
Normal of RECYCLE
|
||||
Normal of KEEP
|
||||
Normal of ROLL
|
||||
|
||||
log file path: /opt/db/dm/dmdbms/data/DMDB/DMDB01.log
|
||||
|
||||
|
||||
log file path: /opt/db/dm/dmdbms/data/DMDB/DMDB02.log
|
||||
|
||||
write to dir [/opt/db/dm/dmdbms/data/DMDB].
|
||||
create dm database success. 2024-06-28 05:18:08
|
||||
|
||||
cd /opt/db/dm/dmdbms/script/root
|
||||
su
|
||||
Password:
|
||||
[root@localhost root]# ls
|
||||
dm_service_installer.sh dm_service_uninstaller.sh root_installer.sh
|
||||
[root@localhost root]# pwd
|
||||
/opt/db/dm/dmdbms/script/root
|
||||
[root@localhost root]# ./dm_service_installer.sh -t dmserver -dm_ini /opt/db/dm/dmdbms/data/DMDB/dm.ini -p DMDW
|
||||
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceDMDW.service to /usr/lib/systemd/system/DmServiceDMDW.service.
|
||||
Finished to create the service (DmServiceDMDW)
|
||||
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
BEGIN
|
||||
DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(
|
||||
retention => 7 * 24 * 60, -- Retain snapshots for 7 days
|
||||
interval => 60 -- Collect snapshot every 60 minutes
|
||||
);
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
BEGIN
|
||||
DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(
|
||||
retention => 7 * 24 * 60,
|
||||
interval => 60
|
||||
);
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
EXEC DBMS_STATS.alter_stats_history_retention(RETENTION => 7);
|
||||
|
||||
4gu1ln
|
||||
|
||||
|
||||
SELECT table_name,
|
||||
bytes / 1024 / 1024 AS size_mb,
|
||||
blocks,
|
||||
extents
|
||||
FROM dba_segments
|
||||
WHERE segment_type = 'TABLE'
|
||||
AND tablespace_name = 'USERS'
|
||||
ORDER BY bytes DESC;
|
||||
|
||||
SELECT segment_name AS table_name,
|
||||
bytes / 1024 / 1024 AS size_mb,
|
||||
blocks,
|
||||
extents
|
||||
FROM dba_segments
|
||||
WHERE segment_type = 'TABLE'
|
||||
AND tablespace_name = 'USERS'
|
||||
ORDER BY bytes DESC;
|
||||
|
||||
|
||||
ALTER TABLE enforce_center.SHR_DATA_SWITCH_LOGS ENABLE ROW MOVEMENT;
|
||||
ALTER TABLE enforce_center.SHR_DATA_SWITCH_LOGS SHRINK SPACE;
|
||||
|
||||
|
||||
|
||||
SELECT segment_name AS index_name,
|
||||
owner,
|
||||
bytes / 1024 / 1024 AS size_mb,
|
||||
blocks,
|
||||
extents
|
||||
FROM dba_segments
|
||||
WHERE segment_type = 'INDEX'
|
||||
AND tablespace_name = 'ENFORCE_CENTER'
|
||||
ORDER BY size_mb DESC;
|
||||
|
||||
|
||||
ALTER INDEX ENFORCE_CENTER.PERSON_INDEX REBUILD;
|
||||
|
||||
|
||||
|
||||
DROP TABLE ENFORCE_CENTER.PATROL_DOC_copy1 PURGE;
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
```sql
|
||||
ALTER SESSION SET CURRENT_SCHEMA=enforce_center;
|
||||
|
||||
ALTER SESSION SET sql_trace = TRUE;
|
||||
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
|
||||
|
||||
To integrate Forgejo running in a Docker container with the host's SSH server, follow these steps:
|
||||
|
||||
### Step 1: Disable Forgejo's Internal SSH Server
|
||||
In your `docker-compose.yml` file, add the environment variable to disable Forgejo's internal SSH server:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- FORGEJO__server__START_SSH_SERVER=false
|
||||
```
|
||||
|
||||
### Step 2: Configure the Host SSH Server
|
||||
Add a dedicated user for Forgejo (e.g., `git`) on your host:
|
||||
|
||||
```bash
|
||||
sudo adduser --disabled-password --gecos 'Forgejo' git
|
||||
```
|
||||
|
||||
Update the SSH configuration in `/etc/ssh/sshd_config`:
|
||||
|
||||
```bash
|
||||
Match User git
|
||||
AllowTcpForwarding yes
|
||||
X11Forwarding no
|
||||
PermitTunnel no
|
||||
AllowAgentForwarding no
|
||||
ForceCommand docker exec -i forgejo /app/gitea/gitea serv key-$SSH_ORIGINAL_COMMAND
|
||||
```
|
||||
|
||||
Restart the SSH server:
|
||||
|
||||
```bash
|
||||
sudo systemctl restart sshd
|
||||
```
|
||||
|
||||
### Step 3: Update Forgejo Configuration
|
||||
Ensure that Forgejo's SSH domain and port in the configuration match your host's SSH settings. You can do this in the Forgejo web interface or by modifying the `app.ini` file within the container.
|
||||
|
||||
This setup allows Forgejo to use the host's SSH server for Git operations while running in a Docker container.
|
||||
|
||||
|
||||
|
||||
create user
|
||||
```bash
|
||||
docker exec forgejo forgejo admin user create --username fengzhiqiang --password admingzzn --email fengzhq@it2000.com.cn --admin
|
||||
```
|
||||
|
||||
|
||||
email
|
||||
```
|
||||
HOST = smtp.exmail.qq.com:465
|
||||
FROM = server@it2000.com.cn
|
||||
USER = server@it2000.com.cn
|
||||
PASSWD = Gzzn1234
|
||||
|
||||
```
|
||||
|
||||
|
||||
freeipa:
|
||||
add user forgejo/forgejopass for bind
|
||||
|
||||
|
||||
To add FreeIPA LDAP as an authentication source in Forgejo, follow these steps:
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **FreeIPA Server**: Ensure you have a FreeIPA server set up and running.
|
||||
2. **Forgejo Installation**: Have Forgejo installed and accessible.
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
### 1. Create a Bind Account in FreeIPA
|
||||
|
||||
- **Create a gitea.ldif file** on the FreeIPA server, replacing `dc=example,dc=com` with your DN, and provide an appropriately secure password:
|
||||
|
||||
```ldif
|
||||
dn: uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com
|
||||
changetype: add
|
||||
objectclass: account
|
||||
objectclass: simplesecurityobject
|
||||
uid: gitea
|
||||
userPassword: secure password
|
||||
passwordExpirationTime: 20380119031407Z
|
||||
nsIdleTimeout: 0
|
||||
```
|
||||
|
||||
- **Import the LDIF** (change localhost to an IPA server if needed). Provide the Directory Manager password when prompted:
|
||||
|
||||
```bash
|
||||
ldapmodify -h localhost -p 389 -x -D "cn=Directory Manager" -W -f gitea.ldif
|
||||
```
|
||||
|
||||
- **Add an IPA group for gitea_users**:
|
||||
|
||||
```bash
|
||||
ipa group-add --desc="Gitea Users" gitea_users
|
||||
```
|
||||
|
||||
### 2. Configure Forgejo
|
||||
|
||||
- **Log in to Forgejo as an Administrator** and navigate to Admin Panel > Authentication.
|
||||
- **Click on "Add New Source"** and select "LDAP (via BindDN)".
|
||||
- **Fill in the following fields**, changing all where appropriate:
|
||||
|
||||
- **Authorization Name**: FreeIPA
|
||||
- **Host**: `ldap://<your-freeipa-server>`
|
||||
- **Port**: 389
|
||||
- **Bind DN**: `uid=gitea,cn=sysaccounts,cn=etc,dc=example,dc=com`
|
||||
- **Bind Password**: secure password
|
||||
- **User Search Base**: `ou=Users,dc=example,dc=com`
|
||||
- **User Filter**: `(&(objectClass=posixAccount)(uid=%s))`
|
||||
- **Admin Filter**: `(memberOf=cn=gitea_users,cn=groups,cn=accounts,dc=example,dc=com)`
|
||||
- **Username Attribute**: uid
|
||||
- **First Name Attribute**: givenName
|
||||
- **Surname Attribute**: sn
|
||||
- **Email Attribute**: mail
|
||||
|
||||
- **Save the changes** and test the authentication by logging out and trying to log in with a FreeIPA user account.
|
||||
|
||||
By following these steps, you can successfully integrate FreeIPA LDAP as an authentication source in Forgejo, allowing users to log in with their FreeIPA credentials.
|
||||
|
||||
Citations:
|
||||
[1] https://www.reddit.com/r/FreeIPA/comments/1ax8te1/can_i_use_an_existing_ldap_server_as_a_source_of/
|
||||
[2] https://github.com/freeipa/freeipa
|
||||
[3] https://freeipa.readthedocs.io/en/latest/designs/external-idp/external-idp.html
|
||||
[4] https://fossies.org/linux/forgejo/docs/content/usage/authentication.en-us.md
|
||||
[5] https://forgejo.org/docs/latest/admin/config-cheat-sheet/
|
||||
[6] https://huijzer.xyz/posts/forgejo-setup/
|
||||
[7] https://forum.yunohost.org/t/how-to-authenticate-to-foregjo-over-https/25444
|
||||
[8] https://forgejo.org/docs/latest/admin/email-setup/
|
||||
@@ -0,0 +1,11 @@
|
||||
token:
|
||||
g1mYHokq7pEGgP_z4_VU
|
||||
|
||||
http --pretty format "https://gitlab.int.it2000.com.cn/api/v4/projects/?simple=yes&per_page=1000&page=1" > project.json
|
||||
|
||||
curl --header "PRIVATE-TOKEN:g1mYHokq7pEGgP_z4_VU" "https://gitlab.int.it2000.com.cn/api/v4/projects/?simple=yes&private=true&per_page=1000&page=1" | jq > project.json
|
||||
|
||||
https://tableconvert.com/json-to-excel
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
### Notes
|
||||
```dataview
|
||||
table file.ctime as Date from "300-resources/Development"
|
||||
sort file.name
|
||||
```
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
install:
|
||||
|
||||
```bash
|
||||
|
||||
sudo ipa-server-install --domain=int.it2000.com.cn \
|
||||
--ds-password=admingzzn \
|
||||
--admin-password=admingzzn \
|
||||
--hostname=ipa.int.it2000.com.cn \
|
||||
--ip-address=10.100.100.2 \
|
||||
--setup-dns
|
||||
```
|
||||
|
||||
|
||||
coolpit ssl:
|
||||
|
||||
```bash
|
||||
ipa-getcert request -f /etc/cockpit/ws-certs.d/$(hostname -f).cert -k /etc/cockpit/ws-certs.d/$(hostname -f).key -D $(hostname -f) -K host/$(hostname -f) -m 0640 -o root:cockpit-ws -O root:root -M 0644
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
ipa-getcert list
|
||||
```
|
||||
|
||||
|
||||
change user password:
|
||||
```bash
|
||||
ipa user-mod (user) --password
|
||||
```
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
https://121.8.227.182:8988/
|
||||
|
||||
|
||||
admin
|
||||
|
||||
u3fPP*-N?pYGYLZT
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
# Rustdesk
|
||||
## GZZN OFFICE
|
||||
|
||||
### win 10 desktop
|
||||
1259681763
|
||||
```
|
||||
w42YyME_y3jVb!qa4X.c
|
||||
```
|
||||
|
||||
### opensuse desktop
|
||||
11 439 584:
|
||||
```
|
||||
uW!g6CU6kteozaHUaJX*
|
||||
```
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
Title: "\[Better Developers\] Using 'From X Import Y' in Python"
|
||||
Author: [[Reuven Lerner]]
|
||||
From:
|
||||
|
||||
## Highlights:
|
||||
|
||||
Is a variation on "import" that is commonly used, which looks like this:
|
||||
from X import Y
|
||||
|
||||
The idea is pretty simple: When you say
|
||||
import foobar
|
||||
|
||||
you're creating a variable "foobar" in the current namespace. That variable is a module, whose attributes are the global variables created in the module's file
|
||||
|
||||
Whether you find it aesthetically ugly, or annoying to type, or confusing, or if you just want to put it in the current namespace, you can do that with:
|
||||
from foobar import hello
|
||||
|
||||
Or if you want both of them, you can say
|
||||
from foobar import hello, x
|
||||
|
||||
Once you have done this, the names "hello" and "x" are defined in your current namespace, and you can use them to access the module's attributes
|
||||
|
||||
Note that I keep saying, "the current namespace." That's because "import", like "def", is a way to define a variable. When you use "def", you're both creating a function object and setting a variable (the function name) to point to that function object. And when you use "import", you're both creating a module object, and setting a variable (the module name) to point to that module object.
|
||||
|
||||
But all variables can be global or local -- and modules are no different.
|
||||
|
||||
I should note that while you can use an "import" statement anywhere, it's pretty rare in my experience to have it anywhere but at the global scope
|
||||
|
||||
So: "from-import" loads the entire module, and puts the module in sys.modules. It then creates aliases to the specified names in the local namespace.
|
||||
|
||||
And if you're using "from-import" because you want to save memory, or don't want to load an entire module, that's obviously bad news.
|
||||
|
||||
When you say "from import *", you're saying that it would be totally OK for the module's variables to overwrite the variables that you have defined in the current namespace
|
||||
|
||||
For starters, "from-import" ignores names that start with an underscore (_) character
|
||||
|
||||
If I want, I can also define the variable __all__, a list of strings indicating which names should be exported when you use a wildcard
|
||||
@@ -0,0 +1,4 @@
|
||||
## Highlights:
|
||||
`Mock.patch ` will intercept import statements identified by a string, and return a Mock instance you can preconfigure using the techniques we discussed above.
|
||||
|
||||
we need to supply `Mock.patch ` with a string representing our specific import. We do not want to supply simply `os.getcwd ` since that would patch it for all modules, instead we want to supply the module under test’s import of os , i.e. work.os . When the module is imported patch will work its magic and return a Mock instead.
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
变量隐藏 [[Scope and Shadowing - Rust By Example]]
|
||||
@@ -0,0 +1,15 @@
|
||||
Fundamental rules for for Universal Naming Convention (UNC),which enable applications to create and process valid names for files and directories, regardless of the file system:
|
||||
|
||||
Following reserved characters:
|
||||
```
|
||||
< (less than)
|
||||
> (greater than)
|
||||
: (colon)
|
||||
" (double quote)
|
||||
/ (forward slash)
|
||||
\ (backslash)
|
||||
| (vertical bar or pipe)
|
||||
? (question mark)
|
||||
* (asterisk)
|
||||
```
|
||||
Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255),
|
||||
@@ -0,0 +1,9 @@
|
||||
```bash
|
||||
|
||||
sudo ipa-server-install --realm=INT.IT2000.COM.CN --domain=int.it2000.com.cn --ds-password=admingzzn --admin-password=admingzzn --hostname=ipa.int.it2000.com.cn --ip-address=10.16.67.98 --setup-dns
|
||||
|
||||
sudo firewall-cmd --add-service={http,https,dns,ntp,freeipa-ldap,freeipa-ldaps} --permanent
|
||||
|
||||
sudo firewall-cmd --reload
|
||||
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
If your user is called `user` and your host is called you could add these lines to `/etc/sudoers`:
|
||||
|
||||
```
|
||||
user = (root) NOPASSWD: /sbin/shutdown
|
||||
user = (root) NOPASSWD: /sbin/reboot
|
||||
```
|
||||
|
||||
This will allow the user `user` to run the desired commands without entering a password. All other sudoed commands will still require a password.
|
||||
|
||||
The commands specified in the `sudoers` file _must_ be fully qualified (i.e. using the absolute path to the command to run)
|
||||
|
||||
If the command ends with a trailing `/` character and points to a directory, the user will be able to run any command in that directory (but not in any sub-directories therein). In the following example, the user `user` can run any command in the directory `/home/someuser/bin/`:
|
||||
|
||||
```
|
||||
user = (root) NOPASSWD: /home/someuser/bin/
|
||||
```
|
||||
|
||||
As an alternative to editing the `/etc/sudoers` file, you could add the two lines to a new file in `/etc/sudoers.d` e.g. `/etc/sudoers.d/shutdown`. This is an elegant way of separating different changes to the `sudo` rights and also leaves the original `sudoers` file untouched for easier upgrades.
|
||||
|
||||
*visudo can be used to edit those files too, this prevent error that could lock you out of the system*
|
||||
```
|
||||
sudo visudo -f /etc/sudoers.d/shutdown
|
||||
```
|
||||
@@ -0,0 +1,508 @@
|
||||
|
||||
Certainly! I can guide you through the process of using **cfssl** (Cloudflare's PKI toolkit) to generate a self-signed Certificate Authority (CA) and server certificate for your Nacos server. Then, I'll show you how to import the CA certificate into your Spring Boot application's Docker container so that it trusts the Nacos server's certificate.
|
||||
|
||||
This approach provides a robust and manageable way to handle certificates, especially when dealing with multiple services and environments.
|
||||
|
||||
---
|
||||
|
||||
## **Overview**
|
||||
|
||||
1. **Install cfssl and cfssljson**: Set up the cfssl toolkit.
|
||||
2. **Generate a Self-Signed CA Certificate**: Create a root CA using cfssl.
|
||||
3. **Generate a Server Certificate for Nacos Signed by the CA**: Create a certificate for your Nacos server.
|
||||
4. **Configure the Nacos Server to Use the Server Certificate**: Set up Nacos to use the generated certificate.
|
||||
5. **Import the CA Certificate into Your Spring Boot Application's Docker Container**: Ensure your application trusts the Nacos server's certificate.
|
||||
6. **Configure Your Spring Boot Application**: Update settings to communicate with the Nacos server over HTTPS.
|
||||
7. **Test the Setup**: Verify that everything works as expected.
|
||||
|
||||
---
|
||||
|
||||
## **Prerequisites**
|
||||
|
||||
- **cfssl and cfssljson** installed on your system.
|
||||
- **Nacos server** installed and running.
|
||||
- **Docker** installed and configured.
|
||||
- **Spring Boot application** ready to be containerized.
|
||||
|
||||
---
|
||||
|
||||
## **Step 1: Install cfssl and cfssljson**
|
||||
|
||||
First, you need to install **cfssl** and **cfssljson**. These are command-line tools provided by Cloudflare for managing PKI.
|
||||
|
||||
### **1.1. Download the Binaries**
|
||||
|
||||
#### **For Linux:**
|
||||
|
||||
```bash
|
||||
# Download cfssl
|
||||
curl -L -o cfssl https://github.com/cloudflare/cfssl/releases/download/v1.6.3/cfssl_linux-amd64
|
||||
|
||||
# Download cfssljson
|
||||
curl -L -o cfssljson https://github.com/cloudflare/cfssl/releases/download/v1.6.3/cfssljson_linux-amd64
|
||||
```
|
||||
|
||||
#### **For macOS:**
|
||||
|
||||
```bash
|
||||
# Download cfssl
|
||||
curl -L -o cfssl https://github.com/cloudflare/cfssl/releases/download/v1.6.3/cfssl_darwin-amd64
|
||||
|
||||
# Download cfssljson
|
||||
curl -L -o cfssljson https://github.com/cloudflare/cfssl/releases/download/v1.6.3/cfssljson_darwin-amd64
|
||||
```
|
||||
|
||||
### **1.2. Make the Binaries Executable**
|
||||
|
||||
```bash
|
||||
chmod +x cfssl cfssljson
|
||||
```
|
||||
|
||||
### **1.3. Move the Binaries to Your PATH**
|
||||
|
||||
```bash
|
||||
sudo mv cfssl cfssljson /usr/local/bin/
|
||||
```
|
||||
|
||||
Alternatively, you can add the directory containing `cfssl` and `cfssljson` to your `PATH`.
|
||||
|
||||
### **1.4. Verify Installation**
|
||||
|
||||
```bash
|
||||
cfssl version
|
||||
cfssljson -version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 2: Generate a Self-Signed CA Certificate**
|
||||
|
||||
We'll create a self-signed CA certificate using cfssl.
|
||||
|
||||
### **2.1. Create a CA Configuration File (`ca-config.json`)**
|
||||
|
||||
Create a file named `ca-config.json` with the following content:
|
||||
|
||||
```json
|
||||
{
|
||||
"signing": {
|
||||
"default": {
|
||||
"expiry": "8760h"
|
||||
},
|
||||
"profiles": {
|
||||
"nacos": {
|
||||
"expiry": "87600h",
|
||||
"usages": ["signing", "key encipherment", "server auth", "client auth"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### **2.2. Create a CA Certificate Signing Request (`ca-csr.json`)**
|
||||
|
||||
Create a file named `ca-csr.json` with the following content:
|
||||
|
||||
```json
|
||||
{
|
||||
"CN": "My Root CA",
|
||||
"key": {
|
||||
"algo": "rsa",
|
||||
"size": 4096
|
||||
},
|
||||
"names": [
|
||||
{
|
||||
"C": "US",
|
||||
"ST": "State",
|
||||
"L": "City",
|
||||
"O": "YourOrganization",
|
||||
"OU": "YourUnit"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### **2.3. Generate the CA Certificate and Key**
|
||||
|
||||
Run the following command:
|
||||
|
||||
```bash
|
||||
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
|
||||
```
|
||||
|
||||
This command generates:
|
||||
|
||||
- `ca.pem`: The CA certificate.
|
||||
- `ca-key.pem`: The CA private key.
|
||||
- `ca.csr`: The CA certificate signing request (not needed further).
|
||||
|
||||
**Note:** Keep `ca-key.pem` secure and do not share it.
|
||||
|
||||
---
|
||||
|
||||
## **Step 3: Generate a Server Certificate for Nacos Signed by the CA**
|
||||
|
||||
### **3.1. Create a Server Certificate Signing Request (`nacos-csr.json`)**
|
||||
|
||||
Create a file named `nacos-csr.json` with the following content:
|
||||
|
||||
```json
|
||||
{
|
||||
"CN": "nacos.example.com",
|
||||
"hosts": [
|
||||
"nacos.example.com",
|
||||
"127.0.0.1",
|
||||
"192.168.1.100"
|
||||
],
|
||||
"key": {
|
||||
"algo": "rsa",
|
||||
"size": 2048
|
||||
},
|
||||
"names": [
|
||||
{
|
||||
"C": "US",
|
||||
"ST": "State",
|
||||
"L": "City",
|
||||
"O": "YourOrganization",
|
||||
"OU": "YourUnit"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- **`CN`**: Common Name. Should match the domain name used to access Nacos.
|
||||
- **`hosts`**: Include all DNS names and IP addresses that will be used to access the Nacos server.
|
||||
- Replace `"nacos.example.com"` and `"192.168.1.100"` with your server's actual domain and IP address.
|
||||
|
||||
### **3.2. Generate the Server Certificate and Key**
|
||||
|
||||
Run the following command:
|
||||
|
||||
```bash
|
||||
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=nacos nacos-csr.json | cfssljson -bare nacos
|
||||
```
|
||||
|
||||
This command generates:
|
||||
|
||||
- `nacos.pem`: The Nacos server certificate.
|
||||
- `nacos-key.pem`: The Nacos server private key.
|
||||
- `nacos.csr`: The Nacos server CSR (not needed further).
|
||||
|
||||
### **3.3. Verify the Certificates**
|
||||
|
||||
You can inspect the server certificate:
|
||||
|
||||
```bash
|
||||
openssl x509 -in nacos.pem -text -noout
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 4: Configure the Nacos Server to Use the Server Certificate**
|
||||
|
||||
Now, configure your Nacos server to use the generated `nacos.pem` and `nacos-key.pem` files.
|
||||
|
||||
### **4.1. Convert the Certificates to PKCS#12 Format (If Necessary)**
|
||||
|
||||
Some servers require certificates in PKCS#12 format.
|
||||
|
||||
```bash
|
||||
openssl pkcs12 -export -in nacos.pem -inkey nacos-key.pem -out nacos.p12 -name nacos -CAfile ca.pem -caname root -password pass:yourpassword
|
||||
```
|
||||
|
||||
- **`nacos.p12`**: The PKCS#12 keystore file.
|
||||
- **`yourpassword`**: Replace with a secure password.
|
||||
|
||||
### **4.2. Configure Nacos to Use SSL**
|
||||
|
||||
#### **Option A: Standalone Nacos (Embedded Tomcat)**
|
||||
|
||||
If you're running Nacos in standalone mode using embedded Tomcat, you can configure SSL in `application.properties` or `application.yml`.
|
||||
|
||||
**In `application.properties`:**
|
||||
|
||||
```properties
|
||||
server.port=8848
|
||||
server.ssl.enabled=true
|
||||
server.ssl.key-store=classpath:nacos.p12
|
||||
server.ssl.key-store-password=yourpassword
|
||||
server.ssl.key-store-type=PKCS12
|
||||
```
|
||||
|
||||
- **Note**: Place `nacos.p12` in the `classpath` (e.g., in the `resources` directory).
|
||||
|
||||
#### **Option B: Nacos with External Tomcat or Nginx**
|
||||
|
||||
If you're using an external server (like Tomcat or Nginx), configure it to use `nacos.pem` and `nacos-key.pem`.
|
||||
|
||||
**Example with Nginx:**
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name nacos.example.com;
|
||||
|
||||
ssl_certificate /path/to/nacos.pem;
|
||||
ssl_certificate_key /path/to/nacos-key.pem;
|
||||
ssl_client_certificate /path/to/ca.pem;
|
||||
ssl_verify_client off; # Change to 'on' if you want to verify client certificates
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8848;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### **4.3. Restart the Nacos Server**
|
||||
|
||||
After configuring SSL, restart your Nacos server to apply the changes.
|
||||
|
||||
---
|
||||
|
||||
## **Step 5: Import the CA Certificate into Your Spring Boot Application's Docker Container**
|
||||
|
||||
Your Spring Boot application needs to trust the CA that signed the Nacos server's certificate. We'll import `ca.pem` into the Java trust store inside your Docker container.
|
||||
|
||||
### **5.1. Convert the CA Certificate to DER Format**
|
||||
|
||||
Java `keytool` requires certificates in DER format.
|
||||
|
||||
```bash
|
||||
openssl x509 -outform der -in ca.pem -out ca.der
|
||||
```
|
||||
|
||||
### **5.2. Update Your Dockerfile**
|
||||
|
||||
Modify your `Dockerfile` to include the CA certificate and import it into the Java trust store.
|
||||
|
||||
#### **Example Dockerfile:**
|
||||
|
||||
```dockerfile
|
||||
# Use an official OpenJDK runtime as a parent image
|
||||
FROM openjdk:17-jdk-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the application's JAR file into the container
|
||||
COPY target/your-application.jar /app/your-application.jar
|
||||
|
||||
# Copy the CA certificate into the container
|
||||
COPY ca.der /tmp/ca.der
|
||||
|
||||
# Import the CA certificate into Java's trust store
|
||||
RUN keytool -importcert \
|
||||
-alias myca \
|
||||
-keystore $JAVA_HOME/lib/security/cacerts \
|
||||
-file /tmp/ca.der \
|
||||
-storepass changeit \
|
||||
-noprompt
|
||||
|
||||
# Clean up the temporary certificate file
|
||||
RUN rm /tmp/ca.der
|
||||
|
||||
# Expose the application port
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the application
|
||||
ENTRYPOINT ["java", "-jar", "/app/your-application.jar"]
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
|
||||
- **`COPY ca.der /tmp/ca.der`**: Ensure `ca.der` is in the same directory as your `Dockerfile`.
|
||||
- **`$JAVA_HOME/lib/security/cacerts`**: Default Java trust store.
|
||||
- **`-storepass changeit`**: Default password for `cacerts`. Use the correct password if it's different.
|
||||
|
||||
### **5.3. Build the Docker Image**
|
||||
|
||||
```bash
|
||||
docker build -t your-application-image .
|
||||
```
|
||||
|
||||
### **5.4. Run the Docker Container**
|
||||
|
||||
```bash
|
||||
docker run -p 8080:8080 your-application-image
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 6: Configure Your Spring Boot Application**
|
||||
|
||||
Ensure your application is configured to communicate with the Nacos server over HTTPS.
|
||||
|
||||
### **6.1. Update Application Properties**
|
||||
|
||||
In your `application.properties` or `application.yml`, update the Nacos server address to use `https` and the correct port.
|
||||
|
||||
**Example (`application.properties`):**
|
||||
|
||||
```properties
|
||||
spring.cloud.nacos.server-addr=https://nacos.example.com:8848
|
||||
spring.cloud.nacos.username=your-username
|
||||
spring.cloud.nacos.password=your-password
|
||||
```
|
||||
|
||||
### **6.2. Disable Hostname Verification (If Necessary)**
|
||||
|
||||
If the hostname verification fails, you may need to disable it (not recommended for production).
|
||||
|
||||
Add the following JVM option:
|
||||
|
||||
```bash
|
||||
-Dcom.sun.net.ssl.checkRevocation=false -Djavax.net.ssl.trustStore=$JAVA_HOME/lib/security/cacerts
|
||||
```
|
||||
|
||||
Alternatively, set up a custom `HostnameVerifier` in your code.
|
||||
|
||||
---
|
||||
|
||||
## **Step 7: Test the Setup**
|
||||
|
||||
After starting your Docker container, test your application to ensure it communicates securely with the Nacos server.
|
||||
|
||||
- **Check Logs**: Look for any SSL-related errors.
|
||||
- **Verify Communication**: Ensure your application can register with Nacos or retrieve configurations.
|
||||
|
||||
---
|
||||
|
||||
## **Additional Considerations**
|
||||
|
||||
### **Using a Custom Trust Store**
|
||||
|
||||
Instead of modifying the default Java trust store (`cacerts`), you can create and use a custom trust store.
|
||||
|
||||
#### **5.2.1. Create a Custom Trust Store**
|
||||
|
||||
```dockerfile
|
||||
# Create a custom trust store and import the CA certificate
|
||||
RUN keytool -importcert \
|
||||
-alias myca \
|
||||
-keystore /app/truststore.jks \
|
||||
-file /tmp/ca.der \
|
||||
-storepass yourtruststorepassword \
|
||||
-noprompt
|
||||
```
|
||||
|
||||
#### **5.2.2. Set JVM Options to Use the Custom Trust Store**
|
||||
|
||||
```dockerfile
|
||||
# Set environment variable for JVM options
|
||||
ENV JAVA_OPTS="-Djavax.net.ssl.trustStore=/app/truststore.jks -Djavax.net.ssl.trustStorePassword=yourtruststorepassword"
|
||||
```
|
||||
|
||||
#### **5.2.3. Update the ENTRYPOINT**
|
||||
|
||||
```dockerfile
|
||||
ENTRYPOINT ["java", "$JAVA_OPTS", "-jar", "/app/your-application.jar"]
|
||||
```
|
||||
|
||||
### **Handling Sensitive Information**
|
||||
|
||||
Avoid hardcoding passwords in your `Dockerfile`. Use build arguments or environment variables.
|
||||
|
||||
#### **Using Build Arguments**
|
||||
|
||||
```dockerfile
|
||||
# Build argument for trust store password
|
||||
ARG TRUSTSTORE_PASS=yourtruststorepassword
|
||||
|
||||
# Use the build argument in the RUN command
|
||||
RUN keytool -importcert \
|
||||
-alias myca \
|
||||
-keystore /app/truststore.jks \
|
||||
-file /tmp/ca.der \
|
||||
-storepass $TRUSTSTORE_PASS \
|
||||
-noprompt
|
||||
|
||||
# Set JVM options
|
||||
ENV JAVA_OPTS="-Djavax.net.ssl.trustStore=/app/truststore.jks -Djavax.net.ssl.trustStorePassword=$TRUSTSTORE_PASS"
|
||||
```
|
||||
|
||||
Build the Docker image with:
|
||||
|
||||
```bash
|
||||
docker build --build-arg TRUSTSTORE_PASS=yourtruststorepassword -t your-application-image .
|
||||
```
|
||||
|
||||
### **Securing Private Keys**
|
||||
|
||||
- **Do Not Include Private Keys in Docker Images**: Ensure that `ca-key.pem` and `nacos-key.pem` are not copied into the Docker image.
|
||||
- **Secure Storage**: Store private keys securely and avoid committing them to version control.
|
||||
|
||||
---
|
||||
|
||||
## **Troubleshooting**
|
||||
|
||||
### **Common Issues and Solutions**
|
||||
|
||||
#### **SSLHandshakeException**
|
||||
|
||||
- **Cause**: The application doesn't trust the Nacos server's certificate.
|
||||
- **Solution**: Ensure the CA certificate is correctly imported into the trust store.
|
||||
|
||||
#### **Hostname Verification Failure**
|
||||
|
||||
- **Cause**: The hostname used to access the Nacos server doesn't match the `CN` or `hosts` in the certificate.
|
||||
- **Solution**:
|
||||
- Ensure the Nacos server's domain matches the `CN` or is included in the `hosts` field.
|
||||
- Use the correct domain or IP address when accessing the server.
|
||||
- As a temporary measure, disable hostname verification (not recommended for production).
|
||||
|
||||
#### **Keytool Not Found**
|
||||
|
||||
- **Cause**: `keytool` is not available in the base Docker image.
|
||||
- **Solution**: Use a JDK-based Docker image (e.g., `openjdk:17-jdk-slim`) instead of a JRE image.
|
||||
|
||||
#### **Incorrect Keystore Password**
|
||||
|
||||
- **Cause**: Wrong `storepass` used when importing the certificate.
|
||||
- **Solution**: Verify the trust store password.
|
||||
|
||||
#### **Certificate Not Found**
|
||||
|
||||
- **Cause**: The certificate file is not correctly copied or the path is incorrect.
|
||||
- **Solution**: Verify the `COPY` command and file paths in the `Dockerfile`.
|
||||
|
||||
### **Testing the Trust Store**
|
||||
|
||||
List the certificates in the trust store to confirm the import:
|
||||
|
||||
```dockerfile
|
||||
RUN keytool -list -keystore $JAVA_HOME/lib/security/cacerts -storepass changeit
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Summary**
|
||||
|
||||
By using **cfssl**, you've:
|
||||
|
||||
- Created a self-signed CA certificate.
|
||||
- Generated a server certificate for your Nacos server signed by the CA.
|
||||
- Configured your Nacos server to use the new SSL certificate.
|
||||
- Imported the CA certificate into your Spring Boot application's Docker container, ensuring trust.
|
||||
- Configured your application to communicate with the Nacos server over HTTPS.
|
||||
|
||||
This setup enhances security by establishing a trusted SSL connection between your application and the Nacos server.
|
||||
|
||||
---
|
||||
|
||||
## **Next Steps**
|
||||
|
||||
- **Automate Certificate Management**: Consider automating certificate renewal and distribution.
|
||||
- **Use a Trusted CA in Production**: For production environments, obtain certificates from a trusted Certificate Authority.
|
||||
- **Monitor SSL Connections**: Implement monitoring to detect and resolve SSL issues promptly.
|
||||
|
||||
---
|
||||
|
||||
## **References**
|
||||
|
||||
- [cfssl GitHub Repository](https://github.com/cloudflare/cfssl)
|
||||
- [Nacos Documentation](https://nacos.io/en-us/docs/what-is-nacos.html)
|
||||
- [Spring Boot SSL Configuration](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-configure-ssl)
|
||||
|
||||
---
|
||||
|
||||
Feel free to ask if you have any questions or need further assistance with any of the steps!
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
db.createUser({ user: "unifi", pwd: "unifi", roles: [{ role: "readWrite", db: "unifi" }] })
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
Title: "[Better Developers] Computers Are Cheap. People Are Expensive."
|
||||
Author:
|
||||
From:
|
||||
|
||||
## Highlights:
|
||||
|
||||
My point is that it took a long time for people to realize that it was OK to work with a high-level language, and that doing so didn't make you a worse programmer. When you use a high-level language, your programs might run a bit more slowly, but that's often an acceptable compromise.
|
||||
|
||||
---
|
||||
|
||||
**==In today's world, computers are cheap, while people are expensive.==**
|
||||
|
||||
---
|
||||
|
||||
Let's assume that a Python program runs twice as slowly as the equivalent Java program, and thus requires two servers instead of one server. In today's world, that server difference will probably cost a few hundred dollars per month. If the programmer writing the software is 5x as productive, then that server is more than paid for by the increase in efficiency.
|
||||
|
||||
---
|
||||
|
||||
This doesn't mean, of course, that you don't need to worry about slow code, or that there's no need for C++ programmers in the world any more. But the need for speed is increasingly balanced by something even more important: The need for maintainable software.
|
||||
|
||||
---
|
||||
|
||||
One of the reasons I love Python is that the code is clear and readable, allowing me to join a new project and dive in, because the code is written similarly to all of the other Python code I've read and written over the years.
|
||||
|
||||
---
|
||||
|
||||
Better to save your colleagues (and company) money by making things more efficient for people, rather than for computers.
|
||||
|
||||
---
|
||||
|
||||
Your 1st comment on this article **Note:** Really interesting insight with the switch to a high level language to save people time and make debugging easier instead of saving server resources. It might not always be the right equation like in our case where the biggest expense are the servers but in many cases it would be true that human price > server price
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
https://nvd.nist.gov/developers/confirm-api-key?uuid=40BC52EA-8655-F011-835C-129478FCB64D
|
||||
|
||||
|
||||
API Key:
|
||||
```
|
||||
5933b86c-fe7c-4836-8959-345214c5a003
|
||||
```
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
```bash
|
||||
$ cosign generate-key-pair
|
||||
Enter password for private key:
|
||||
Enter password for private key again:
|
||||
Private key written to cosign.key
|
||||
Public key written to cosign.pub
|
||||
|
||||
```
|
||||
password: windyboy
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
Hi Amin,
|
||||
|
||||
Thanks for posting in the community. We are happy to help you.
|
||||
|
||||
According to your description, the situation on your end is likely caused by your organization's settings/policies (e.g. conditional access policy).
|
||||
|
||||
You can try the following steps, and then check if it still happens or not.
|
||||
|
||||
1. Please sign out your accounts from Office applications, then close all Office applications.
|
||||
|
||||
2. Open File Explorer, paste the following path, and delete all files and folders.
|
||||
|
||||
%localappdata%\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy
|
||||
|
||||
3. In the Windows search bar, search for "Access Work or School".
|
||||
|
||||
4. Check if you can see your business account in "Access Work or School".
|
||||
|
||||
- If you don't see it, please select Connect and add your business account.
|
||||
|
||||
|
||||
- If you can see it, please select it and select Disconnect. After that, please click "Connect" and log into your account again to register the device.
|
||||
|
||||
|
||||
5. Run one Office application, such as Word, sign into your account, and check again.
|
||||
|
||||
If the error message still appears after trying the above steps, I recommend you report the situation to your organization admin or IT department.
|
||||
|
||||
We look forward to your response. Thanks for your cooperation.
|
||||
|
||||
Sincerely,
|
||||
|
||||
George | Microsoft Community Moderator
|
||||
|
||||
[Updated by George Jiang MSFT 04:33 AM 08/10 2024 UTC + 8]
|
||||
|
||||
• Beware of Scammers posting fake Support Numbers here.
|
||||
@@ -0,0 +1,5 @@
|
||||
亲,以下是您购买的商品信息。
|
||||
MobaXterm Professional 便携版
|
||||
下载地址https://wwxs.lanzoum.com/ieYNw0s21tab
|
||||
备用地址https://www.987123.xyz/oss/lovemei9/MobaXterm/MobaXterm_Portable_v23.1.zip
|
||||
说明:复制以上地址进行下载,软件包中已经集成授权文件,下载后解压即用。
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
api:
|
||||
secret_WggiGblW3PayQXirTeOCrS9FTsQ5EWGWHjInmNcvJdv
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
Here is the **definitive, consolidated guide** for setting up Playwright on **Arch Linux (WSL)**.
|
||||
|
||||
This summary skips the trial-and-error we just went through and provides the "Happy Path" to get everything working in one go.
|
||||
|
||||
---
|
||||
|
||||
### 📋 Prerequisites
|
||||
* **WSL 2** (Recommended).
|
||||
* **Proxy (Optional):** If you are behind a proxy, remember to use `sudo -E` to preserve environment variables.
|
||||
|
||||
---
|
||||
|
||||
### 🚀 Step 1: System Prep & Node.js
|
||||
First, ensure your package database is fresh (fixes 404 errors) and install Node.js.
|
||||
|
||||
```bash
|
||||
# Update system and install Node.js/npm
|
||||
# Use -E if you have https_proxy set in your shell
|
||||
sudo -E pacman -Syu nodejs npm
|
||||
```
|
||||
|
||||
### 📦 Step 2: Install System Dependencies (The Critical Step)
|
||||
**Do not** use `npx playwright install-deps` (it fails on Arch). Instead, install these packages manually. This list includes all the X11, Graphics, and Network libraries required by Chromium, Firefox, and WebKit.
|
||||
|
||||
```bash
|
||||
sudo -E pacman -S --needed \
|
||||
git \
|
||||
nss \
|
||||
nspr \
|
||||
libdrm \
|
||||
alsa-lib \
|
||||
mesa \
|
||||
gtk3 \
|
||||
at-spi2-core \
|
||||
pango \
|
||||
cairo \
|
||||
gdk-pixbuf2 \
|
||||
libx11 \
|
||||
libxcomposite \
|
||||
libxdamage \
|
||||
libxext \
|
||||
libxfixes \
|
||||
libxrandr \
|
||||
libxcursor \
|
||||
libxi \
|
||||
libxrender \
|
||||
libxcb \
|
||||
freetype2 \
|
||||
fontconfig \
|
||||
ffmpeg
|
||||
```
|
||||
|
||||
### 🛠️ Step 3: Initialize Playwright
|
||||
Set up your project and download the browser binaries (these are separate from the system libs above).
|
||||
|
||||
```bash
|
||||
# Create project directory
|
||||
mkdir my-tests && cd my-tests
|
||||
|
||||
# Initialize (Select TypeScript/JavaScript as preferred)
|
||||
npm init playwright@latest
|
||||
|
||||
# If prompted to "Install Playwright browsers", select True.
|
||||
# If you need to install them manually later:
|
||||
npx playwright install
|
||||
```
|
||||
|
||||
### ✅ Step 4: Run Tests
|
||||
You are now ready to run.
|
||||
|
||||
```bash
|
||||
npx playwright test
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 💡 Troubleshooting Cheat Sheet
|
||||
|
||||
| Issue | Solution |
|
||||
| :------------------------ | :-------------------------------------------------------------------------------- |
|
||||
| **`install-deps` fails** | **Ignore it.** It only supports Ubuntu. Use the `pacman` command in Step 2. |
|
||||
| **`libxxx.so not found`** | You are missing a package. Use `pkgfile libxxx.so` to find the Arch package name. |
|
||||
| **404 Errors (Pacman)** | Your mirrors are out of sync. Run `sudo pacman -Syu` to refresh. |
|
||||
| **Browser won't launch** | Ensure `nspr` and `nss` are installed (included in Step 2). |
|
||||
| **GUI/Headless issues** | If visual mode fails, try `xvfb-run npx playwright test`. |
|
||||
@@ -0,0 +1,173 @@
|
||||
|
||||
To set up **Oh My Posh** with **Zsh** on **Debian 12**, follow these steps to install the necessary components and configure your terminal prompt.
|
||||
|
||||
## Installation Steps
|
||||
|
||||
### 1. Download the Oh My Posh Binary
|
||||
First, you need to download the Oh My Posh binary suitable for Linux. Open your terminal and run the following command:
|
||||
|
||||
```bash
|
||||
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
|
||||
```
|
||||
|
||||
### 2. Set Executable Permissions
|
||||
Make the downloaded binary executable:
|
||||
|
||||
```bash
|
||||
sudo chmod +x /usr/local/bin/oh-my-posh
|
||||
```
|
||||
|
||||
### 3. Create a Directory for Themes
|
||||
You need a directory to store your themes. Create it using:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.poshthemes
|
||||
```
|
||||
|
||||
### 4. Download Themes
|
||||
You can download predefined themes from the Oh My Posh repository. For example, to download the latest themes, run:
|
||||
|
||||
```bash
|
||||
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
|
||||
```
|
||||
|
||||
Unzip the downloaded file:
|
||||
|
||||
```bash
|
||||
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
|
||||
```
|
||||
|
||||
Then, clean up by removing the zip file:
|
||||
|
||||
```bash
|
||||
rm ~/.poshthemes/themes.zip
|
||||
```
|
||||
|
||||
### 5. Update Your Zsh Configuration
|
||||
Now, you need to configure your Zsh shell to use Oh My Posh. Open your `.zshrc` file in a text editor:
|
||||
|
||||
```bash
|
||||
nano ~/.zshrc
|
||||
```
|
||||
|
||||
Add the following line at the end of the file to initialize Oh My Posh with a specific theme (replace `alien` with your preferred theme name):
|
||||
|
||||
```bash
|
||||
eval "$(oh-my-posh --init --shell zsh --config ~/.poshthemes/alien.omp.json)"
|
||||
```
|
||||
|
||||
### 6. Apply Changes
|
||||
After saving and closing the `.zshrc` file, apply the changes by running:
|
||||
|
||||
```bash
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
## Additional Configuration
|
||||
|
||||
### Install a Nerd Font (Optional)
|
||||
For better aesthetics, install a Nerd Font that supports icons used by Oh My Posh. You can download fonts like **Meslo** or **Fira Code** from their respective repositories and install them on your system.
|
||||
|
||||
### Set Terminal Font
|
||||
Finally, ensure that your terminal emulator is configured to use the newly installed Nerd Font for optimal display of icons and symbols.
|
||||
|
||||
By following these steps, you will have successfully set up Oh My Posh with Zsh on Debian 12, enhancing your terminal's appearance and functionality.
|
||||
|
||||
Citations:
|
||||
[1] https://dev.to/karleeov/wsl-arch-setup-for-oh-my-posh-51pa
|
||||
[2] https://www.reddit.com/r/NixOS/comments/1ge1gwn/how_to_set_ohmyposh_settings/
|
||||
[3] https://ohmyposh.dev/docs/installation/linux
|
||||
[4] https://www.librebyte.net/en/cli-en/oh-my-posh-a-beatifull-prompt-for-your-shell/
|
||||
[5] https://www.youtube.com/watch?v=nGHgyPLi7UM
|
||||
[6] https://calebschoepp.com/blog/2021/how-to-setup-oh-my-posh-on-ubuntu/
|
||||
[7] https://www.linux.org/threads/need-help-finalizing-oh-my-posh-bash-terminal.52617/
|
||||
|
||||
|
||||
|
||||
.zshrc
|
||||
```
|
||||
#go lang
|
||||
export GOROOT=/usr/local/go
|
||||
export GOPATH=/home/windy/go-lang
|
||||
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||
|
||||
eval "$(oh-my-posh --init --shell zsh --config ~/.poshthemes/powerlevel10k_modern.omp.json)"
|
||||
|
||||
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
|
||||
# Zinit setup and plugin management
|
||||
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
|
||||
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
|
||||
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
||||
source "${ZINIT_HOME}/zinit.zsh"
|
||||
|
||||
# Load essential annexes (non-turbo mode for annex functionality)
|
||||
zinit light-mode for \
|
||||
zdharma-continuum/zinit-annex-as-monitor \
|
||||
zdharma-continuum/zinit-annex-bin-gem-node \
|
||||
zdharma-continuum/zinit-annex-patch-dl \
|
||||
zdharma-continuum/zinit-annex-rust
|
||||
|
||||
# Load Zeno plugin with keybindings
|
||||
zinit ice lucid depth"1" blockf
|
||||
zinit light yuki-yano/zeno.zsh
|
||||
|
||||
if [[ -n $ZENO_LOADED ]]; then
|
||||
bindkey ' ' zeno-auto-snippet
|
||||
bindkey '^m' accept-line
|
||||
bindkey '^i' zeno-completion
|
||||
bindkey '^g' zeno-ghq-cd
|
||||
bindkey '^r' zeno-history-selection
|
||||
bindkey '^x' zeno-insert-snippet
|
||||
fi
|
||||
|
||||
# Load additional Zsh plugins
|
||||
zinit ice wait"0"; zinit light zsh-users/zsh-completions
|
||||
autoload -Uz compinit && compinit
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
||||
zstyle ':completion:*:default' menu select=1
|
||||
|
||||
zinit light zsh-users/zsh-syntax-highlighting
|
||||
zinit light zsh-users/zsh-autosuggestions
|
||||
zinit light Aloxaf/fzf-tab
|
||||
|
||||
# FZF configuration
|
||||
zi ice from"gh-r" as"program"
|
||||
zi light junegunn/fzf
|
||||
|
||||
# Auto-suggestions styling
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=244"
|
||||
|
||||
# History settings
|
||||
HISTFILE=~/.zsh-history
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=1000000
|
||||
HISTDUP=erase
|
||||
setopt appendhistory sharehistory hist_ignore_space hist_ignore_all_dups
|
||||
setopt hist_save_no_dups hist_ignore_dups hist_find_no_dups
|
||||
setopt inc_append_history share_history
|
||||
|
||||
# Zsh options for usability
|
||||
setopt AUTO_CD
|
||||
setopt AUTO_PARAM_KEYS
|
||||
|
||||
# Completion and FZF styling
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*' menu no
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
|
||||
|
||||
# Load additional plugins with default keys
|
||||
zinit pack"default+keys" for fzf
|
||||
|
||||
# Ensure Zinit autocompletion
|
||||
autoload -Uz _zinit
|
||||
(( ${+_comps} )) && _comps[zinit]=_zinit
|
||||
|
||||
# Consolidate PATH with deduplication
|
||||
export PATH=$(echo "/run/current-system/sw/bin:/usr/local/bin:/usr/local/sbin:$PATH" | tr ':' '\n' | awk '!seen[$0]++' | tr '\n' ':' | sed 's/:$//')
|
||||
|
||||
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
experimental:
|
||||
interface-name: eth0 //上网的网卡
|
||||
|
||||
创建tap设备
|
||||
打开tap设备属性,更改 share
|
||||
共享的网卡选择热点的网卡 wlan1
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
<h2>Common Options</h2>
|
||||
<div>-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.</div>
|
||||
<div>-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).</div>
|
||||
<div>-c, --cookie-jar <file name> File to save response cookies to.</div>
|
||||
<div>-d, --data <data> Send specified data in POST request. Details provided below.</div>
|
||||
<div>-f, --fail Fail silently (don't output HTML error form if returned).</div>
|
||||
<div>-F, --form <name=content> Submit form data.</div>
|
||||
<div>-H, --header <header> Headers to supply with request.</div>
|
||||
<div>-i, --include Include HTTP headers in the output.</div>
|
||||
<div>-I, --head Fetch headers only.</div>
|
||||
<div>-k, --insecure Allow insecure connections to succeed.</div>
|
||||
<div>-L, --location Follow redirects.</div>
|
||||
<div>-o, --output <file> Write output to . Can use --create-dirs in conjunction with this to create any directories specified in the -o path.</div>
|
||||
<div>-O, --remote-name Write output to file named like the remote file (only writes to current directory).</div>
|
||||
<div>-s, --silent Silent (quiet) mode. Use with -S to force it to show errors.</div>
|
||||
<div>-v, --verbose Provide more information (useful for debugging).</div>
|
||||
<div>-w, --write-out <format> Make curl display information on stdout after a completed transfer. See man page for more details on available variables. Convenient way to force curl to append a newline to output: -w "\n" (can add to ~/.curlrc).</div>
|
||||
<div>-X, --request The request method to use.</div>
|
||||
<h2>POST</h2>
|
||||
<div>When sending data via a POST or PUT request, two common formats (specified via the Content-Type header) are:</div>
|
||||
<ul><li><div>application/json</div></li><li><div>application/x-www-form-urlencoded</div></li></ul>
|
||||
<div>Many APIs will accept both formats, so if you're using curl at the command line, it can be a bit easier to use the form urlencoded format instead of json because</div>
|
||||
<ul><li><div>the json format requires a bunch of extra quoting</div></li><li><div>curl will send form urlencoded by default, so for json the Content-Type header must be explicitly set</div></li></ul>
|
||||
<div>This gist provides examples for using both formats, including how to use sample data files in either format with your curl requests.</div>
|
||||
<h2>curl usage</h2>
|
||||
<div>For sending data with POST and PUT requests, these are common curl options:</div>
|
||||
<ul><li><div>request type</div></li><ul><li><div>-X POST</div></li><li><div>-X PUT</div></li></ul><li><div>content type header</div></li><li><div>-H "Content-Type: application/x-www-form-urlencoded"</div></li><li><div>-H "Content-Type: application/json"</div></li><li><div>data</div></li><ul><li><div>form urlencoded: -d "param1=value1&m2=value2" or -d @data.txt</div></li><li><div>json: -d '{"key1":"value1", "key2":"value2"}' or -d @data.json</div></li></ul></ul>
|
||||
<h2>Examples</h2>
|
||||
<h3>POST application/x-www-form-urlencoded</h3>
|
||||
<div>application/x-www-form-urlencoded is the default:</div>
|
||||
<div>curl -d "param1=value1&m2=value2" -X POST http://localhost:3000/data</div>
|
||||
<div>explicit:</div>
|
||||
<div>curl -d "param1=value1&m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:3000/data</div>
|
||||
<div>with a data file</div>
|
||||
<div>curl -d "@data.txt" -X POST http://localhost:3000/data</div>
|
||||
<h3>POST application/json</h3>
|
||||
<div>curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data</div>
|
||||
<div>with a data file</div>
|
||||
<div>curl -d "@data.json" -X POST http://localhost:3000/data</div>
|
||||
<div><br></div>
|
||||
@@ -0,0 +1,15 @@
|
||||
Java parameters references:
|
||||
[Gradle Java Plugin](https://docs.gradle.org/current/userguide/java_plugin.html)
|
||||
|
||||
Running only certain test to debug problems:
|
||||
```
|
||||
gradle test --tests org.gradle.SomeTest.someSpecificFeature
|
||||
gradle test --tests *SomeTest.someSpecificFeature
|
||||
gradle test --tests *SomeSpecificTest
|
||||
gradle test --tests all.in.specific.package*
|
||||
gradle test --tests *IntegTest
|
||||
gradle test --tests *IntegTest*ui*
|
||||
gradle test --tests *IntegTest.singleMethod
|
||||
gradle someTestTask --tests *UiTest someOtherTestTask --tests *WebTest*ui
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user