add smd authorize
This commit is contained in:
parent
69018aa52b
commit
2b3391da4e
4 changed files with 71 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ import 'package:oto_cli/oto/commands/proto/protobuf.dart';
|
|||
import 'package:oto_cli/oto/commands/util/json.dart';
|
||||
import 'package:oto_cli/oto/commands/util/print.dart';
|
||||
import 'package:oto_cli/oto/commands/util/set_value.dart';
|
||||
import 'package:oto_cli/oto/commands/util/smb_authorize.dart';
|
||||
import 'package:oto_cli/oto/commands/util/string_util.dart';
|
||||
import 'package:oto_cli/oto/commands/web/web.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
|
@ -100,7 +101,8 @@ enum CommandType {
|
|||
WebFile,
|
||||
ProcessPortUse,
|
||||
ProcessRun,
|
||||
ProcessKill
|
||||
ProcessKill,
|
||||
SMBAuth
|
||||
}
|
||||
|
||||
abstract class Command {
|
||||
|
|
@ -163,7 +165,8 @@ abstract class Command {
|
|||
CommandType.WebFile: () => WebFile(),
|
||||
CommandType.ProcessPortUse: () => ProcessPortUse(),
|
||||
CommandType.ProcessRun: () => ProcessRun(),
|
||||
CommandType.ProcessKill: () => ProcessKill()
|
||||
CommandType.ProcessKill: () => ProcessKill(),
|
||||
CommandType.SMBAuth: () => SMBAuth(),
|
||||
};
|
||||
|
||||
factory Command.byType(CommandType type) {
|
||||
|
|
|
|||
25
lib/oto/commands/util/smb_authorize.dart
Normal file
25
lib/oto/commands/util/smb_authorize.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:oto_cli/oto/commands/command.dart';
|
||||
import 'package:oto_cli/oto/data/command_data.dart';
|
||||
|
||||
class SMBAuth extends Command {
|
||||
Function? get error => null;
|
||||
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
var data = DataSMBAuthorize.fromJson(getParam(command));
|
||||
var process = await Process.run('cmd', [
|
||||
'/C',
|
||||
'net',
|
||||
'use',
|
||||
'\\\\${data.domain}',
|
||||
'/user:${data.id}',
|
||||
data.password
|
||||
]);
|
||||
print(process.stdout.toString());
|
||||
print(process.stderr.toString());
|
||||
|
||||
return complete(process.exitCode, command);
|
||||
}
|
||||
}
|
||||
|
|
@ -1024,3 +1024,18 @@ class DataProcessKill extends DataParam {
|
|||
@override
|
||||
Map<String, dynamic> toJson() => _$DataProcessKillToJson(this);
|
||||
}
|
||||
|
||||
//Smb Authorize
|
||||
@JsonSerializable()
|
||||
class DataSMBAuthorize extends DataParam {
|
||||
DataSMBAuthorize();
|
||||
|
||||
late String domain;
|
||||
late String id;
|
||||
late String password;
|
||||
|
||||
factory DataSMBAuthorize.fromJson(Map<String, dynamic> json) =>
|
||||
_$DataSMBAuthorizeFromJson(json);
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$DataSMBAuthorizeToJson(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ const _$CommandTypeEnumMap = {
|
|||
CommandType.ProcessPortUse: 'ProcessPortUse',
|
||||
CommandType.ProcessRun: 'ProcessRun',
|
||||
CommandType.ProcessKill: 'ProcessKill',
|
||||
CommandType.SMBAuth: 'SMBAuth',
|
||||
};
|
||||
|
||||
DataParam _$DataParamFromJson(Map<String, dynamic> json) => DataParam()
|
||||
|
|
@ -1737,3 +1738,28 @@ Map<String, dynamic> _$DataProcessKillToJson(DataProcessKill instance) =>
|
|||
'showPrint': instance.showPrint,
|
||||
'pid': instance.pid,
|
||||
};
|
||||
|
||||
DataSMBAuthorize _$DataSMBAuthorizeFromJson(Map<String, dynamic> json) =>
|
||||
DataSMBAuthorize()
|
||||
..workspace = json['workspace'] as String?
|
||||
..passExitCodes = (json['passExitCodes'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList()
|
||||
..setResult = json['setResult'] as String?
|
||||
..setExitCode = json['setExitCode'] as String?
|
||||
..showPrint = json['showPrint'] as bool?
|
||||
..domain = json['domain'] as String
|
||||
..id = json['id'] as String
|
||||
..password = json['password'] as String;
|
||||
|
||||
Map<String, dynamic> _$DataSMBAuthorizeToJson(DataSMBAuthorize instance) =>
|
||||
<String, dynamic>{
|
||||
'workspace': instance.workspace,
|
||||
'passExitCodes': instance.passExitCodes,
|
||||
'setResult': instance.setResult,
|
||||
'setExitCode': instance.setExitCode,
|
||||
'showPrint': instance.showPrint,
|
||||
'domain': instance.domain,
|
||||
'id': instance.id,
|
||||
'password': instance.password,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue