Skip to content

Commit

Permalink
Try fix ci and ip nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Sep 4, 2024
1 parent 0213044 commit 7fdfcaf
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 145 deletions.
124 changes: 2 additions & 122 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domcloud-bridge",
"version": "0.55.0",
"version": "0.56.0",
"description": "Deployment runner for DOM Cloud",
"main": "app.js",
"engines": {
Expand All @@ -19,7 +19,6 @@
"license": "MIT",
"type": "module",
"dependencies": {
"axios": "^1.6.8",
"cli": "^1.0.1",
"dotenv": "^16.4.5",
"express": "^4.19.2",
Expand Down
23 changes: 13 additions & 10 deletions src/binaries/update.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import fs from "fs";
import { dirname } from "path";
import { fileURLToPath } from "url";
import request from "../request.js";
const __dirname = dirname(fileURLToPath(import.meta.url));

const pythonConstants = {
Expand Down Expand Up @@ -48,8 +48,7 @@ export const initUtils = async () => {
* @type {Record<string, string>}
*/
let javaVersionsMap = {};
await axios
.get("https://rvm_io.global.ssl.fastly.net/binaries/centos/9/x86_64/") // currently aarch64 have to rebuilt
await request("https://rvm_io.global.ssl.fastly.net/binaries/centos/9/x86_64/") // currently aarch64 have to rebuilt
.then((res) => {
// @ts-ignore
var matches = [
Expand All @@ -66,15 +65,21 @@ export const initUtils = async () => {
console.error("error fetching Ruby releases", err.message);
});

await axios.get(pythonConstants.latestTagUrl()).then((res) => {
await request(pythonConstants.latestTagUrl()).then((res) => {
res.data = JSON.parse(res.data)
if (res.data && res.data.tag) {
pythonConstants.tag = res.data.tag;
} else {
console.warn("unable get latest python tag");
}
});
await axios
.get(pythonConstants.index())
await request(pythonConstants.index(), {
headers: {
'user-agent': 'curl/7.81.0',
'Host': 'github.com',
'accept': '*/*',
}
})
.then((res) => {
// @ts-ignore
var matches = [
Expand All @@ -91,12 +96,10 @@ export const initUtils = async () => {
.catch((err) => {
console.error("error fetching Python releases", err.message);
});
await axios
.get("https://api.adoptium.net/v3/info/available_releases")
await request("https://api.adoptium.net/v3/info/available_releases")
.then(async (res) => {
for (const ver of res.data.available_releases) {
await axios
.get(
await request(
`https://api.adoptium.net/v3/assets/latest/${ver}/hotspot?architecture=${archLinux[arch]}&image_type=jdk&os=linux&vendor=eclipse`
)
.then((x) => {
Expand Down
17 changes: 12 additions & 5 deletions src/controllers/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import {
dirname
} from 'path';
import axios from 'axios';
import request from '../request.js';


/**
Expand Down Expand Up @@ -59,13 +59,19 @@ export async function runConfigInBackground(body, domain, sandbox, callback) {
const headers = {
'Content-Type': 'text/plain; charset=UTF-8',
};
/**
* @type {import('https').RequestOptions}
*/
const options = {
rejectUnauthorized: false, // can be bad if I forgotten to renew
family: 4, // some servers gateway ipv6 not working
};
let aborted = false;
const periodicSender = async () => {
if (chunkedLogData.length > 0) {
var chunkk = chunkedLogData;
const data = normalizeShellOutput(chunkedLogData);
chunkedLogData = ['[Chunked data...]\n'];

await curlPost(callback, normalizeShellOutput(chunkk), { headers })
request(callback, { data, headers, ...options })
.catch(e => {
console.error(e);
});
Expand All @@ -80,7 +86,8 @@ export async function runConfigInBackground(body, domain, sandbox, callback) {
write.on('end', () => {
// and finish message with full log
if (callback) {
curlPost(callback, trimPayload(normalizeShellOutput(fullLogData)), { headers })
const data = trimPayload(normalizeShellOutput(fullLogData));
request(callback, { data, headers, ...options })
.catch(e => {
console.error(e);
});
Expand Down
12 changes: 8 additions & 4 deletions src/executor/nginx.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ class NginxExecutor {
let sslconf = info.config.ssl || sslNames[info.ssl];
let httpconf = info.config.http || info.http;
if (sslconf !== "enforce" && sslconf !== "always") {
node._add('listen', info.ip);
node._add('listen', info.ip6);
node._add('listen', info.ip ? info.ip + ":80" : "80");
node._add('listen', (info.ip6 || '[::]') + ":80");
}
if (sslconf !== "off") {
node._add('listen', info.ip + ":443 ssl");
node._add('listen', info.ip6 + ":443 ssl");
node._add('listen', info.ip ? info.ip + ":443 ssl" : "443 ssl");
node._add('listen', (info.ip6 || '[::]') + ":443 ssl");
if (httpconf == 2) {
node._add('http2', "on");
}
Expand Down Expand Up @@ -283,6 +283,10 @@ class NginxExecutor {
let ip = ("" + x._value).split(" ")[0];
if (ip.endsWith(":443"))
ip = ip.slice(0, -4);
else if (ip.endsWith(":80"))
ip = ip.slice(0, -3);
else if (ip === "80" || ip === "443")
ip = "";
data[ip.startsWith("[") ? "ip6" : "ip"] = ip;
data.ssl |= x._value.includes("ssl") ? 2 : 1;
});
Expand Down
Loading

0 comments on commit 7fdfcaf

Please sign in to comment.