This commit is contained in:
2022-10-20 15:18:57 +02:00
committed by GitHub
parent fb7416dbec
commit a1af82501c
15 changed files with 429 additions and 768 deletions

22
src/ip.ts Normal file
View File

@@ -0,0 +1,22 @@
import axios from 'axios'
import { Cache } from './cache.js'
import { Config } from './config.js'
export async function getCurrentIp(): Promise<string> {
const { data } = await axios({
url: Config.runner.resolver,
method: 'GET',
})
return data as string
}
export function checkIfUpdateIsRequired(newIP: string): boolean {
// Check if IP has changed.
const current = Cache.get('ip')
if (newIP !== current) {
Cache.set('ip', newIP)
return true
}
return false
}