Skip to content

Commit

Permalink
add TLS-crypt config
Browse files Browse the repository at this point in the history
  • Loading branch information
kota65535 committed Sep 15, 2023
1 parent 41a9f48 commit 003e839
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 11 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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`);
Expand All @@ -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 ===========");
Expand Down
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -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 ===========");
Expand Down

0 comments on commit 003e839

Please sign in to comment.