Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions PiHoleShell/Public/FTLInformation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,66 @@ This API hook returns a collection of host infos.
break
}

finally {
if ($Sid) {
Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl
}
}
}

function Get-PiHoleLogWebserver {
<#
.SYNOPSIS
Get info about logs for webserver

#>
#Work In Progress
[CmdletBinding()]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "Password")]
param (
[Parameter(Mandatory = $true)]
[System.URI]$PiHoleServer,
[Parameter(Mandatory = $true)]
[string]$Password,
[int]$NextID,
[bool]$IgnoreSsl = $false,
[bool]$RawOutput = $false
)
try {
$Sid = Request-PiHoleAuth -PiHoleServer $PiHoleServer -Password $Password -IgnoreSsl $IgnoreSsl

if ($NextID) {
$Uri = "$($PiHoleServer.OriginalString)/api/logs/webserver?nextId=$NextId"

}
else {
$Uri = "$($PiHoleServer.OriginalString)/api/logs/webserver"
}

$Params = @{
Headers = @{sid = $($Sid) }
Uri = $Uri
Method = "Get"
SkipCertificateCheck = $IgnoreSsl
ContentType = "application/json"
}

$Response = Invoke-RestMethod @Params

if ($RawOutput) {
Write-Output $Response
}

else {
#$ObjectFinal = @()
}
}

catch {
Write-Error -Message $_.Exception.Message
break
}

finally {
if ($Sid) {
Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl
Expand Down
71 changes: 71 additions & 0 deletions PiHoleShell/Public/Teleporter.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
function Get-PiHoleTeleporterDownload {
<#
.SYNOPSIS
Get info about logs for webserver

#>
#Work In Progress
[CmdletBinding()]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "Password")]
param (
[Parameter(Mandatory = $true)]
[System.URI]$PiHoleServer,
[Parameter(Mandatory = $true)]
[string]$Password,
[Parameter(Mandatory = $true)]
[System.IO.DirectoryInfo]$FolderPath,
[Parameter(Mandatory = $true)]
[string]$FileName,
[bool]$IgnoreSsl = $false,
[bool]$RawOutput = $false
)
try {
$Sid = Request-PiHoleAuth -PiHoleServer $PiHoleServer -Password $Password -IgnoreSsl $IgnoreSsl

if (!(Test-Path -Path $FolderPath)) {
throw "$FolderPath does not exist!"
}
$FileName = "$FileName.tar.gz"
$OutFile = "$FolderPath\$FileName"
if (Test-Path -Path $OutFile) {
throw "$OutFile already exists!"
}

$Params = @{
Headers = @{sid = $($Sid) }
Uri = "$($PiHoleServer.OriginalString)/api/teleporter"
Method = "Get"
SkipCertificateCheck = $IgnoreSsl
ContentType = "application/json"
}

$Response = Invoke-RestMethod @Params -OutFile $OutFile

if ($RawOutput) {
Write-Output $Response
}

else {
$ObjectFinal = @()
$Object = [PSCustomObject]@{
FileName = $FileName
FilePath = $OutFile
RootFolder = $FolderPath
FileSizeKB = [math]::Ceiling((Get-Item $OutFile).Length / 1KB)
}
$ObjectFinal += $Object
Write-Output $ObjectFinal
}
}

catch {
Write-Error -Message $_.Exception.Message
break
}

finally {
if ($Sid) {
Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl
}
}
}