This commit is contained in:
Douglas Barone 2023-10-19 19:55:42 -04:00
parent baf7fd39e1
commit 0bd79eb3d0

View File

@ -5,19 +5,15 @@ export class PaFirewall {
async mapUserIDToIP(username: string, ip: string, domain: string) { async mapUserIDToIP(username: string, ip: string, domain: string) {
const command = this.createCommand(username, ip, domain) const command = this.createCommand(username, ip, domain)
const url = `https://${this.ip}/api/?type=user-id&key=${this.key}&cmd=${command}`
const response = await fetch( const response = await fetch(url, { method: 'POST' })
`https://${this.ip}/api/?type=user-id&key=${this.key}&cmd=${command}`,
{
method: 'POST'
}
)
const data = await response.text() const data = await response.text()
const result = data.includes('status="success"') const success = data.includes('status="success"')
if (!result) { if (!success) {
console.log(data) console.log(data)
throw new Error('Failed to map user ID to IP') throw new Error('Failed to map user ID to IP')
} }