2020-03-09 19:22:15 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { sendAsync, sendSync } from "./dispatch_json.ts";
|
|
|
|
import { Transport } from "./net.ts";
|
|
|
|
|
|
|
|
export interface ConnectTLSRequest {
|
|
|
|
transport: Transport;
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
2020-03-10 12:08:58 -04:00
|
|
|
certFile?: string;
|
2020-03-09 19:22:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
interface ConnectTLSResponse {
|
|
|
|
rid: number;
|
|
|
|
localAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
|
|
|
transport: Transport;
|
|
|
|
};
|
|
|
|
remoteAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
|
|
|
transport: Transport;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function connectTLS(
|
|
|
|
args: ConnectTLSRequest
|
|
|
|
): Promise<ConnectTLSResponse> {
|
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;
|
|
|
|
transport: Transport;
|
|
|
|
};
|
|
|
|
remoteAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
|
|
|
transport: Transport;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export async 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;
|
|
|
|
transport: Transport;
|
|
|
|
certFile: string;
|
|
|
|
keyFile: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ListenTLSResponse {
|
|
|
|
rid: number;
|
|
|
|
localAddr: {
|
|
|
|
hostname: string;
|
|
|
|
port: number;
|
|
|
|
transport: Transport;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function listenTLS(args: ListenTLSRequest): ListenTLSResponse {
|
|
|
|
return sendSync("op_listen_tls", args);
|
|
|
|
}
|