An open API service indexing awesome lists of open source software.

https://github.com/chmlfrp/union-normative-system

ChmlFrp第三方启动器联盟规范制度
https://github.com/chmlfrp/union-normative-system

chmlfrp union

Last synced: 17 days ago
JSON representation

ChmlFrp第三方启动器联盟规范制度

Awesome Lists containing this project

README

        

# 联盟规范制度

## 1.加入ChmlFrp第三方启动器联盟
1.需要拥有一个github账号和CHMLFRP账号

2.所写启动器必须按照联盟规范制度

3.账号不在 https://all.chmlfrp.com/blacklist 当中

4.没有对CHMLFRP有过损害行为

5.遵守以上规则

6.要求代码开源

## 2.用户数据存储位置
我们要求启动器对用户数据需统一存储至注册表

数据项位置:
```
计算机\HKEY_CURRENT_USER\Software\ChmlFrp
```

文件树:
```
├───ChmlFrp
│ ├───password
│ ├───username
│ └───usertoken

```

| 数据项名称 | 数据项类型 | 描述 |
| ------------- | ------------- | ------------- |
| password | 字符串值 | 用户密码 |
| username | 字符串值 | 用户名 |
| usertoken | 字符串值 | 用户token |

## 2.示例代码

```python
import winreg

class User:
key_path = r"SOFTWARE\ChmlFrp"
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_path)

username = None
password = None
usertoken = None

@staticmethod
def load():
try:
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, User.key_path) as key:
User.username = winreg.QueryValueEx(key, "username")[0]
User.password = winreg.QueryValueEx(key, "password")[0]
User.usertoken = winreg.QueryValueEx(key, "usertoken")[0]
except FileNotFoundError:
User.username = None
User.password = None
User.usertoken = None

@staticmethod
def save(username, password, usertoken):
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, User.key_path, 0, winreg.KEY_WRITE) as key:
winreg.SetValueEx(key, "username", 0, winreg.REG_SZ, username)
winreg.SetValueEx(key, "password", 0, winreg.REG_SZ, password)
winreg.SetValueEx(key, "usertoken", 0, winreg.REG_SZ, usertoken)
User.load()
```

```csharp
using Microsoft.Win32;

public static class User
{
private static readonly RegistryKey Key =
Registry.CurrentUser.CreateSubKey(@"SOFTWARE\\ChmlFrp", true);
public static string Username;
public static string Password;
public static string Usertoken;

static User()
{
Load();
}

private static void Load()
{
Username = Key.GetValue("username")?.ToString();
Password = Key.GetValue("password")?.ToString();
Usertoken = Key.GetValue("usertoken")?.ToString();
}

public static void Save(string username, string password, string usertoken)
{
Key.SetValue("username", username);
Key.SetValue("password", password);
Key.SetValue("usertoken", usertoken);
Load();
}
}
```

## 3.启动配置文件存储位置
我们要求启动器对启动配置文件需统一存储至用户文件夹

文件夹位置:
```
C:\Users\[用户名]\AppData\Roaming\ChmlFrp
```

文件树:
```
├───ChmlFrp
│ ├───Debug-[启动器缩写].logs
│ ├───frpc.exe
│ ├───Inis
│ │ [隧道名].ini
│ │
│ ├───Logs
│ │ [隧道名].logs
│ │
│ └───Pictures

```

## 3.示例代码

```csharp
using System.IO;

public static class Paths
{
public static readonly string DataPath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ChmlFrp");

public static readonly string IniPath = Path.Combine(DataPath, "Inis");
public static readonly string LogPath = Path.Combine(DataPath, "Logs");
public static readonly string FrpExePath = Path.Combine(DataPath, "frpc.exe");
public static readonly string PicturesPath = Path.Combine(DataPath, "Pictures");
public static readonly string LogfilePath = Path.Combine(DataPath, "Debug-[启动器缩写].logs");
}
```