Refactor
This commit is contained in:
parent
baf7fd39e1
commit
0bd79eb3d0
|
@ -5,19 +5,15 @@ export class PaFirewall {
|
|||
|
||||
async mapUserIDToIP(username: string, ip: string, domain: string) {
|
||||
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(
|
||||
`https://${this.ip}/api/?type=user-id&key=${this.key}&cmd=${command}`,
|
||||
{
|
||||
method: 'POST'
|
||||
}
|
||||
)
|
||||
const response = await fetch(url, { method: 'POST' })
|
||||
|
||||
const data = await response.text()
|
||||
|
||||
const result = data.includes('status="success"')
|
||||
const success = data.includes('status="success"')
|
||||
|
||||
if (!result) {
|
||||
if (!success) {
|
||||
console.log(data)
|
||||
throw new Error('Failed to map user ID to IP')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user