Skip to content
Binary file modified PiHoleShell/PiHoleShell.psd1
Binary file not shown.
23 changes: 22 additions & 1 deletion PiHoleShell/PiHoleShell.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,25 @@ foreach ($File in $PublicFunctions) {

foreach ($File in $PrivateFunctions) {
. $File.FullName
}
}

Export-ModuleMember -Function @(
#Actions.ps1
'Update-PiHoleActionsGravity' `
#Authentication.ps1
'Remove-PiHoleCurrentAuthSession' , 'Get-PiHoleCurrentAuthSession', 'Remove-PiHoleAuthSession', `
#GroupManagement.ps1
'Get-PiHoleGroup', 'New-PiHoleGroup', 'Update-PiHoleGroup', 'Remove-PiHoleGroup', `
#DnsControl.ps1
'Get-PiHoleDnsBlockingStatus', 'Set-PiHoleDnsBlocking', `
#Config.ps1
'Get-PiHoleConfig', 'Get-PiHoleCurrentAuthSession', 'Remove-PiHoleAuthSession', `
#Padd.ps1
'Get-PiHolePadd', `
#Metrics.ps1
'Get-PiHoleStatsRecentBlocked', 'Get-PiHoleStatsQueryType', 'Get-PiHoleStatsTopDomain', 'Get-PiHoleStatsSummary', `
#ListManagement.ps1
'Get-PiHoleList', 'Search-PiHoleListDomain', 'Add-PiHoleList', 'Remove-PiHoleList', `
#FTLInformation.ps1
'Get-PiHoleInfoMessage', 'Get-PiHoleInfoHost'
)
57 changes: 57 additions & 0 deletions PiHoleShell/Public/Actions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
function Update-PiHoleActionsGravity {
<#
.SYNOPSIS
https://TODO

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

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

if ($PSCmdlet.ShouldProcess("Pi-Hole server at $PiHoleServer", "Update gravity actions")) {
$Response = Invoke-RestMethod @Params
}

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

else {
$ObjectFinal = @()
$Object = $null
if ($Object) {
$ObjectFinal += $Object
}
Write-Output $ObjectFinal
}
}

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

finally {
if ($Sid) {
Remove-PiHoleCurrentAuthSession -PiHoleServer $PiHoleServer -Sid $Sid -IgnoreSsl $IgnoreSsl
}
}
}
31 changes: 29 additions & 2 deletions PiHoleShell/Public/Config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,35 @@ https://TODO
Write-Output $Response
}
else {
# $ObjectFinal = @()
# Write-Output $ObjectFinal | Select-Object -Unique
$ObjectFinal = @()
$Dns = [PSCustomObject]@{
Upstreams = $Response.config.dns.upstreams
}

$Dhcp = [PSCustomObject]@{
Active = $Response.config.dhcp.active
Start = $Response.config.dhcp.start
End = $Response.config.dhcp.end
Hosts = $Response.config.dhcp.hosts
IgnoreUnknownClients = $Response.config.dhcp.ignoreUnknownClients
Ipv6 = $Response.config.dhcp.ipv6
LeaseTime = $Response.config.dhcp.leaseTime
Logging = $Response.config.dhcp.logging
MultiDNS = $Response.config.dhcp.multiDNS
Netmask = $Response.config.dhcp.netmask
RapidCommit = $Response.config.dhcp.rapidCommit
Router = $Response.config.dhcp.router
}

$Object = [PSCustomObject]@{
Dns = $Dns
Dhcp = $Dhcp
}

if ($Object) {
$ObjectFinal += $Object
}
Write-Output $ObjectFinal
}
}

Expand Down
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
Loading