From cafddbf114ba833aa91702605e1c7ad616179f97 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 14 Mar 2024 00:05:57 +0100 Subject: [PATCH] init --- .gitattributes | 15 + .github/CODEOWNERS | 50 ++++ .github/dependabot.yml | 15 + .github/release.yml | 18 ++ .github/workflows/Process-PSModule.yml | 26 ++ .gitignore | 363 +------------------------ .vscode/extensions.json | 6 + .vscode/settings.json | 81 ++++++ LICENSE | 2 +- README.md | 53 +++- icon/icon.png | Bin 0 -> 5882 bytes src/PublicIP/PublicIP.psd1 | 20 ++ src/PublicIP/PublicIP.psm1 | 32 +++ src/PublicIP/private/common.ps1 | 4 + src/PublicIP/public/Get-PublicIP.ps1 | 23 ++ 15 files changed, 356 insertions(+), 352 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/release.yml create mode 100644 .github/workflows/Process-PSModule.yml create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 icon/icon.png create mode 100644 src/PublicIP/PublicIP.psd1 create mode 100644 src/PublicIP/PublicIP.psm1 create mode 100644 src/PublicIP/private/common.ps1 create mode 100644 src/PublicIP/public/Get-PublicIP.ps1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..96c2e0d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,15 @@ +# Needed for publishing of examples, build worker defaults to core.autocrlf=input. +* text eol=autocrlf + +*.mof text eol=crlf +*.sh text eol=lf +*.svg eol=lf + +# Ensure any exe files are treated as binary +*.exe binary +*.jpg binary +*.xl* binary +*.pfx binary +*.png binary +*.dll binary +*.so binary diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..134e9b5 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,50 @@ +# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +* @PSModule/module-maintainers + +# Order is important; the last matching pattern takes the most +# precedence. When someone opens a pull request that only +# modifies JS files, only @js-owner and not the global +# owner(s) will be requested for a review. +# *.js @js-owner + +# You can also use email addresses if you prefer. They'll be +# used to look up users just like we do for commit author +# emails. +# *.go docs@example.com + +# Teams can be specified as code owners as well. Teams should +# be identified in the format @org/team-name. Teams must have +# explicit write access to the repository. In this example, +# the octocats team in the octo-org organization owns all .txt files. +# *.txt @octo-org/octocats + +# In this example, @doctocat owns any files in the build/logs +# directory at the root of the repository and any of its +# subdirectories. +# /build/logs/ @doctocat + +# The `docs/*` pattern will match files like +# `docs/getting-started.md` but not further nested files like +# `docs/build-app/troubleshooting.md`. +# docs/* docs@example.com + +# In this example, @octocat owns any file in an apps directory +# anywhere in your repository. +# apps/ @octocat + +# In this example, @doctocat owns any file in the `/docs` +# directory in the root of your repository and any of its +# subdirectories. +# /docs/ @doctocat + +# In this example, @octocat owns any file in the `/apps` +# directory in the root of your repository except for the `/apps/github` +# subdirectory, as its owners are left empty. +# /apps/ @octocat +# /apps/github diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b92544a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions # See documentation for possible values + directory: / # Location of package manifests + schedule: + interval: weekly + - package-ecosystem: nuget # See documentation for possible values + directory: / # Location of package manifests + schedule: + interval: weekly diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..35c6ae8 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,18 @@ +# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes + +changelog: + exclude: + labels: + - NoRelease + categories: + - title: 🌟 Breaking Changes + labels: + - Major + - Breaking + - title: 🚀 New Features + labels: + - Minor + - Feature + - title: Other Changes + labels: + - '*' diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml new file mode 100644 index 0000000..b14321b --- /dev/null +++ b/.github/workflows/Process-PSModule.yml @@ -0,0 +1,26 @@ +name: Process-PSModule + +run-name: "Process-PSModule - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" + +on: + pull_request: + branches: + - main + types: + - closed + - opened + - reopened + - synchronize + - labeled + +concurrency: + group: ${{ github.workflow }} + +permissions: + contents: write + pull-requests: write + +jobs: + Process-PSModule: + uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v1 + secrets: inherit diff --git a/.gitignore b/.gitignore index dfcfd56..907bfea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,350 +1,13 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/* + +# The Powershell build outputs folder +outputs/* diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..038896b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "github.vscode-github-actions", + "ms-vscode.powershell" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e732ea1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,81 @@ +{ + "[json]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + }, + "[markdown]": { + "editor.defaultFormatter": "yzhang.markdown-all-in-one", + "editor.quickSuggestions": { + "comments": "off", + "other": "off", + "strings": "off" + }, + "editor.wordWrap": "off" + }, + "[powershell]": { + "editor.defaultFormatter": "ms-vscode.powershell", + "editor.wordSeparators": "`~!@#%^&*()=+[{]}\\|;:'\",.<>/?", + "files.encoding": "utf8bom" + }, + "[yaml]": { + "editor.defaultFormatter": "github.vscode-github-actions", + "editor.insertSpaces": true, + "editor.tabSize": 2, + }, + "[github-actions-workflow]": { + "editor.defaultFormatter": "github.vscode-github-actions", + "editor.insertSpaces": true, + "editor.tabSize": 2 + }, + "editor.rulers": [0, 150], + "powershell.codeFormatting.autoCorrectAliases": true, + "powershell.codeFormatting.newLineAfterCloseBrace": false, + "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline", + "powershell.codeFormatting.preset": "OTBS", + "powershell.codeFormatting.trimWhitespaceAroundPipe": true, + "powershell.codeFormatting.useConstantStrings": true, + "powershell.codeFormatting.useCorrectCasing": true, + "powershell.codeFormatting.whitespaceBetweenParameters": true, + "powershell.pester.codeLens": false, + "powershell.powerShellDefaultVersion": "PowerShell (x64)", + "powershell.scriptAnalysis.enable": true, + "todo-tree.general.tags": [ + "BUG", + "HACK", + "FIXME", + "TODO", + "DEBUG" + ], + "todo-tree.highlights.customHighlight": { + "TODO": { + "background": "#00ff00", + "foreground": "#ffffff", + "icon": "alert", + "iconColour": "#00ff00", + "type": "text-and-comment" + }, + "HACK": { + "background": "#ff0000", + "foreground": "#ffffff", + "icon": "alert", + "iconColour": "#ff0000", + "type": "text-and-comment" + }, + "FIXME": { + "background": "#ff0000", + "foreground": "#ffffff", + "icon": "alert", + "iconColour": "#ff0000", + "type": "text-and-comment" + }, + "BUG": { + "background": "#ff0000", + "foreground": "#ffffff", + "icon": "alert", + "iconColour": "#ff0000", + "type": "text-and-comment" + } + } +} diff --git a/LICENSE b/LICENSE index 3e7c40e..92f4384 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Marius Storhaug +Copyright (c) 2024 PSModule Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2e1e298..e1c740e 100644 --- a/README.md +++ b/README.md @@ -1 +1,52 @@ -# PublicIP \ No newline at end of file +# Fonts + +This is a PowerShell module for getting information about your public IP. +It uses the APIs of [IPInfo](https://ipinfo.io) and [MyIP](https://www.myip.com/) to get this data. + +## Prerequisites + +This module requires an internet connection to work. + +## Installation + +To install the module simply run the following command in a PowerShell terminal. + +```powershell +Install-PSResource -Name PublicIP +Import-Module -Name PublicIP +``` + +## Usage + +You can use this module to get info about your public IP. + +### List information about your public IP and ISP + +This command will information about your public IP and more information about your ISP. + +```powershell +Get-PublicIP +``` + +### List public IP using 'MyIP' API + +This command will get your public IP using the 'MyIP' API. + +```powershell +Get-PublicIP -Provider MyIP +``` + +## Contributing + +Coder or not, you can contribute to the project! We welcome all contributions. + +### For Users + +If you don't code, you still sit on valuable information that can make this project even better. If you experience that the +product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests. +Please see the issues tab on this project and submit a new issue that matches your needs. + +### For Developers + +If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information. +You can either help by picking up an existing issue or submit a new one if you have an idea for a new feature or improvement. diff --git a/icon/icon.png b/icon/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..be83fd5fd3914846c735d44415569b86c254ccad GIT binary patch literal 5882 zcmX9?dpy(c7oQBnHlr{aVJ<}&ks^v^LfrW&q;8wvw#Um3V=W$n3W~Y5d`9b?L81) zU`A8~0|8!KA&wTNpch|JQvd<>H?cJVfhyAk|DNXoXnvBVTL=gQXYM^*Emul?K_Ia- zE1ZebO|RLXVWCbJ9<(f$+?~;P`-E$RiMrEfL2^Mp>!nfVJpRSoLfK6*Mb}kIEx;!3 zV&V<~CO?Xf(oWk`M!60Q8b@Tky@skO)^r=&VJo{odrPC&CrYl>wToj|-e6B3mgJY^+ zADmA!fLi@l*gJuSUE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@ -0,0 +1,20 @@ +@{ + ModuleVersion = '0.0.1' + Description = 'PowerShell Module for Public IP' + HelpInfoURI = 'https://PSModule.github.io/PublicIP' + PrivateData = @{ + PSData = @{ + Tags = @( + 'PublicIP' + 'IP' + 'Public' + 'IPConfig' + 'Config' + ) + LicenseUri = 'https://github.com/PSModule/PublicIP/blob/main/LICENSE' + ProjectUri = 'https://github.com/PSModule/PublicIP' + IconUri = 'https://raw.githubusercontent.com/PSModule/PublicIP/main/icon/icon.png' + } + } +} + diff --git a/src/PublicIP/PublicIP.psm1 b/src/PublicIP/PublicIP.psm1 new file mode 100644 index 0000000..573c80d --- /dev/null +++ b/src/PublicIP/PublicIP.psm1 @@ -0,0 +1,32 @@ +[Cmdletbinding()] +param() + +Write-Verbose 'Importing subcomponents' +$Folders = 'classes', 'private', 'public' +# Import everything in these folders +Foreach ($Folder in $Folders) { + $Root = Join-Path -Path $PSScriptRoot -ChildPath $Folder + Write-Verbose "Processing folder: $Root" + if (Test-Path -Path $Root) { + Write-Verbose "Getting all files in $Root" + $Files = $null + $Files = Get-ChildItem -Path $Root -Include '*.ps1', '*.psm1' -Recurse + # dot source each file + foreach ($File in $Files) { + Write-Verbose "Importing $($File)" + Import-Module $File + Write-Verbose "Importing $($File): Done" + } + } +} + +$Param = @{ + Function = (Get-ChildItem -Path "$PSScriptRoot\public" -Include '*.ps1' -Recurse).BaseName + Variable = '*' + Cmdlet = '*' + Alias = '*' +} + +Write-Verbose 'Exporting module members' + +Export-ModuleMember @Param -Verbose diff --git a/src/PublicIP/private/common.ps1 b/src/PublicIP/private/common.ps1 new file mode 100644 index 0000000..a58fa50 --- /dev/null +++ b/src/PublicIP/private/common.ps1 @@ -0,0 +1,4 @@ +$script:providerMap = @{ + MyIP = 'https://api.myip.com/' + IPInfo = 'https://ipinfo.io/json' +} diff --git a/src/PublicIP/public/Get-PublicIP.ps1 b/src/PublicIP/public/Get-PublicIP.ps1 new file mode 100644 index 0000000..9d0b6b7 --- /dev/null +++ b/src/PublicIP/public/Get-PublicIP.ps1 @@ -0,0 +1,23 @@ +function Get-PublicIP { + <# + .SYNOPSIS + Gets your public IP address. + + .DESCRIPTION + Gets your public IP address. You can specify a provider to use by using the Provider parameter. + + .EXAMPLE + Get-PublicIP + + .EXAMPLE + Get-PublicIP -Provider MyIP + #> + param( + # The provider to use to get the public IP address. + [Parameter()] + [ValidateScript({ $providerMap.Keys })] + $Provider = 'IPInfo' + ) + + Invoke-RestMethod -Uri $providerMap[$Provider] +}