-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from Muska-Ami/dev
Update to v0.2.1 GUI with v0.0.1 CLI
- Loading branch information
Showing
65 changed files
with
705 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ | |
- [x] 登录 | ||
- [x] 隧道启动 | ||
- [ ] 进程管理 | ||
- [ ] Frpc 下载 | ||
- [x] Frpc 下载 | ||
- [x] 隧道启动 | ||
- [x] 用户信息展示 | ||
|
||
## 运行测试 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,5 +48,4 @@ class Config implements CommandImplement { | |
return null; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,99 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:dio/dio.dart'; | ||
|
||
import 'package:nyalcf/templates/command_implement.dart'; | ||
import 'package:nyalcf_core/network/dio/frpc/download_frpc.dart'; | ||
import 'package:nyalcf_core/utils/cpu_arch.dart'; | ||
import 'package:nyalcf_core/utils/frpc/arch.dart'; | ||
import 'package:nyalcf_core/utils/frpc/archive.dart'; | ||
import 'package:nyalcf_core/utils/logger.dart'; | ||
|
||
class Download implements CommandImplement { | ||
List<Map<String, String>> arch = []; | ||
late String platform; | ||
|
||
String _selectedArch = ''; | ||
String? _provideArch; | ||
String? _providePlatform; | ||
bool _provide = false; | ||
|
||
late CancelToken _cancelToken; | ||
|
||
@override | ||
void main(List<String> args) { | ||
|
||
void main(List<String> args) async { | ||
switch (args.length) { | ||
case 0: | ||
case 2: | ||
if (args.length == 2) { | ||
_provideArch = args[0]; | ||
_providePlatform = args[1]; | ||
_provide = true; | ||
} | ||
Logger.verbose('Provide info: ${_provideArch}, ${_providePlatform}'); | ||
final systemArch = await CPUArch.getCPUArchitecture(); | ||
Logger.verbose('CPU arch: ${systemArch}'); | ||
|
||
bool supportedSystem = false; | ||
|
||
if (!_provide) { | ||
getPlatformFrpcArchList(); | ||
for (var val in arch) { | ||
Logger.debug(val['arch']); | ||
if (val['name']!.contains(systemArch!)) { | ||
supportedSystem = true; | ||
_selectedArch = val['arch']!; | ||
} | ||
} | ||
Logger.info('Automatic selected arch: ${_selectedArch}'); | ||
} else { | ||
_selectedArch = _provideArch!; | ||
platform = _providePlatform!; | ||
Logger.info('Selected: ${_selectedArch} ${_providePlatform}'); | ||
} | ||
|
||
if (supportedSystem || _provide) { | ||
_cancelToken = CancelToken(); | ||
Logger.info('Starting frpc download...'); | ||
|
||
await DownloadFrpc.download( | ||
arch: _selectedArch, | ||
platform: platform, | ||
version: '0.51.3-3', | ||
releaseName: 'LoCyanFrp-0.51.3-3 #2024050701', | ||
progressCallback: callback, | ||
cancelToken: _cancelToken, | ||
useMirror: false, | ||
); | ||
stdout.write('\rPlease wait, extracting frpc...\n'); | ||
await FrpcArchive.unarchive( | ||
platform: platform, arch: _selectedArch, version: '0.51.3-3'); | ||
} else { | ||
Logger.error( | ||
'Unsupported system! If you believe this is wrong, please provide arch manually in command.'); | ||
} | ||
default: | ||
Logger.error('No valid arguments provided.'); | ||
} | ||
} | ||
|
||
} | ||
void getPlatformFrpcArchList() { | ||
if (Platform.isWindows) { | ||
platform = 'windows'; | ||
this.arch = Arch.windows; | ||
} | ||
if (Platform.isLinux) { | ||
platform = 'linux'; | ||
this.arch = Arch.linux; | ||
} | ||
if (Platform.isMacOS) { | ||
platform = 'darwin'; | ||
this.arch = Arch.macos; | ||
} | ||
} | ||
|
||
void callback(downloaded, all) { | ||
stdout.write('\r' + ' ' * 30); | ||
stdout.write('\rProgress: ${(downloaded / all * 100).toStringAsFixed(2)}%'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:nyalcf/templates/command_implement.dart'; | ||
import 'package:nyalcf_core/storages/stores/user_info_storage.dart'; | ||
import 'package:nyalcf_core/utils/logger.dart'; | ||
|
||
class Logout implements CommandImplement { | ||
@override | ||
Future<void> main(List<String> args) async { | ||
final userInfo = await UserInfoStorage.read(); | ||
final res = await UserInfoStorage.sigo(userInfo?.user, userInfo?.token); | ||
|
||
if (res) { | ||
Logger.info('Session data removed.'); | ||
} else { | ||
Logger.error('Logout failed, please check your network connection and retry.'); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
abstract class CommandImplement { | ||
/// 入口函数 | ||
void main(List<String> args); | ||
} | ||
} |
Oops, something went wrong.