-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Client.ts
112 lines (97 loc) · 2.04 KB
/
Client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// deno-lint-ignore-file no-unused-vars
/**
* The options for the client.
*/
export interface ClientOptions {
/**
* The hostname or IP address of the server.
*/
hostname?: string;
/**
* The port number of the server.
*/
port?: number;
/**
* The username to authenticate as.
*/
username?: string;
/**
* The password to use for authentication.
*/
password?: string;
/**
* The private key to use for authentication.
*/
privateKey?: string;
/**
* The passphrase to use for decrypting the private key.
*/
passphrase?: string;
}
/**
* The base SSH client class for connecting to the server.
* Each instance of this class represents a single connection to the server.
*/
export class Client {
#connection: Deno.TcpConn | null;
#port: number;
#hostname: string;
#username: string;
isConnected: boolean;
constructor({
hostname = "127.0.0.1",
port = 22,
username = "root",
}: ClientOptions = {}) {
this.#connection = null;
this.isConnected = false;
this.#port = port;
this.#hostname = hostname;
this.#username = username;
}
/**
* Connect to the server.
*/
async connect() {
this.#connection = await Deno.connect({
port: this.#port,
hostname: this.#hostname,
});
// // if successful:
this.isConnected = true;
}
/**
* Disconnect from the server.
*/
disconnect() {
}
/**
* Get a directory listing. If a path is given, the listing will start from that path.
*/
async getDirectory(path?: string) {
}
/**
* Get a file. If a path is given, the file will be retrieved from that path.
*/
async getFile(path?: string) {
}
/**
* Put a directory. If a path is given, the directory will be put to that path.
*/
async putDirectory(path?: string) {
}
/**
* Put a file. If a path is given, the file will be put to that path.
*/
async putFile(path?: string) {
}
/**
* Run a command on the server.
*/
async run(command: string, {
cwd,
}: {
cwd?: string;
} = {}) {
}
}