mirror of
https://github.com/cupcakearmy/docker-ddns-cloudflare.git
synced 2025-09-11 07:20:41 +00:00
1.3.0 (#6)
This commit is contained in:
22
src/ip.ts
Normal file
22
src/ip.ts
Normal 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
|
||||
}
|
Reference in New Issue
Block a user