update structure
This commit is contained in:
@ -12,21 +12,40 @@ export class SshConfig {
|
||||
/**
|
||||
* stores a config file
|
||||
*/
|
||||
storeConfig(dirPathArg:string){
|
||||
store(dirPathArg:string){
|
||||
let done = plugins.q.defer();
|
||||
let configArray:configObject[];
|
||||
let configString;
|
||||
for(let key in this.sshKeyArray){
|
||||
let sshKey = this.sshKeyArray[key];
|
||||
if(sshKey.host){
|
||||
configString = "Host " + sshKey.host + "\n" +
|
||||
" HostName " + sshKey.host + "\n" +
|
||||
" IdentityFile ~/.ssh/" + sshKey.host + "\n"
|
||||
}
|
||||
configArray.push({
|
||||
configString:configString,
|
||||
authorized: sshKey.authorized,
|
||||
sshKey: sshKey
|
||||
});
|
||||
}
|
||||
let configFile:string = "";
|
||||
for(let key in configArray){
|
||||
configFile = configFile + configArray[key].configString + "\n";
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(configFile,dirPathArg);
|
||||
return done.promise;
|
||||
}
|
||||
read(dirPathArg){
|
||||
let done = plugins.q.defer();
|
||||
let configArray:configObject[];
|
||||
|
||||
return done.promise;
|
||||
}
|
||||
readConfig
|
||||
};
|
||||
|
||||
let createConfigPath = () => {
|
||||
|
||||
}
|
||||
|
||||
export interface configObject {
|
||||
host:string;
|
||||
configString:string;
|
||||
authorized:boolean;
|
||||
sshKey:SshKey;
|
||||
};
|
||||
|
@ -7,7 +7,8 @@ import {SshConfig} from "./smartssh.classes.sshconfig";
|
||||
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
||||
path:string; // the path of the ssh directory
|
||||
private sshKeyArray:SshKey[];
|
||||
constructor(sshKeyArray:SshKey[],sshDirPathArg?:string){
|
||||
private sshConfig:SshConfig;
|
||||
constructor(sshKeyArray:SshKey[],sshConfig:SshConfig,sshDirPathArg?:string){
|
||||
this.sshKeyArray = sshKeyArray;
|
||||
if(sshDirPathArg){
|
||||
this.path = sshDirPathArg;
|
||||
@ -18,8 +19,8 @@ export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
||||
writeToDir(){ // syncs sshInstance to directory
|
||||
this.sshKeyArray.forEach((sshKeyArg) => {
|
||||
sshKeyArg.store(this.path);
|
||||
|
||||
});
|
||||
this.sshConfig.store(this.path);
|
||||
};
|
||||
readFromDir(){ // syncs sshInstance from directory
|
||||
|
||||
|
@ -15,7 +15,7 @@ export class SshInstance {
|
||||
optionsArg ? void(0) : optionsArg = {};
|
||||
this._sshKeyArray = [];
|
||||
this._sshConfig = new SshConfig(this._sshKeyArray);
|
||||
this._sshDir = new SshDir(this._sshKeyArray,optionsArg.sshDirPath);
|
||||
this._sshDir = new SshDir(this._sshKeyArray,this._sshConfig,optionsArg.sshDirPath);
|
||||
this._sshSync = optionsArg.sshSync;
|
||||
};
|
||||
|
||||
@ -101,5 +101,3 @@ export class SshInstance {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,7 +54,12 @@ export class SshKey {
|
||||
this._pubKey = plugins.base64.decode(publicKeyArg);
|
||||
}
|
||||
|
||||
|
||||
get authorized(){
|
||||
return this._authorized;
|
||||
}
|
||||
set authorized(authorizedArg:boolean){
|
||||
this._authorized = authorizedArg;
|
||||
}
|
||||
get type(){
|
||||
if(this._privKey && this._pubKey){
|
||||
return "duplex";
|
||||
|
Reference in New Issue
Block a user