2020-03-09 19:22:15 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-07-06 21:45:39 -04:00
|
|
|
|
2020-03-09 19:22:15 -04:00
|
|
|
import { sendAsync, sendSync } from "./dispatch_json.ts";
|
|
|
|
|
|
|
|
export interface ConnectTLSRequest {
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-10 12:08:58 -04:00
|
|
|
certFile?: string;
|
2020-03-09 19:22:15 -04:00
|
|
|
}
|
|
|
|
|
2020-04-18 11:21:20 -04:00
|
|
|
interface EstablishTLSResponse {
|
2020-03-09 19:22:15 -04:00
|
|
|
rid: number;
|
|
|
|
localAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
};
|
|
|
|
remoteAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-24 17:29:14 -04:00
|
|
|
export function connectTls(
|
2020-03-09 19:22:15 -04:00
|
|
|
args: ConnectTLSRequest
|
2020-04-18 11:21:20 -04:00
|
|
|
): Promise<EstablishTLSResponse> {
|
2020-03-16 05:22:16 -04:00
|
|
|
return sendAsync("op_connect_tls", args);
|
2020-03-09 19:22:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
interface AcceptTLSResponse {
|
|
|
|
rid: number;
|
|
|
|
localAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
};
|
|
|
|
remoteAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:38:34 -04:00
|
|
|
export function acceptTLS(rid: number): Promise<AcceptTLSResponse> {
|
2020-03-16 05:22:16 -04:00
|
|
|
return sendAsync("op_accept_tls", { rid });
|
2020-03-09 19:22:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ListenTLSRequest {
|
|
|
|
port: number;
|
|
|
|
hostname: string;
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
certFile: string;
|
|
|
|
keyFile: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ListenTLSResponse {
|
|
|
|
rid: number;
|
|
|
|
localAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-23 18:02:51 -04:00
|
|
|
transport: "tcp";
|
2020-03-09 19:22:15 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-24 17:29:14 -04:00
|
|
|
export function listenTls(args: ListenTLSRequest): ListenTLSResponse {
|
2020-03-09 19:22:15 -04:00
|
|
|
return sendSync("op_listen_tls", args);
|
|
|
|
}
|
2020-04-18 11:21:20 -04:00
|
|
|
|
|
|
|
export interface StartTLSRequest {
|
|
|
|
rid: number;
|
|
|
|
hostname: string;
|
|
|
|
certFile?: string;
|
|
|
|
}
|
|
|
|
|
2020-04-24 17:29:14 -04:00
|
|
|
export function startTls(args: StartTLSRequest): Promise<EstablishTLSResponse> {
|
2020-04-18 11:21:20 -04:00
|
|
|
return sendAsync("op_start_tls", args);
|
|
|
|
}
|