diff --git a/tachyon/files/usr/lib/components/updates.uc b/tachyon/files/usr/lib/components/updates.uc index 864ef03b..6e41ac70 100644 --- a/tachyon/files/usr/lib/components/updates.uc +++ b/tachyon/files/usr/lib/components/updates.uc @@ -1592,7 +1592,7 @@ function component_job_log_path(job_id) { } function component_job_output_path_from_state(path) { - path = as_string(path); + let output_path = as_string(path); if (length(path) >= 5 && substr(path, length(path) - 5) == ".json") return substr(path, 0, length(path) - 5) + ".out"; return path + ".out"; @@ -1862,7 +1862,7 @@ function component_action_worker(state_file, output_file, component, action) { // object, and a successful action was reported to the UI as "Failed to // execute" with the tail of a log as its message. let worker_env = component_worker_env(); - worker_env.UPDATES_JOB_LOG = output_file + ".log"; + worker_env.UPDATES_JOB_LOG = substr(output_file, 0, length(output_file) - 4) + ".log"; let command = command_env(worker_env) + " " + command_from_args([ "ucode", diff --git a/tachyon/files/usr/lib/server/service.uc b/tachyon/files/usr/lib/server/service.uc index f47c8c6f..0ea1e299 100644 --- a/tachyon/files/usr/lib/server/service.uc +++ b/tachyon/files/usr/lib/server/service.uc @@ -646,7 +646,7 @@ function server_effective_security_value(section, protocol) { if (security == "") security = default_security_value(protocol); - if (protocol == "shadowsocks" || protocol == "socks" || protocol == "mtproto" || protocol == "tailscale" || protocol == "json_inbound") + if (protocol == "shadowsocks" || protocol == "socks" || protocol == "mtproto" || protocol == "tailscale" || protocol == "json_inbound" || protocol == "awg") security = "none"; else if (protocol == "hysteria2") security = "tls"; @@ -899,7 +899,7 @@ function prepare_server_defaults(section) { let protocol = config_get(section, "protocol", "vless"); if (!(protocol == "shadowsocks" || protocol == "socks" || protocol == "vmess" || protocol == "vless" || protocol == "trojan" || protocol == "hysteria2" || protocol == "mtproto" || protocol == "tailscale" || - protocol == "json_inbound")) + protocol == "json_inbound" || protocol == "awg")) fatal("Server '" + section + "' has unsupported protocol '" + protocol + "'. Aborted."); server_default_set_option(section, "protocol", protocol); @@ -965,6 +965,38 @@ function prepare_server_defaults(section) { server_default_set_option(section, "vmess_alter_id", "0"); if (protocol == "shadowsocks") server_default_set_option(section, "shadowsocks_method", "aes-128-gcm"); + if (protocol == "awg") { + server_default_set_option(section, "listen_port", "51820"); + server_default_set_option(section, "awg_mtu", "1280"); + server_default_set_option(section, "awg_local_address", "10.0.0.1/24"); + server_default_set_option(section, "awg_jc", "4"); + server_default_set_option(section, "awg_jmin", "40"); + server_default_set_option(section, "awg_jmax", "70"); + server_default_set_option(section, "awg_s1", "0"); + server_default_set_option(section, "awg_s2", "0"); + server_default_set_option(section, "awg_s3", "0"); + server_default_set_option(section, "awg_s4", "0"); + server_default_set_option(section, "awg_h1", "1"); + server_default_set_option(section, "awg_h2", "2"); + server_default_set_option(section, "awg_h3", "3"); + server_default_set_option(section, "awg_h4", "4"); + server_default_set_option(section, "awg_keepalive", "25"); + if (uci_get(config_path(section, "awg_private_key")) == "") { + let data = output("sing-box generate wg-keypair 2>/dev/null"); + let priv = ""; + let pub = ""; + for (let line in split(data, "\n")) { + let m_priv = match(line, /^PrivateKey:\s*(.+)$/); + if (m_priv) priv = trim(m_priv[1]); + let m_pub = match(line, /^PublicKey:\s*(.+)$/); + if (m_pub) pub = trim(m_pub[1]); + } + if (priv != "" && pub != "") { + server_set_option(section, "awg_private_key", priv); + server_set_option(section, "awg_peer_public_key", pub); + } + } + } if (protocol == "tailscale") { let safe_name = safe_filename_string(section); server_default_set_option(section, "tailscale_control_url", "https://controlplane.tailscale.com"); diff --git a/tachyon/files/usr/lib/singbox/servers.uc b/tachyon/files/usr/lib/singbox/servers.uc index b7c21815..f5baee4a 100644 --- a/tachyon/files/usr/lib/singbox/servers.uc +++ b/tachyon/files/usr/lib/singbox/servers.uc @@ -86,7 +86,7 @@ function effective_security(section, protocol) { } if (protocol == "shadowsocks" || protocol == "socks" || protocol == "mtproto" || - protocol == "tailscale" || protocol == "json_inbound") + protocol == "tailscale" || protocol == "json_inbound" || protocol == "awg") return "none"; if (protocol == "hysteria2") return "tls"; @@ -236,6 +236,66 @@ function add_standard_inbound(config, section, protocol, tag_name) { maybe_string(inbound, "idle_timeout", option(section, "mtproto_idle_timeout", "5m")); maybe_string(inbound, "handshake_timeout", option(section, "mtproto_handshake_timeout", "10s")); } + else if (protocol == "awg") { + inbound.type = "wireguard"; + inbound.address = list_option(section, "awg_local_address"); + inbound.private_key = option(section, "awg_private_key", ""); + inbound.mtu = int_option(section, "awg_mtu", "1280"); + + let server_address = option(section, "awg_server_address", ""); + let server_port = int_option(section, "awg_server_port", "51820"); + let peer_public_key = option(section, "awg_peer_public_key", ""); + + inbound.peers = [{ + address: server_address, + port: server_port, + public_key: peer_public_key, + allowed_ips: option(section, "awg_allowed_ips", "0.0.0.0/0,::/0") + }]; + + let preshared_key = option(section, "awg_preshared_key", ""); + if (preshared_key != "") + inbound.peers[0].pre_shared_key = preshared_key; + + let keepalive = int_option(section, "awg_keepalive", "0"); + if (keepalive > 0) + inbound.peers[0].persistent_keepalive_interval = keepalive; + + let jc = int_option(section, "awg_jc", "4"); + let jmin = int_option(section, "awg_jmin", "40"); + let jmax = int_option(section, "awg_jmax", "70"); + let is_lx = trim(fs.readfile("/etc/tachyon/sing-box-variant") || "") == "lx"; + + let amnezia = { + jc: jc, + jmin: jmin, + jmax: jmax, + s1: int_option(section, "awg_s1", "0"), + s2: int_option(section, "awg_s2", "0"), + h1: int_option(section, "awg_h1", "1"), + h2: int_option(section, "awg_h2", "2"), + h3: int_option(section, "awg_h3", "3"), + h4: int_option(section, "awg_h4", "4"), + s3: int_option(section, "awg_s3", "0"), + s4: int_option(section, "awg_s4", "0") + }; + + if (is_lx) { + inbound.jc = amnezia.jc; + inbound.jmin = amnezia.jmin; + inbound.jmax = amnezia.jmax; + inbound.s1 = amnezia.s1; + inbound.s2 = amnezia.s2; + inbound.h1 = amnezia.h1; + inbound.h2 = amnezia.h2; + inbound.h3 = amnezia.h3; + inbound.h4 = amnezia.h4; + inbound.s3 = amnezia.s3; + inbound.s4 = amnezia.s4; + } else { + inbound.amnezia = amnezia; + } + } else { inbound.users = users(section, protocol); } diff --git a/uc.out b/uc.out new file mode 100644 index 00000000..9fce5152 Binary files /dev/null and b/uc.out differ