From aa3e4a9ede6a63c4e15f8508a479c5ce7c3219d7 Mon Sep 17 00:00:00 2001 From: YI Date: Fri, 25 Oct 2024 15:18:47 +0800 Subject: [PATCH] add wezterm tls config --- dot_config/wezterm/wezterm.lua | 44 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/dot_config/wezterm/wezterm.lua b/dot_config/wezterm/wezterm.lua index c397254..19e11bf 100644 --- a/dot_config/wezterm/wezterm.lua +++ b/dot_config/wezterm/wezterm.lua @@ -39,9 +39,7 @@ end) -- Show which key table is active in the status area wezterm.on('update-right-status', function(window, pane) local name = window:active_key_table() - if name then - name = 'TABLE: ' .. name - end + if name then name = 'TABLE: ' .. name end window:set_right_status(name or '') end) @@ -49,13 +47,51 @@ local default_domain = 'SSHMUX:dev' local config = {} +config.tls_clients = {} + config.ssh_domains = wezterm.default_ssh_domains() for _, dom in ipairs(config.ssh_domains) do - wezterm.log_info('setting multiplexing to WezTerm for ' .. dom.name) + -- Default ssh domains are Posix, but we can override that later. dom.assume_shell = 'Posix' dom.local_echo_threshold_ms = 10 + + -- Create a tls client for each ssh domain. + -- The dom name here can start with SSH: or SSHMUX: + -- We remove the prefix here. + local server_name = dom.name:gsub('^SSH[MUX]*:', '') + local tls_name = server_name .. '.tls' + local tls_client_found = false + for _, tls in ipairs(config.tls_clients) do + if tls.name == tls_name then + tls_client_found = true + break + end + end + + -- If we have already set this name in the tls_config, then just skip + -- the rest of the loop. + if not tls_client_found then + local conf = { + name = tls_name, + remote_address = dom.remote_address .. ":4443", + bootstrap_via_ssh = server_name + } + wezterm.log_info('domain', dom) + wezterm.log_info('config', conf) + + -- Insert the config to config.tls_clients + config.tls_clients[#config.tls_clients + 1] = conf + end end +config.tls_servers = { + { + -- The host:port combination on which the server will listen + -- for connections + bind_address = ':4443' + } +} + config.color_scheme = scheme_for_appearance(get_appearance()) config.launch_menu = {