mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
new & opt.
- new: support suspend and WOL #172 - opt.: `execWithPwd` when cancel - opt.: extentions
This commit is contained in:
@@ -18,6 +18,7 @@ enum ShellFunc {
|
||||
process,
|
||||
shutdown,
|
||||
reboot,
|
||||
suspend,
|
||||
;
|
||||
|
||||
String get flag {
|
||||
@@ -32,6 +33,8 @@ enum ShellFunc {
|
||||
return 'sd';
|
||||
case ShellFunc.reboot:
|
||||
return 'r';
|
||||
case ShellFunc.suspend:
|
||||
return 'sp';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +54,12 @@ enum ShellFunc {
|
||||
return 'ShutDown';
|
||||
case ShellFunc.reboot:
|
||||
return 'Reboot';
|
||||
case ShellFunc.suspend:
|
||||
return 'Suspend';
|
||||
}
|
||||
}
|
||||
|
||||
String get cmd {
|
||||
String get _cmd {
|
||||
switch (this) {
|
||||
case ShellFunc.status:
|
||||
return '''
|
||||
@@ -96,6 +101,13 @@ if [ "\$userId" = "0" ]; then
|
||||
\treboot
|
||||
else
|
||||
\tsudo -S reboot
|
||||
fi''';
|
||||
case ShellFunc.suspend:
|
||||
return '''
|
||||
if [ "\$userId" = "0" ]; then
|
||||
\tsystemctl suspend
|
||||
else
|
||||
\tsudo -S systemctl suspend
|
||||
fi''';
|
||||
}
|
||||
}
|
||||
@@ -123,7 +135,7 @@ userId=\$(id -u)
|
||||
for (final func in values) {
|
||||
sb.write('''
|
||||
${func.name}() {
|
||||
${func.cmd.split('\n').map((e) => '\t$e').join('\n')}
|
||||
${func._cmd.split('\n').map((e) => '\t$e').join('\n')}
|
||||
}
|
||||
|
||||
''');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import '../../../core/extension/stringx.dart';
|
||||
import '../../res/misc.dart';
|
||||
|
||||
class Conn {
|
||||
@@ -22,10 +21,10 @@ Conn? parseConn(String raw) {
|
||||
if (idx != '') {
|
||||
final vals = idx.split(Miscs.numReg);
|
||||
return Conn(
|
||||
maxConn: vals[5].i,
|
||||
active: vals[6].i,
|
||||
passive: vals[7].i,
|
||||
fail: vals[8].i,
|
||||
maxConn: int.tryParse(vals[5]) ?? 0,
|
||||
active: int.tryParse(vals[6]) ?? 0,
|
||||
passive: int.tryParse(vals[7]) ?? 0,
|
||||
fail: int.tryParse(vals[8]) ?? 0,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -70,7 +70,7 @@ class ServerPrivateInfo {
|
||||
return data;
|
||||
}
|
||||
|
||||
Server? get server => Providers.server.pick(spi: this);
|
||||
Server? get server => Pros.server.pick(spi: this);
|
||||
|
||||
bool shouldReconnect(ServerPrivateInfo old) {
|
||||
return id != old.id ||
|
||||
|
||||
Reference in New Issue
Block a user