diff --git a/action.yml b/action.yml index ce3e8d7..a82408a 100644 --- a/action.yml +++ b/action.yml @@ -14,7 +14,10 @@ inputs: description: "Password" required: false tls_auth_key: - description: "Pre-shared secret for TLS-auth HMAC signature" + description: "TLS-auth pre-shared group key" + required: false + tls_crypt_key: + description: "TLS-crypt pre-shared group key" required: false client_key: description: "Local peer's private key" diff --git a/dist/index.js b/dist/index.js index 9bfb4c7..68998d1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2007,8 +2007,12 @@ class Tail extends events.EventEmitter { */ getPositionAtNthLine(nLines) { const { size } = fs.statSync(this.filename); - const fd = fs.openSync(this.filename, 'r'); + if (size === 0) { + return 0; + } + + const fd = fs.openSync(this.filename, 'r'); // Start from the end of the file and work backwards in specific chunks let currentReadPosition = size; const chunkSizeBytes = Math.min(1024, size); @@ -3172,6 +3176,7 @@ const run = (callback) => { const password = core.getInput("password"); const clientKey = core.getInput("client_key"); const tlsAuthKey = core.getInput("tls_auth_key"); + const tlsCryptKey = core.getInput("tls_crypt_key"); if (!fs.existsSync(configFile)) { throw new Error(`config file '${configFile}' not found`); @@ -3198,6 +3203,11 @@ const run = (callback) => { fs.writeFileSync("ta.key", tlsAuthKey, { mode: 0o600 }); } + if (tlsCryptKey) { + fs.appendFileSync(configFile, "tls-crypt ta.key 1\n"); + fs.writeFileSync("ta.key", tlsCryptKey, { mode: 0o600 }); + } + core.info("========== begin configuration =========="); core.info(fs.readFileSync(configFile, "utf8")); core.info("=========== end configuration ==========="); diff --git a/src/main.js b/src/main.js index c5c90dc..d3bfa93 100644 --- a/src/main.js +++ b/src/main.js @@ -9,6 +9,7 @@ const run = (callback) => { const password = core.getInput("password"); const clientKey = core.getInput("client_key"); const tlsAuthKey = core.getInput("tls_auth_key"); + const tlsCryptKey = core.getInput("tls_crypt_key"); if (!fs.existsSync(configFile)) { throw new Error(`config file '${configFile}' not found`); @@ -35,6 +36,11 @@ const run = (callback) => { fs.writeFileSync("ta.key", tlsAuthKey, { mode: 0o600 }); } + if (tlsCryptKey) { + fs.appendFileSync(configFile, "tls-crypt ta.key 1\n"); + fs.writeFileSync("ta.key", tlsCryptKey, { mode: 0o600 }); + } + core.info("========== begin configuration =========="); core.info(fs.readFileSync(configFile, "utf8")); core.info("=========== end configuration ===========");