Skip to content

Commit

Permalink
Merge pull request #25 from roberttoups/0.5.0
Browse files Browse the repository at this point in the history
0.5.0
  • Loading branch information
roberttoups authored Jun 28, 2021
2 parents eeca0a2 + 0bd42f6 commit 99a35cf
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pester.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Pester
on:
push:
branches: [development]
branches:
- "development"
- "master"
jobs:
test-windows:
runs-on: windows-latest
Expand Down
72 changes: 72 additions & 0 deletions Docs/Get-MyPublicIP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
external help file: IPv4Toolbox-help.xml
Module Name: IPv4Toolbox
online version: http://www.github.com/roberttoups/IPv4Toolbox
schema: 2.0.0
---

# Get-MyPublicIP

## SYNOPSIS
Returns the Public IPv4 Address of the client returned by a web API.

## SYNTAX

```
Get-MyPublicIP [[-Uri] <String>] [<CommonParameters>]
```

## DESCRIPTION
Returns the Public IPv4 Address of the client returned by a web API.

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------

```powershell
Get-MyPublicIP
8.8.8.8
```

### -------------------------- EXAMPLE 2 --------------------------

```powershell
Get-MyPublicIP -Uri 'http://icanhazip.com'
8.8.8.8
```

## PARAMETERS

### -Uri
This is the URI used to query the Public IPv4 Address.
Valid URIs are http://icanhazip.com, http://ident.me, http://ifconfig.me/ip, & http://ipinfo.io/ip.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: Http://ipinfo.io/ip
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
### System.String
## NOTES
This function depends on the traffic reaching the web based API not flowing through a proxy for most accurate results.
## RELATED LINKS
[http://www.github.com/roberttoups/IPv4Toolbox](http://www.github.com/roberttoups/IPv4Toolbox)
8 changes: 6 additions & 2 deletions Docs/IPv4Toolbox.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
Module Name: IPv4Toolbox
Module Guid: b1a4c4a0-f480-4831-a6e0-141487f746b4
Download Help Link: https://github.com/roberttoups/IPv4Toolbox
Help Version: 0.4.0
Download Help Link: https://raw.githubusercontent.com/roberttoups/IPv4Toolbox/master/en-US/IPv4Toolbox-help.xml
Help Version: 0.5.0
Locale: en-US
---

Expand All @@ -22,6 +22,10 @@ Converts an IPv4 Address or Subnet into Windows PTR Zone compatible domain name.

Find-IPv4Address will search a block of text for IPv4 Addresses and returns only the IPv4 Addresses found.

### [Get-MyPublicIP](Get-MyPublicIP.md)

Returns the Public IPv4 Address of the client returned by a web API.

### [Get-SubnetInformation](Get-SubnetInformation.md)

Returns the information regarding a subnet that an IPv4 Address exists and returns information regarding Subnet ID, Broadcast Address, Subnet Mask, Network Prefix, First IP Address, Last IP Address, Total Hosts, and AWS related information.
Expand Down
5 changes: 3 additions & 2 deletions IPv4Toolbox.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'IPv4Toolbox.psm1'

# Version number of this module.
ModuleVersion = '0.4.0'
ModuleVersion = '0.5.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -71,8 +71,9 @@
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'ConvertTo-InverseAddress'
'Get-SubnetInformation'
'Find-IPv4Address'
'Get-MyPublicIP'
'Get-SubnetInformation'
'Invoke-IPv4GeoLookup'
'Invoke-IPv4ListSort'
'Out-SubnetRange'
Expand Down
16 changes: 15 additions & 1 deletion Public/Find-IPv4Address.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,22 @@ function Find-IPv4Address {

process {
$RegularExpression = '^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$'
$SpaceOut = @(
','
';'
'-'
'#'
'%'
'|'
'='
'_'
'<'
'>'
)
$Text = $Text -replace '\n', ' '
$Text = $Text -replace ',', ' '
foreach($Spacer in $SpaceOut) {
$Text = $Text.Replace($Spacer, ' ')
}
$Data = $Text.Split(' ')
foreach($Word in $Data) {
while($Word -match '\W$') {
Expand Down
62 changes: 62 additions & 0 deletions Public/Get-MyPublicIP.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<#
.SYNOPSIS
Returns the Public IPv4 Address of the client returned by a web API.
.DESCRIPTION
Returns the Public IPv4 Address of the client returned by a web API.
.PARAMETER Uri
This is the URI used to query the Public IPv4 Address. Valid URIs are http://icanhazip.com, http://ident.me, http://ifconfig.me/ip, & http://ipinfo.io/ip.
.EXAMPLE
Get-MyPublicIP
8.8.8.8
.EXAMPLE
Get-MyPublicIP -Uri 'http://icanhazip.com'
8.8.8.8
.NOTES
This function depends on the traffic reaching the web based API not flowing through a proxy for most accurate results.
.LINK
http://www.github.com/roberttoups/IPv4Toolbox
#>
function Get-MyPublicIP {
[CmdletBinding()]
[OutputType([String])]
param (
# The thing you want the single string for.
[Parameter(
Position = 0,
Mandatory = $false,
HelpMessage = 'The URI of the API Service.'
)]
[ValidateSet(
'http://icanhazip.com',
'http://ident.me',
'http://ifconfig.me/ip',
'http://ipinfo.io/ip'
)]
[String]
$Uri = 'http://ipinfo.io/ip'
)
begin {}

process {
((Invoke-WebRequest -Uri $Uri).Content).Trim()
}

end {}
}
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ PackageManagement IPv4Toolbox {

Converts an IPv4 Address or Subnet into Windows PTR Zone compatible domain name.

### [Find-IPv4Address](Docs/Find-IPv4Address)
### [Find-IPv4Address](Docs/Find-IPv4Address.md)

Returns all valid IPv4 Address in a string.

### [Get-MyPublicIP](Docs/Get-MyPublicIP.md)

Returns the Public IPv4 Address of the client returned by a web API.

### [Get-SubnetInformation](Docs/Get-SubnetInformation.md)

Returns the information regarding a subnet that an IPv4 Address exists.
Expand Down Expand Up @@ -83,6 +87,6 @@ Determines if an IPv4 Address is in a private address space.

## License

IPv4Toolbox is provided under the [Apache license](LICENSE.md).
IPv4Toolbox is provided under the [Apache license](LICENSE).

Authored by Robert M. Toups, Jr.
10 changes: 9 additions & 1 deletion Tests/Find-IPv4Address.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ InModuleScope $ModuleName {
'172.18.0.1'
'4.2.2.1'
}

Context "Testing return by $FunctionName" {
$TestCase = @{
TestText = $TestText
Expand All @@ -46,6 +45,15 @@ InModuleScope $ModuleName {
Find-IPv4Address @ArgumentCollection |
Should -Be $ShouldBe
}
It "Return should be $($ShouldBe -join ',') from the pipeline" -TestCases $TestCase {
param(
$TestText,
$ShouldBe
)
$TestText |
Find-IPv4Address |
Should -Be $ShouldBe
}
}
}
}
9 changes: 4 additions & 5 deletions Tests/Manifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ if((Test-Path -Path $ModulePath) -eq $false) {
throw "Unable to locate $ModulePath"
}
$ManifestTest = Test-ModuleManifest -Path $ModulePath
$Author = 'Robert M. Toups, Jr.'
$TestObject = [PSCustomObject]@{
Name = 'IPv4Toolbox'
Guid = 'b1a4c4a0-f480-4831-a6e0-141487f746b4'
Author = $Author
Author = 'Robert M. Toups, Jr.'
CompanyName = 'Toups Design Bureau'
Copyright = "(c) $(Get-Date -Format 'yyyy') $Author, All rights reserved."
Copyright = '(c) 2021 Robert M. Toups, Jr., All rights reserved.'
Description = 'Module to assist in the manipulation of IPv4 Addresses and Subnets.'
Version = '0.4.0'
Version = '0.5.0'
ProjectUri = 'https://github.com/roberttoups/IPv4Toolbox'
IconUri = 'https://raw.githubusercontent.com/roberttoups/IPv4Toolbox/master/icons/Color-PSGallery.png'
LicenseUri = 'https://github.com/roberttoups/IPv4Toolbox/blob/master/LICENSE'
Expand Down Expand Up @@ -44,7 +43,7 @@ Describe "Manifest Test for $ModuleName" -Tag 'Manifest' {
CurrentItem = $CurrentTags
TestItem = $TestTags
}
It "The Manifest should have these tags $($TestTags -join ',')" -TestCases $TestCase {
It "The Manifest should have these tags $($TestTags -join ', ')" -TestCases $TestCase {
param(
$CurrentItem,
$TestItem
Expand Down
86 changes: 86 additions & 0 deletions en-US/IPv4Toolbox-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,92 @@
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>Get-MyPublicIP</command:name>
<command:verb>Get</command:verb>
<command:noun>MyPublicIP</command:noun>
<maml:description>
<maml:para>Returns the Public IPv4 Address of the client returned by a web API.</maml:para>
</maml:description>
</command:details>
<maml:description>
<maml:para>Returns the Public IPv4 Address of the client returned by a web API.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-MyPublicIP</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>Uri</maml:name>
<maml:description>
<maml:para>This is the URI used to query the Public IPv4 Address. Valid URIs are http://icanhazip.com, http://ident.me, http://ifconfig.me/ip, &amp; http://ipinfo.io/ip.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.String</command:parameterValue>
<dev:type>
<maml:name>System.String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Http://ipinfo.io/ip</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="1" aliases="none">
<maml:name>Uri</maml:name>
<maml:description>
<maml:para>This is the URI used to query the Public IPv4 Address. Valid URIs are http://icanhazip.com, http://ident.me, http://ifconfig.me/ip, &amp; http://ipinfo.io/ip.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.String</command:parameterValue>
<dev:type>
<maml:name>System.String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Http://ipinfo.io/ip</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes />
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.String</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:alertSet>
<maml:alert>
<maml:para>This function depends on the traffic reaching the web based API not flowing through a proxy for most accurate results.</maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>Get-MyPublicIP

8.8.8.8</dev:code>
<dev:remarks>
<maml:para></maml:para>
</dev:remarks>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code>Get-MyPublicIP -Uri 'http://icanhazip.com'

8.8.8.8</dev:code>
<dev:remarks>
<maml:para></maml:para>
</dev:remarks>
</command:example>
</command:examples>
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>http://www.github.com/roberttoups/IPv4Toolbox</maml:linkText>
<maml:uri>http://www.github.com/roberttoups/IPv4Toolbox</maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<command:details>
<command:name>Get-SubnetInformation</command:name>
Expand Down

0 comments on commit 99a35cf

Please sign in to comment.