Skip to content

Commit f29f69a

Browse files
authored
Merge pull request #224 from Muska-Ami/dev
Ver. 1.0.0+4
2 parents 3c06d77 + 05daefa commit f29f69a

File tree

12 files changed

+41
-25
lines changed

12 files changed

+41
-25
lines changed

Diff for: RELEASE_CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44

55
### GUI
66

7-
- 修复无法读取本地数据自动查询授权的问题
7+
- 使用随机可用端口进行授权
8+
- 修复了 Task 潜在的异常问题
9+
- 修复一个错误的日志输出
10+
11+
### CLI
12+
13+
- 使用随机可用端口进行授权
14+
15+
### NyaLCF Core
16+
17+
- 使用随机端口分配启动鉴权回调服务
818

919
## 版本信息
1020

1121
- nyalcf_gui: 1.0.0
1222
- nyalcf_cli: 1.0.0
1323
- nyalcf_env: 2.0.0
14-
- nyalcf_core,nyalcf_inject: 2.0.0
24+
- nyalcf_core: 2.0.1
25+
- nyalcf_inject: 2.0.0
1526

1627
<!-- Some change log here -->

Diff for: nyalcf_cli/lib/commands/authorize.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class Authorize implements Command {
2929
Future<void> main(List<String> args) async {
3030
final ApiClient api = ApiClient();
3131

32-
await startHttpServer();
32+
final port = await startHttpServer();
3333
Logger.info(
3434
'Please open this link to authorize: '
3535
'http://dashboard.locyanfrp.cn/auth/oauth/authorize'
3636
'?app_id=1'
3737
'&scopes=User,Proxy,Sign'
3838
'&redirect_url='
39-
'https%3A%2F%2Fdashboard.locyanfrp.cn%2Fcallback%2Fauth%2Foauth%2Flocalhost%3Fport%3D21131%26ssl%3Dfalse%26path%3D%2Foauth%2Fcallback',
39+
'https%3A%2F%2Fdashboard.locyanfrp.cn%2Fcallback%2Fauth%2Foauth%2Flocalhost%3Fport%3D$port%26ssl%3Dfalse%26path%3D%2Foauth%2Fcallback',
4040
);
4141
Logger.write('Waiting callback...');
4242
Future.doWhile(() async {
@@ -77,12 +77,12 @@ class Authorize implements Command {
7777
_tokenStorage.setFrpToken(frpToken);
7878
}
7979

80-
Future<void> startHttpServer() async {
80+
Future<int> startHttpServer() async {
8181
OAuth.initRoute(
8282
response: OAuthResponseBody(success: '授权成功', error: '授权失败'),
8383
callback: callback,
8484
);
85-
await OAuth.start();
85+
return await OAuth.start();
8686
}
8787

8888
void callback({String? refreshToken, String? error}) {

Diff for: nyalcf_cli/nyalcf_core_extend/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nyalcf_core_extend
22
description: "Nya LoCyanFrp! core extend module."
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://nyalcf.1l1.icu
55
publish_to: none
66

Diff for: nyalcf_cli/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nyalcf
22
description: "[CLI]The next generation of LoCyanFrp launcher."
3-
version: 1.0.0+2
3+
version: 1.0.0+4
44
homepage: https://nyalcf.1l1.icu
55
publish_to: none
66
# repository: https://github.com/my_org/my_repo

Diff for: nyalcf_core/lib/network/server/oauth.dart

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class OAuth {
2020
}) {
2121
app.get('/oauth/callback', (Request request) {
2222
String? error = request.requestedUri.queryParameters['error'];
23-
String? refreshToken = request.requestedUri.queryParameters['refresh_token'];
23+
String? refreshToken =
24+
request.requestedUri.queryParameters['refresh_token'];
2425

2526
if (error != null) {
2627
callback(error: error);
@@ -40,8 +41,9 @@ class OAuth {
4041
});
4142
}
4243

43-
static start() async {
44-
_server = await io.serve(app.call, 'localhost', 21131);
44+
static Future<int> start() async {
45+
_server = await io.serve(app.call, 'localhost', 0);
46+
return _server!.port;
4547
}
4648

4749
static close() {

Diff for: nyalcf_core/lib/storages/stores/user_info_storage.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ class UserInfoStorage {
2222
/// 读取用户数据
2323
static Future<UserInfoModel?> read() async {
2424
try {
25-
final String result =
26-
await File('$_path/session.json').readAsString(encoding: utf8);
25+
final file = File('$_path/session.json');
26+
if (!await file.exists()) return null;
27+
final String result = await file.readAsString(encoding: utf8);
2728
return UserInfoModel.fromJson(jsonDecode(result));
2829
} catch (e, t) {
2930
Logger.error(e, t: t);

Diff for: nyalcf_core/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nyalcf_core
22
description: 'Nya LoCyanFrp! core module.'
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://nyalcf.1l1.icu
55
publish_to: none
66
# repository: https://github.com/my_org/my_repo

Diff for: nyalcf_gui/nyalcf_core_extend/lib/tasks/basic.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
abstract class TaskBasic {
2-
late Function? callback;
2+
Function? callback;
33
startUp({Function? callback});
44
}

Diff for: nyalcf_gui/nyalcf_core_extend/lib/tasks/update_proxies_list.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TaskUpdateProxiesList extends TaskBasic {
3232
return;
3333
}
3434
if (rs.statusCode == 200) {
35-
final List<Map<String, dynamic>> list = rs.data['data']['list'];
35+
final List<dynamic> list = rs.data['data']['list'];
3636

3737
final List<ProxyInfoModel> proxies = [];
3838
for (Map<String, dynamic> proxy in list) {

Diff for: nyalcf_gui/nyalcf_core_extend/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nyalcf_core_extend
22
description: "Nya LoCyanFrp! core extend module."
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://nyalcf.1l1.icu
55
publish_to: none
66

Diff for: nyalcf_gui/nyalcf_ui/lib/views/auth/authorize.dart

+9-7
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,19 @@ class _AuthorizeState extends State<AuthorizeUI> {
108108

109109
@override
110110
void initState() {
111-
const url = 'https://dashboard.locyanfrp.cn/auth/oauth/authorize'
112-
'?app_id=1'
113-
'&scopes=User,Proxy,Sign'
114-
'&redirect_url='
115-
'https%3A%2F%2Fdashboard.locyanfrp.cn%2Fcallback%2Fauth%2Foauth%2Flocalhost%3Fport%3D21131%26ssl%3Dfalse%26path%3D%2Foauth%2Fcallback';
116-
launchUrl(Uri.parse(url));
117111
OAuth.initRoute(
118112
response: OAuthResponseBody(success: '授权成功', error: '授权失败'),
119113
callback: ctr.callback,
120114
);
121115
OAuth.close();
122-
OAuth.start();
116+
OAuth.start().then((port) {
117+
final url = 'https://dashboard.locyanfrp.cn/auth/oauth/authorize'
118+
'?app_id=1'
119+
'&scopes=User,Proxy,Sign'
120+
'&redirect_url='
121+
'https%3A%2F%2Fdashboard.locyanfrp.cn%2Fcallback%2Fauth%2Foauth%2Flocalhost%3Fport%3D$port%26ssl%3Dfalse%26path%3D%2Foauth%2Fcallback';
122+
launchUrl(Uri.parse(url));
123+
});
123124
super.initState();
124125
}
125126

@@ -142,6 +143,7 @@ class _Controller extends GetxController {
142143
if (error != null) {
143144
this.error.value = error;
144145
} else {
146+
OAuth.close();
145147
ApiClient api = ApiClient();
146148
message.value = '已取得返回数据,正在获取访问令牌,请稍后...';
147149
final rs = await api

Diff for: nyalcf_gui/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nyalcf
22
description: "[GUI]The next generation of LoCyanFrp launcher."
3-
version: 1.0.0+3
3+
version: 1.0.0+4
44
homepage: https://nyalcf.1l1.icu
55
publish_to: 'none'
66

0 commit comments

Comments
 (0)