File tree 12 files changed +41
-25
lines changed
12 files changed +41
-25
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### GUI
6
6
7
- - 修复无法读取本地数据自动查询授权的问题
7
+ - 使用随机可用端口进行授权
8
+ - 修复了 Task 潜在的异常问题
9
+ - 修复一个错误的日志输出
10
+
11
+ ### CLI
12
+
13
+ - 使用随机可用端口进行授权
14
+
15
+ ### NyaLCF Core
16
+
17
+ - 使用随机端口分配启动鉴权回调服务
8
18
9
19
## 版本信息
10
20
11
21
- nyalcf_gui: 1.0.0
12
22
- nyalcf_cli: 1.0.0
13
23
- 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
15
26
16
27
<!-- Some change log here -->
Original file line number Diff line number Diff line change @@ -29,14 +29,14 @@ class Authorize implements Command {
29
29
Future <void > main (List <String > args) async {
30
30
final ApiClient api = ApiClient ();
31
31
32
- await startHttpServer ();
32
+ final port = await startHttpServer ();
33
33
Logger .info (
34
34
'Please open this link to authorize: '
35
35
'http://dashboard.locyanfrp.cn/auth/oauth/authorize'
36
36
'?app_id=1'
37
37
'&scopes=User,Proxy,Sign'
38
38
'&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' ,
40
40
);
41
41
Logger .write ('Waiting callback...' );
42
42
Future .doWhile (() async {
@@ -77,12 +77,12 @@ class Authorize implements Command {
77
77
_tokenStorage.setFrpToken (frpToken);
78
78
}
79
79
80
- Future <void > startHttpServer () async {
80
+ Future <int > startHttpServer () async {
81
81
OAuth .initRoute (
82
82
response: OAuthResponseBody (success: '授权成功' , error: '授权失败' ),
83
83
callback: callback,
84
84
);
85
- await OAuth .start ();
85
+ return await OAuth .start ();
86
86
}
87
87
88
88
void callback ({String ? refreshToken, String ? error}) {
Original file line number Diff line number Diff line change 1
1
name : nyalcf_core_extend
2
2
description : " Nya LoCyanFrp! core extend module."
3
- version : 2.0.0
3
+ version : 2.0.1
4
4
homepage : https://nyalcf.1l1.icu
5
5
publish_to : none
6
6
Original file line number Diff line number Diff line change 1
1
name : nyalcf
2
2
description : " [CLI]The next generation of LoCyanFrp launcher."
3
- version : 1.0.0+2
3
+ version : 1.0.0+4
4
4
homepage : https://nyalcf.1l1.icu
5
5
publish_to : none
6
6
# repository: https://github.com/my_org/my_repo
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ class OAuth {
20
20
}) {
21
21
app.get ('/oauth/callback' , (Request request) {
22
22
String ? error = request.requestedUri.queryParameters['error' ];
23
- String ? refreshToken = request.requestedUri.queryParameters['refresh_token' ];
23
+ String ? refreshToken =
24
+ request.requestedUri.queryParameters['refresh_token' ];
24
25
25
26
if (error != null ) {
26
27
callback (error: error);
@@ -40,8 +41,9 @@ class OAuth {
40
41
});
41
42
}
42
43
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;
45
47
}
46
48
47
49
static close () {
Original file line number Diff line number Diff line change @@ -22,8 +22,9 @@ class UserInfoStorage {
22
22
/// 读取用户数据
23
23
static Future <UserInfoModel ?> read () async {
24
24
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);
27
28
return UserInfoModel .fromJson (jsonDecode (result));
28
29
} catch (e, t) {
29
30
Logger .error (e, t: t);
Original file line number Diff line number Diff line change 1
1
name : nyalcf_core
2
2
description : ' Nya LoCyanFrp! core module.'
3
- version : 2.0.0
3
+ version : 2.0.1
4
4
homepage : https://nyalcf.1l1.icu
5
5
publish_to : none
6
6
# repository: https://github.com/my_org/my_repo
Original file line number Diff line number Diff line change 1
1
abstract class TaskBasic {
2
- late Function ? callback;
2
+ Function ? callback;
3
3
startUp ({Function ? callback});
4
4
}
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class TaskUpdateProxiesList extends TaskBasic {
32
32
return ;
33
33
}
34
34
if (rs.statusCode == 200 ) {
35
- final List <Map < String , dynamic > > list = rs.data['data' ]['list' ];
35
+ final List <dynamic > list = rs.data['data' ]['list' ];
36
36
37
37
final List <ProxyInfoModel > proxies = [];
38
38
for (Map <String , dynamic > proxy in list) {
Original file line number Diff line number Diff line change 1
1
name : nyalcf_core_extend
2
2
description : " Nya LoCyanFrp! core extend module."
3
- version : 2.0.0
3
+ version : 2.0.1
4
4
homepage : https://nyalcf.1l1.icu
5
5
publish_to : none
6
6
Original file line number Diff line number Diff line change @@ -108,18 +108,19 @@ class _AuthorizeState extends State<AuthorizeUI> {
108
108
109
109
@override
110
110
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));
117
111
OAuth .initRoute (
118
112
response: OAuthResponseBody (success: '授权成功' , error: '授权失败' ),
119
113
callback: ctr.callback,
120
114
);
121
115
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
+ });
123
124
super .initState ();
124
125
}
125
126
@@ -142,6 +143,7 @@ class _Controller extends GetxController {
142
143
if (error != null ) {
143
144
this .error.value = error;
144
145
} else {
146
+ OAuth .close ();
145
147
ApiClient api = ApiClient ();
146
148
message.value = '已取得返回数据,正在获取访问令牌,请稍后...' ;
147
149
final rs = await api
Original file line number Diff line number Diff line change 1
1
name : nyalcf
2
2
description : " [GUI]The next generation of LoCyanFrp launcher."
3
- version : 1.0.0+3
3
+ version : 1.0.0+4
4
4
homepage : https://nyalcf.1l1.icu
5
5
publish_to : ' none'
6
6
You can’t perform that action at this time.
0 commit comments