注册 登录
n/chit-chat · 1 个月前 · 已编辑 · 2774 次浏览
u/shf_huang铂金3 YEARS
n/chit-chatu/shf_huang 3 YEARS · 1 个月前

免费4H8G主机保活--instabox.sh

https://instabox.sh/

instabox.sh提供了4核8G的主机,但是30分钟空闲之后就会自动停止。
可以通过cf定时任务进行保活:
创建worker

选择hello world

直接创建后编辑代码,贴入代码后重新部署

const API_ORIGIN = 'https://api.instabox.sh';
const ATTEMPTS = 3;
const REQUEST_TIMEOUT_MS = 55_000;

// Dependencies are injectable so offline tests never contact the real machine.
export async function runKeepalive(env, {
fetchImpl = fetch,
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
} = {}) {
const key = env.INSTABOX_API_KEY;
const machineId = env.INSTABOX_MACHINE_ID;
if (typeof key !== 'string' || !/^ibk_[A-Za-z0-9_-]+$/.test(key) || key === 'ibk_REPLACE_ME') {
throw new Error('Configure the INSTABOX_API_KEY secret.');
}
if (typeof machineId !== 'string' || !/^m_[A-Za-z0-9_-]+$/.test(machineId)) {
throw new Error('Configure a valid INSTABOX_MACHINE_ID.');
}

let lastFailure = 'Request failed';
for (let attempt = 1; attempt <= ATTEMPTS; attempt++) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
let status;
let machine;
try {
const response = await fetchImpl(${API_ORIGIN}/v1/machines/${machineId}/wake, {
method: 'POST',
headers: { 'X-API-Key': key, Accept: 'application/json' },
redirect: 'manual',
signal: controller.signal,
});
status = response.status;
if (status === 200) {
machine = await response.json();
} else {
// Never log upstream response bodies, request headers or API keys.
await response.body?.cancel();
}
} catch {
// Do not propagate transport errors that might include request details.
lastFailure = 'Network, timeout or invalid JSON response';
status = undefined;
} finally {
clearTimeout(timeout);
}

if (status === 200) {
  if (machine?.id !== machineId || machine?.state !== 'running') {
    throw new Error('HTTP 200 did not confirm the expected machine is running.');
  }
  return { machineId, state: 'running', attempt };
}
if (status !== undefined) {
  lastFailure = `HTTP ${status}`;
  const retryable = status === 409 || status === 429 || status >= 500;
  if (!retryable) {
    throw new Error(`Wake rejected: HTTP ${status}. Check credentials, permissions, machine ID and account status.`);
  }
}
if (attempt < ATTEMPTS) await sleep(10_000 * attempt);

}
throw new Error(Wake failed after ${ATTEMPTS} attempts: ${lastFailure}.);
}

export default {
async scheduled(controller, env, ctx) {
// Await the job so errors are recorded as failed Cron invocations.
try {
const result = await runKeepalive(env);
console.log(JSON.stringify({ event: 'instabox_wake_ok', ...result }));
} catch (error) {
console.error(JSON.stringify({ event: 'instabox_wake_failed', message: error.message }));
throw error;
}
},
async fetch() {
// HTTP requests cannot trigger a wake or inspect secrets.
return new Response('Not found', { status: 404 });
},
};

添加变量
INSTABOX_API_KEY:

INSTABOX_MACHINE_ID

添加定时任务:

如果主机不知道用来做什么的话,可以搭建节点:
vless://7c5f288e-99c9-458d-b1c2-61be58f27f02@18081-agqurgqeoftfugqprha6jrp7je.instabox.tech:443?encryption=none&security=tls&sni=18081-agqurgqeoftfugqprha6jrp7je.instabox.tech&fp=chrome&insecure=0&allowInsecure=0&type=ws&host=18081-agqurgqeoftfugqprha6jrp7je.instabox.tech&path=%2FS-M5-4aSDFJ-DtpgVEJ_lgeeBFs#Instabox-test

10月23号官方加了8小时到期限制

通过实测cf保活可以自动唤醒机器

god:在本机做保活
test:在cf做保活

183
81
登录后参与讨论。

81 条回复

排序
  1. princelife 白银 1 个月前 #2

    这个容器好用吗

    1
  2. shf_huang 铂金 楼主 3 YEARS 1 个月前 #3
    回复 @princelife:这个容器好用吗
    0
  3. DaPeng 白银 1 个月前 #4

    已申请,等待反馈邀请码

    0
  4. Melody 白银 1 个月前 #5

    到底有没有人获得了邀请码的?Google账号一个都没有收到

    0
  5. shf_huang 铂金 楼主 3 YEARS 1 个月前 #6
    回复 @Melody:到底有没有人获得了邀请码的?Google账号一个都没有收到

    不清楚,反正我半天左右就收到了

    0
  6. nyoung 👑 黄金 3 YEARS 1 个月前 #7

    搞了个3X-UI,还行

    0
  7. uixiayu 白银 1 个月前 #8
    回复 @shf_huang:我尝试部署了一个newapi:https://3000-agqurgqeoftfugqprha6jrp7je.insta…

    他还提供自带的公网链接吗

    0
  8. shf_huang 铂金 楼主 3 YEARS 1 个月前 #9
    回复 @uixiayu:他还提供自带的公网链接吗

    是的

    0
  9. uixiayu 白银 1 个月前 #10
    回复 @shf_huang:是的

    很心动啊,就是给这么大的福利,感觉有猫腻,不敢把自己的东西搬上去

    0
  10. shf_huang 铂金 楼主 3 YEARS 1 个月前 #11
    回复 @uixiayu:很心动啊,就是给这么大的福利,感觉有猫腻,不敢把自己的东西搬上去

    放点无关紧要的东西就好,当作玩具来玩

    0
  11. fxz 黄金 3 YEARS 1 个月前 #12
    回复 @Melody:到底有没有人获得了邀请码的?Google账号一个都没有收到

    感觉很随机,同一天申请的有人当天就出来,我等了3天,我还以为我是qq邮箱申请失败了呢

    0
  12. fxz 黄金 3 YEARS 1 个月前 #13
    回复 @uixiayu:很心动啊,就是给这么大的福利,感觉有猫腻,不敢把自己的东西搬上去

    挺一般的,放上去了网页游戏 ,多点了几下 ,就提示

    Too many connections. Try again shortly.
    

    当个玩具还行

    0
  13. Arvin_Leung 🚗 荣耀 Solved 2 1 个月前 #14

    感谢分享教程,我还在等,不知道是不是太多人给筛选了。

    0
  14. seeq 白银 3 YEARS 1 个月前 #15

    学习 😁

    0
  15. azhaoyihao 荣耀 水王 1 个月前 #16

    太棒了 收藏起来

    0
  16. azhaoyihao 荣耀 水王 1 个月前 #17
    回复 @Melody:到底有没有人获得了邀请码的?Google账号一个都没有收到

    我的两天才收到邀请码 听说有的人刚申请 邀请码几分钟就来了

    0
  17. Melody 白银 1 个月前 #18
    回复 @Melody:到底有没有人获得了邀请码的?Google账号一个都没有收到

    已经快第四天了。。

    0
  18. Splatoon 白银 1 个月前 #19

    直接用 UptimeRobot 做健康检查不就行了吗

    0
  19. macna40 白银 1 个月前 #20

    卡住了。。

    0
  20. okfree 白银 1 个月前 #21

    搞了一个不会用 一直放着

    0
  21. kacey 青铜 1 个月前 #22

    感谢分享。

    0
  22. suyongkang 钻石 2 YEARS 1 个月前 #23

    你这个保活有点麻烦了hh

    0
  23. shf_huang 铂金 楼主 3 YEARS 1 个月前 #24
    回复 @suyongkang:你这个保活有点麻烦了hh

    有个简单的,把主机的apikey扔给ai,告诉它直接帮你做保活 :xhj001:

    0
  24. Rison 钻石 3 YEARS 1 个月前 #25

    搞了一个,还不知道搞点啥呢

    0
  25. shf_huang 铂金 楼主 3 YEARS 1 个月前 #26
    这条回复已被版主删除
  26. dwad 白银 2 YEARS 1 个月前 #27

    保活确实麻烦的很,开了没一会就挂了

    0
  27. wxk 💯 钻石 1 个月前 #28

    不错,等下试试

    0
  28. ketto 🔥 铂金 3 YEARS 1 个月前 #29

    已申请差不多两天了,还没有收到邀请码

    0
  29. mitutu 白银 3 YEARS 1 个月前 #30

    谢谢分享,我等收到邀请码后试试

    0