From 62a3bd80492cc0140e881deae961f8c627b9aa32 Mon Sep 17 00:00:00 2001 From: John Sahhar Date: Sun, 5 Feb 2023 06:06:25 +0000 Subject: [PATCH 01/30] Add support for TLS servers --- Makefile | 8 ++++++++ cmd/serve.go | 27 ++++++++++++++++++++++++--- web/server.go | 8 +++++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5c0d72030..e01c1b92b 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,14 @@ GIT_COMMIT=$(shell git rev-parse --short HEAD) .PHONY: all all: fmt lint test build go.mod +# Build static assets +# This will create dist directory containing client's static files +.PHONY: static +static: + cd web/client + yarn + yarn build + .PHONY: build build: go generate ./... diff --git a/cmd/serve.go b/cmd/serve.go index f3679cc7e..0449e2e0b 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -2,6 +2,10 @@ package cmd import ( "fmt" + "log" + "net/http" + "os" + "github.com/gin-gonic/gin" "github.com/joho/godotenv" "github.com/sirupsen/logrus" @@ -11,14 +15,14 @@ import ( "github.com/sundowndev/phoneinfoga/v2/lib/remote" "github.com/sundowndev/phoneinfoga/v2/web" "github.com/sundowndev/phoneinfoga/v2/web/v2/api/handlers" - "log" - "net/http" - "os" ) type ServeCmdOptions struct { HttpPort int DisableClient bool + Domain string + KeyfilePath string + CertfilePath string DisabledScanners []string PluginPaths []string EnvFiles []string @@ -33,11 +37,19 @@ func init() { // Register flags cmd.PersistentFlags().IntVarP(&opts.HttpPort, "port", "p", 5000, "HTTP port") cmd.PersistentFlags().BoolVar(&opts.DisableClient, "no-client", false, "Disable web client (REST API only)") + cmd.PersistentFlags().StringVar(&opts.Domain, "domain", "", "Use a specific domain to host (with tls).") + cmd.PersistentFlags().StringVar(&opts.CertfilePath, "cert", "", "Path to certfile (will use default letsencrypt path for domain if none provided).") + cmd.PersistentFlags().StringVar(&opts.KeyfilePath, "key", "", "Path to keyfile (will use default letsencrypt path for domain if none provided).") cmd.PersistentFlags().StringArrayVarP(&opts.DisabledScanners, "disable", "D", []string{}, "Scanner to skip for the scans") cmd.PersistentFlags().StringArrayVar(&opts.PluginPaths, "plugin", []string{}, "Extra scanner plugin to use for the scans") cmd.PersistentFlags().StringSliceVar(&opts.EnvFiles, "env-file", []string{}, "Env files to parse environment variables from (looks for .env by default)") } +func fmtLetsEncrypt(sitename string) (string, string) { + return fmt.Sprintf("/etc/letsencrypt/live/%s/fullchain.pem", sitename), + fmt.Sprintf("/etc/letsencrypt/live/%s/privkey.pem", sitename) +} + func NewServeCmd(opts *ServeCmdOptions) *cobra.Command { return &cobra.Command{ Use: "serve", @@ -70,6 +82,15 @@ func NewServeCmd(opts *ServeCmdOptions) *cobra.Command { log.Fatal(err) } + if len(opts.Domain) != 0 { + if len(opts.CertfilePath) == 0 || len(opts.KeyfilePath) == 0 { + opts.CertfilePath, opts.KeyfilePath = fmtLetsEncrypt(opts.Domain) + } + if err := srv.ListenAndServeTLS(opts.Domain+":443", opts.CertfilePath, opts.KeyfilePath); err != nil && err != http.ErrServerClosed { + log.Fatalf("listen: %s\n", err) + } + } + addr := fmt.Sprintf(":%d", opts.HttpPort) fmt.Printf("Listening on %s\n", addr) if err := srv.ListenAndServe(addr); err != nil && err != http.ErrServerClosed { diff --git a/web/server.go b/web/server.go index 7bd4bb05f..f3a9d254a 100644 --- a/web/server.go +++ b/web/server.go @@ -1,11 +1,13 @@ // Package web includes code for the web server of PhoneInfoga +// //go:generate swag init -g ./server.go --parseDependency package web import ( + "net/http" + "github.com/gin-gonic/gin" v2 "github.com/sundowndev/phoneinfoga/v2/web/v2/api/server" - "net/http" ) // @title PhoneInfoga REST API @@ -69,6 +71,10 @@ func (s *Server) ListenAndServe(addr string) error { return s.router.Run(addr) } +func (s *Server) ListenAndServeTLS(addr string, certfile, keyfile string) error { + return s.router.RunTLS(addr, certfile, keyfile) +} + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.router.ServeHTTP(w, r) } From 97cc7c424af452f5551e4e08575e49b930583e10 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Tue, 17 Jan 2023 00:47:07 -0500 Subject: [PATCH 02/30] Fixed an issue with the install script failing on mac on the checksum verify step. --- support/scripts/install | 87 ++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 28 deletions(-) mode change 100644 => 100755 support/scripts/install diff --git a/support/scripts/install b/support/scripts/install old mode 100644 new mode 100755 index e6b6c0a10..6e8c80bcd --- a/support/scripts/install +++ b/support/scripts/install @@ -1,38 +1,69 @@ -#!/bin/bash +#! /bin/bash # Bash installation script for UNIX systems only # Use it : curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install | bash os="$(uname -s)_$(uname -m)" -if [ $os == "Linux_x86_64" ] || [ $os == "Linux_armv6" ] || [ $os == "Darwin_x86_64" ] || [ $os == "Darwin_arm64" ] || [ $os == "Linux_arm64" ] || [ $os == "Linux_i386" ]; then - echo "Installing PhoneInfoga" - phoneinfoga_version=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) - echo "Found version $phoneinfoga_version" - - echo "Downloading version $phoneinfoga_version..." - wget "https://github.com/sundowndev/phoneinfoga/releases/download/$phoneinfoga_version/phoneinfoga_$os.tar.gz" - - echo "Verifying checksum..." - curl -sSL "https://github.com/sundowndev/phoneinfoga/releases/download/$phoneinfoga_version/phoneinfoga_checksums.txt" -o phoneinfoga_SHA256SUMS - sha256sum --ignore-missing -c phoneinfoga_SHA256SUMS - [ $? -eq 0 ] || exit 1 - - tar xfv "phoneinfoga_$os.tar.gz" - [ $? -eq 0 ] || exit 1 - - # Clear downloaded assets - rm phoneinfoga_$os.tar.gz - rm phoneinfoga_SHA256SUMS - - echo "Installation completed successfully." - echo "Check the version : ./phoneinfoga version" - echo "You can now install the program globally : sudo mv ./phoneinfoga /usr/bin/phoneinfoga" +if [[ -z "${os}" ]]; then + echo "Error: Unable to determine system type." + exit 1 +fi + +SUPPORTED_OS_TYPES=( + "Linux_x86_64" + "Linux_armv6" + "Linux_arm64" + "Linux_i386" + "Darwin_x86_64" + "Darwin_arm64" +) + +if [[ "${SUPPORTED_OS_TYPES[*]}" =~ "${os}" ]]; then + echo "$os detected" +else + echo "Error: $os is not supported" + echo "Please check the releases page for a list of all supported systems. + https://github.com/sundowndev/phoneinfoga/releases" + echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" + exit 1 +fi + +echo "Installing PhoneInfoga" + +phoneinfoga_version=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) +echo "Found version $phoneinfoga_version" + +echo "Downloading version $phoneinfoga_version..." +wget "https://github.com/sundowndev/phoneinfoga/releases/download/$phoneinfoga_version/phoneinfoga_$os.tar.gz" + +echo "Verifying checksum..." +curl -sSL "https://github.com/sundowndev/phoneinfoga/releases/download/$phoneinfoga_version/phoneinfoga_checksums.txt" -o phoneinfoga_SHA256SUMS + +if [[ $(uname -s) == "Darwin" ]]; then + EXPECTED_SHA=$(grep -i "${os}" phoneinfoga_SHA256SUMS | awk '{print $1}') + DOWNLOAD_SHA=$(shasum -a 256 phoneinfoga_$os.tar.gz | awk '{print $1}') + + if [[ "${EXPECTED_SHA}" == "${DOWNLOAD_SHA}" ]]; then + echo "Checksum verified" + else + echo "Error: Checksum validation failed." + exit 1 + fi + else - echo "Your OS/Arch is not supported." - echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" - exit 1 + sha256sum --ignore-missing -c phoneinfoga_SHA256SUMS + [ $? -eq 0 ] || exit 1 fi -exit 0 +tar xfv "phoneinfoga_$os.tar.gz" +[ $? -eq 0 ] || exit 1 + +rm phoneinfoga_$os.tar.gz +rm phoneinfoga_SHA256SUMS + +echo "Installation completed successfully." +echo "Check the version : ./phoneinfoga version" +echo "You can now install the program globally : sudo mv ./phoneinfoga /usr/bin/phoneinfoga" +exit 0 \ No newline at end of file From 4d6a635c04e7bbba4b0b697305078d1e93ae3956 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Tue, 17 Jan 2023 00:59:32 -0500 Subject: [PATCH 03/30] Fixed no newline at end of file --- support/scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/scripts/install b/support/scripts/install index 6e8c80bcd..07782436e 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -66,4 +66,4 @@ echo "Installation completed successfully." echo "Check the version : ./phoneinfoga version" echo "You can now install the program globally : sudo mv ./phoneinfoga /usr/bin/phoneinfoga" -exit 0 \ No newline at end of file +exit 0 From 827e2c1f74208499728de6342b6ee5e814f6eb89 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Tue, 31 Jan 2023 21:19:12 -0500 Subject: [PATCH 04/30] refactor installer script to make it more robust and flexible. Adds optional arguments, a path to manual download if the automatic checks fail, and fallbacks to curl if wget is not installed. --- support/scripts/install | 264 +++++++++++++++++++++++++++++++--------- 1 file changed, 208 insertions(+), 56 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index 07782436e..b8070d0ce 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -3,67 +3,219 @@ # Bash installation script for UNIX systems only # Use it : curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install | bash -os="$(uname -s)_$(uname -m)" - -if [[ -z "${os}" ]]; then - echo "Error: Unable to determine system type." - exit 1 -fi - -SUPPORTED_OS_TYPES=( - "Linux_x86_64" - "Linux_armv6" - "Linux_arm64" - "Linux_i386" - "Darwin_x86_64" - "Darwin_arm64" -) - -if [[ "${SUPPORTED_OS_TYPES[*]}" =~ "${os}" ]]; then - echo "$os detected" -else - echo "Error: $os is not supported" - echo "Please check the releases page for a list of all supported systems. - https://github.com/sundowndev/phoneinfoga/releases" - echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" - exit 1 -fi - -echo "Installing PhoneInfoga" - -phoneinfoga_version=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) -echo "Found version $phoneinfoga_version" - -echo "Downloading version $phoneinfoga_version..." -wget "https://github.com/sundowndev/phoneinfoga/releases/download/$phoneinfoga_version/phoneinfoga_$os.tar.gz" - -echo "Verifying checksum..." -curl -sSL "https://github.com/sundowndev/phoneinfoga/releases/download/$phoneinfoga_version/phoneinfoga_checksums.txt" -o phoneinfoga_SHA256SUMS - -if [[ $(uname -s) == "Darwin" ]]; then - EXPECTED_SHA=$(grep -i "${os}" phoneinfoga_SHA256SUMS | awk '{print $1}') - DOWNLOAD_SHA=$(shasum -a 256 phoneinfoga_$os.tar.gz | awk '{print $1}') - - if [[ "${EXPECTED_SHA}" == "${DOWNLOAD_SHA}" ]]; then - echo "Checksum verified" - else - echo "Error: Checksum validation failed." +PHONEINFOGA_VERSION=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) + +AUTOMATIC=0 +SKIP_CHECKSUM=0 + +usage() { + + echo "PhoneInfoga Installer for version $PHONEINFOGA_VERSION" + echo + echo "DESCRIPTION: An installer script for downloading the latest release of PhoneInfoga. Without any arguments, $0 will detect your operating system and attempt to download the corresponding version of PhoneInfoga. Please submit an issue on GitHub if you encounter issues with this script." + echo + echo "USAGE: $0 [flag...] (-h|-s|-u)" + echo + echo " -h | --help Print this message and exit" + echo + echo " -s | --skip-checksum [Not Reccomended] Skip checksum validation" + echo " Only use this option if $0" + echo " is failing due to missing software." + echo + echo " -u | --unsupported Attempt to install on an unsupported OS." + echo " Useful when $0 is unable to detect" + echo " your OS automatically" + echo +} + + +validate_OS_type() { + + if [[ -z "${OS}" ]]; then + echo "ERROR: Unable to determine your system type." exit 1 fi +} + + +validate_supported_OS() { + + SUPPORTED_OS_TYPES=( + "Linux_x86_64" + "Linux_armv6" + "Linux_arm64" + "Linux_i386" + "Darwin_x86_64" + "Darwin_arm64" + ) + + if [[ "${SUPPORTED_OS_TYPES[*]}" =~ "${OS}" ]]; then + return 0 + else + echo "Error: $OS is not supported, installation will attempt to proceed manually." + echo + echo "Please check the releases page for a list of supported systems." + echo "https://github.com/sundowndev/phoneinfoga/releases" + echo + echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" + echo + AUTOMATIC=1 + return 1 + fi +} + + +validate_checksum() { + + local WGET_INSTALLED=false + which wget > /dev/null + [ $? -eq 1 ] || WGET_INSTALLED=true + + echo "Validating checksum ..." + if $WGET_INSTALLED; then + wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" + elif ! $WGET_INSTALLED; then + curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" + fi + + local SHA256SUM_INSTALLED=false + which sha256sum > /dev/null + [ $? -eq 1 ] || SHA256SUM_INSTALLED=true + + if $SHA256SUM_INSTALLED; then + sha256sum --ignore-missing -c phoneinfoga_checksums.txt + [ $? -eq 0 ] || exit 1 + elif ! $SHA256SUM_INSTALLED; then + shasum --ignore-missing -c phoneinfoga_checksums.txt + [ $? -eq 0 ] || exit 1 + fi + + rm phoneinfoga_checksums.txt +} + + +download_latest_release() { + + local WGET_INSTALLED=false + which wget > /dev/null + [ $? -eq 1 ] || local WGET_INSTALLED=true + + echo "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + + if $WGET_INSTALLED; then + wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + elif ! $WGET_INSTALLED; then + curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + fi +} + + +manual_download_latest_release() { -else - sha256sum --ignore-missing -c phoneinfoga_SHA256SUMS + ASSETS=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | jq --raw-output '.assets[] | .name' | grep --color=never tar.gz) + + local WGET_INSTALLED=false + which wget > /dev/null + [ $? -eq 1 ] || WGET_INSTALLED=true + + echo "Please select the version of PhoneInfoga that you need." + PS3="Enter a number: " + select OPT in $ASSETS; do + case $OPT in + *) + echo "trying https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + + if $WGET_INSTALLED; then + wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + elif ! $WGET_INSTALLED; then + curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + fi + + break + ;; + esac + done +} + + +unpack_and_cleanup() { + + local FILE=$(find . -name phoneinfoga_*.tar.gz) + + tar -xzf $FILE [ $? -eq 0 ] || exit 1 -fi -tar xfv "phoneinfoga_$os.tar.gz" -[ $? -eq 0 ] || exit 1 + echo "Cleaning up ..." + rm $FILE +} + + +main() { + + if [[ -z "$1" ]]; then + echo "Downloading PhoneInfoga version $PHONEINFOGA_VERSION" + else + while [[ "$1" == -* ]]; do + case "$1" in + + -h | --help) + usage + exit 0 + ;; + + -s | --skip-checksum) + SKIP_CHECKSUM=1 + ;; + + -u | --unsupported) + AUTOMATIC=1 + ;; + + *) + echo + echo "ERROR: Unrecognized command '$1', run '$0 --help' for help." + exit 1 + ;; + + esac + shift + done + fi + + if [[ $AUTOMATIC == 0 ]]; then + download_latest_release + elif [[ $AUTOMATIC == 1 ]]; then + manual_download_latest_release + else + echo "something bad happened" + exit 1 + fi + + if [[ $SKIP_CHECKSUM == 0 ]]; then + validate_checksum + elif [[ $SKIP_CHECKSUM == 1 ]]; then + echo + echo "WARNING: Skipping checksum validation." + echo "Please be sure to verify your download manually." + echo "You can find the checksum for your software version here" + echo + echo "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" + else + echo "something bad happened" + exit 1 + fi + + unpack_and_cleanup + + echo + echo "Installation completed successfully." + echo "To check the version installed: ./phoneinfoga version" + echo + echo "Add it to your path by running" + echo "'sudo mv ./phoneinfoga /usr/local/bin/phoneinfoga'" -rm phoneinfoga_$os.tar.gz -rm phoneinfoga_SHA256SUMS + exit 0 +} -echo "Installation completed successfully." -echo "Check the version : ./phoneinfoga version" -echo "You can now install the program globally : sudo mv ./phoneinfoga /usr/bin/phoneinfoga" -exit 0 +main "${@}" \ No newline at end of file From 0e7ddd8e696566d38ede674ed5820c7b45f51580 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Tue, 31 Jan 2023 21:30:38 -0500 Subject: [PATCH 05/30] fixed some typos --- support/scripts/install | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index b8070d0ce..cc4ff878f 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -3,9 +3,10 @@ # Bash installation script for UNIX systems only # Use it : curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install | bash +OS="$(uname -s)_$(uname -m)" PHONEINFOGA_VERSION=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) -AUTOMATIC=0 +AUTOMATIC= SKIP_CHECKSUM=0 usage() { @@ -50,7 +51,7 @@ validate_supported_OS() { ) if [[ "${SUPPORTED_OS_TYPES[*]}" =~ "${OS}" ]]; then - return 0 + AUTOMATIC=0 else echo "Error: $OS is not supported, installation will attempt to proceed manually." echo @@ -60,7 +61,6 @@ validate_supported_OS() { echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" echo AUTOMATIC=1 - return 1 fi } @@ -152,6 +152,8 @@ unpack_and_cleanup() { main() { + validate_supported_OS + if [[ -z "$1" ]]; then echo "Downloading PhoneInfoga version $PHONEINFOGA_VERSION" else @@ -218,4 +220,4 @@ main() { } -main "${@}" \ No newline at end of file +main "${@}" From 6f66cb4105bb7dfcce141f64439bc9c276ff2dd5 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Sun, 19 Feb 2023 22:30:59 -0500 Subject: [PATCH 06/30] squashed some bugs, further testing needed --- support/scripts/install | 136 +++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 50 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index cc4ff878f..22fbfbcf1 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -4,29 +4,58 @@ # Use it : curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install | bash OS="$(uname -s)_$(uname -m)" -PHONEINFOGA_VERSION=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) - +PHONEINFOGA_VERSION= AUTOMATIC= -SKIP_CHECKSUM=0 +SKIP_CHECKSUM=1 +CURL_INSTALLED=false +WGET_INSTALLED=false + +choose_wget_or_curl() { + + which curl > /dev/null + [ $? -eq 1 ] || CURL_INSTALLED=true + echo "CURL_INSTALLED=$CURL_INSTALLED" + + + if $CURL_INSTALLED; then + PHONEINFOGA_VERSION=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) + return + fi + + which wget > /dev/null + [ $? -eq 1 ] || WGET_INSTALLED=true + echo "WGET_INSTALLED=$WGET_INSTALLED" + + if $WGET_INSTALLED; then + PHONEINFOGA_VERSION=$(wget -q --output-document - https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) + return + fi + + echo "Error: You need to have either curl or wget installed to be able to use this script" + exit 1 + +} + + usage() { echo "PhoneInfoga Installer for version $PHONEINFOGA_VERSION" echo - echo "DESCRIPTION: An installer script for downloading the latest release of PhoneInfoga. Without any arguments, $0 will detect your operating system and attempt to download the corresponding version of PhoneInfoga. Please submit an issue on GitHub if you encounter issues with this script." + echo "DESCRIPTION: An installer script for downloading the latest release of PhoneInfoga. Without any arguments, $0 will detect your operating system and attempt to download the corresponding version of PhoneInfoga. Please submit an issue on GitHub if you encounter issues with this script." | fold -s echo - echo "USAGE: $0 [flag...] (-h|-s|-u)" + echo "USAGE: $0 [flag...] (-h|-m|-s)" echo echo " -h | --help Print this message and exit" echo + echo " -m | --manual Manually select version to download." + echo " Useful when $0 is unable to detect" + echo " your OS automatically" + echo echo " -s | --skip-checksum [Not Reccomended] Skip checksum validation" echo " Only use this option if $0" echo " is failing due to missing software." echo - echo " -u | --unsupported Attempt to install on an unsupported OS." - echo " Useful when $0 is unable to detect" - echo " your OS automatically" - echo } @@ -42,12 +71,18 @@ validate_OS_type() { validate_supported_OS() { SUPPORTED_OS_TYPES=( - "Linux_x86_64" - "Linux_armv6" + "Darwin_arm64" + "Darwin_x86_64" "Linux_arm64" + "Linux_armv6" + "Linux_armv7" "Linux_i386" - "Darwin_x86_64" - "Darwin_arm64" + "Linux_x86_64" + "Windows_arm64" + "Windows_armv6" + "Windows_armv7" + "Windows_i386" + "Windows_x86_64" ) if [[ "${SUPPORTED_OS_TYPES[*]}" =~ "${OS}" ]]; then @@ -67,15 +102,11 @@ validate_supported_OS() { validate_checksum() { - local WGET_INSTALLED=false - which wget > /dev/null - [ $? -eq 1 ] || WGET_INSTALLED=true - echo "Validating checksum ..." - if $WGET_INSTALLED; then - wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" - elif ! $WGET_INSTALLED; then + if $CURL_INSTALLED; then curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" + elif $WGET_INSTALLED; then + wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" fi local SHA256SUM_INSTALLED=false @@ -88,6 +119,8 @@ validate_checksum() { elif ! $SHA256SUM_INSTALLED; then shasum --ignore-missing -c phoneinfoga_checksums.txt [ $? -eq 0 ] || exit 1 + else + echo -e "Error: \033[1mshasum\033[0m or \033[1msha256sum\033[0m command not found. Please install either one of those programs to validate your checksum." | fold -s fi rm phoneinfoga_checksums.txt @@ -96,39 +129,45 @@ validate_checksum() { download_latest_release() { - local WGET_INSTALLED=false - which wget > /dev/null - [ $? -eq 1 ] || local WGET_INSTALLED=true + echo "Downloading PhoneInfoga Version $PHONEINFOGA_VERSION for $OS" - echo "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + if $CURL_INSTALLED; then + curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" - if $WGET_INSTALLED; then + elif $WGET_INSTALLED; then wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" - elif ! $WGET_INSTALLED; then - curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + fi } manual_download_latest_release() { - ASSETS=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | jq --raw-output '.assets[] | .name' | grep --color=never tar.gz) - - local WGET_INSTALLED=false - which wget > /dev/null - [ $? -eq 1 ] || WGET_INSTALLED=true + if $CURL_INSTALLED; then + ASSETS=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | jq --raw-output '.assets[] | .name' | grep --color=never .tar.gz) + elif $WGET_INSTALLED; then + ASSETS=$(wget -q --output-document - https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | jq --raw-output '.assets[] | .name' | grep --color=never .tar.gz) + fi - echo "Please select the version of PhoneInfoga that you need." + echo "Please select a version of PhoneInfoga to download." PS3="Enter a number: " select OPT in $ASSETS; do case $OPT in + + '') + echo "Error: Invalid option, please enter a number from the list." + ;; + *) - echo "trying https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + echo "Downloading $OPT version $PHONEINFOGA_VERSION" + echo "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" - if $WGET_INSTALLED; then - wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" - elif ! $WGET_INSTALLED; then + if $CURL_INSTALLED; then curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + + elif $WGET_INSTALLED; then + wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + fi break @@ -152,10 +191,12 @@ unpack_and_cleanup() { main() { + validate_OS_type validate_supported_OS + choose_wget_or_curl if [[ -z "$1" ]]; then - echo "Downloading PhoneInfoga version $PHONEINFOGA_VERSION" + echo else while [[ "$1" == -* ]]; do case "$1" in @@ -165,12 +206,12 @@ main() { exit 0 ;; - -s | --skip-checksum) - SKIP_CHECKSUM=1 + -m | --manual) + AUTOMATIC=1 ;; - -u | --unsupported) - AUTOMATIC=1 + -s | --skip-checksum) + SKIP_CHECKSUM=0 ;; *) @@ -193,18 +234,13 @@ main() { exit 1 fi - if [[ $SKIP_CHECKSUM == 0 ]]; then + if [[ $SKIP_CHECKSUM == 1 ]]; then validate_checksum - elif [[ $SKIP_CHECKSUM == 1 ]]; then + elif [[ $SKIP_CHECKSUM == 0 ]]; then echo - echo "WARNING: Skipping checksum validation." - echo "Please be sure to verify your download manually." - echo "You can find the checksum for your software version here" + echo "WARNING: Skipping checksum validation. Please be sure to verify your download manually. You can find the checksum for your software version here:" | fold -s echo echo "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_checksums.txt" - else - echo "something bad happened" - exit 1 fi unpack_and_cleanup From 2f64f4fa58994f965f4aa7b194d091135327ff68 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Sun, 19 Feb 2023 22:40:31 -0500 Subject: [PATCH 07/30] fixed a few typos, should be ready for review --- support/scripts/install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index 22fbfbcf1..4589a9181 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -10,12 +10,11 @@ SKIP_CHECKSUM=1 CURL_INSTALLED=false WGET_INSTALLED=false + choose_wget_or_curl() { which curl > /dev/null [ $? -eq 1 ] || CURL_INSTALLED=true - echo "CURL_INSTALLED=$CURL_INSTALLED" - if $CURL_INSTALLED; then PHONEINFOGA_VERSION=$(curl -s https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) @@ -24,7 +23,6 @@ choose_wget_or_curl() { which wget > /dev/null [ $? -eq 1 ] || WGET_INSTALLED=true - echo "WGET_INSTALLED=$WGET_INSTALLED" if $WGET_INSTALLED; then PHONEINFOGA_VERSION=$(wget -q --output-document - https://api.github.com/repos/sundowndev/phoneinfoga/releases/latest | grep tag_name | cut -d '"' -f 4) @@ -37,7 +35,6 @@ choose_wget_or_curl() { } - usage() { echo "PhoneInfoga Installer for version $PHONEINFOGA_VERSION" From 5cd121d7a7d7c069ea52f78f3759489649432d16 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Sun, 19 Feb 2023 22:43:06 -0500 Subject: [PATCH 08/30] removed one additional debug item. ready for review --- support/scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index 4589a9181..f5b8d9b8f 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -116,8 +116,6 @@ validate_checksum() { elif ! $SHA256SUM_INSTALLED; then shasum --ignore-missing -c phoneinfoga_checksums.txt [ $? -eq 0 ] || exit 1 - else - echo -e "Error: \033[1mshasum\033[0m or \033[1msha256sum\033[0m command not found. Please install either one of those programs to validate your checksum." | fold -s fi rm phoneinfoga_checksums.txt From 303055b5034ee404df1ca8d72cbc4b5b48184e30 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Tue, 28 Feb 2023 19:37:48 -0500 Subject: [PATCH 09/30] fix shellcheck SC2076 (warning): Remove quotes from right-hand side of =~ to match as a regex rather than literally. --- support/scripts/install | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index f5b8d9b8f..edd7fbf8b 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -82,18 +82,22 @@ validate_supported_OS() { "Windows_x86_64" ) - if [[ "${SUPPORTED_OS_TYPES[*]}" =~ "${OS}" ]]; then - AUTOMATIC=0 - else - echo "Error: $OS is not supported, installation will attempt to proceed manually." - echo - echo "Please check the releases page for a list of supported systems." - echo "https://github.com/sundowndev/phoneinfoga/releases" - echo - echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" - echo - AUTOMATIC=1 - fi + for OS_TYPE in "${SUPPORTED_OS_TYPES[@]}"; do + if [[ "$OS_TYPE" == "$OS" ]]; then + AUTOMATIC=0 + return + fi + done + + echo "Error: $OS is not supported, installation will attempt to proceed manually." + echo + echo "Please check the releases page for a list of supported systems." + echo "https://github.com/sundowndev/phoneinfoga/releases" + echo + echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" + echo + AUTOMATIC=1 + } From 4f3b8886d0c93fdaba7c6f1f38bb5e452070ca48 Mon Sep 17 00:00:00 2001 From: HudsonOnHere Date: Tue, 28 Feb 2023 19:44:46 -0500 Subject: [PATCH 10/30] fixed 2 shellcheck issues: 1. SC2155 (warning): Declare and assign separately to avoid masking return values. 2. SC2061 (warning): Quote the parameter to -name so the shell won't interpret it. --- support/scripts/install | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/support/scripts/install b/support/scripts/install index edd7fbf8b..c4714891d 100755 --- a/support/scripts/install +++ b/support/scripts/install @@ -97,7 +97,7 @@ validate_supported_OS() { echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" echo AUTOMATIC=1 - + } @@ -178,7 +178,8 @@ manual_download_latest_release() { unpack_and_cleanup() { - local FILE=$(find . -name phoneinfoga_*.tar.gz) + local FILE + FILE=$(find . -name "phoneinfoga_*.tar.gz") tar -xzf $FILE [ $? -eq 0 ] || exit 1 From a047b58439455d9984d095c7be5d96b59c9e2de2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 00:03:25 +0000 Subject: [PATCH 11/30] fix(deps): bump actions/setup-go from 3.2.0 to 3.5.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.2.0 to 3.5.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3.2.0...v3.5.0) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 305dc802b..29c886f93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v3.2.0 + uses: actions/setup-go@v3.5.0 with: go-version: 1.17.8 id: go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aabc5d311..97ea2fbf9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: node-version: 15.11.x - name: Set up Go - uses: actions/setup-go@v3.2.0 + uses: actions/setup-go@v3.5.0 with: go-version: 1.17.8 From 3f470846d567e89586c71e02919eb54dd412185a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 00:03:20 +0000 Subject: [PATCH 12/30] fix(deps): bump goreleaser/goreleaser-action from 4.1.1 to 4.2.0 Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 4.1.1 to 4.2.0. - [Release notes](https://github.com/goreleaser/goreleaser-action/releases) - [Commits](https://github.com/goreleaser/goreleaser-action/compare/v4.1.1...v4.2.0) --- updated-dependencies: - dependency-name: goreleaser/goreleaser-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97ea2fbf9..483eaae88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: run: make install-tools - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4.1.1 + uses: goreleaser/goreleaser-action@v4.2.0 with: version: v1.10.2 args: release --rm-dist From 353e98f552d5c23e7c1f74403a3cefedefb142c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 01:01:56 +0000 Subject: [PATCH 13/30] fix(deps): bump docker/login-action from 1.14.1 to 2.1.0 Bumps [docker/login-action](https://github.com/docker/login-action) from 1.14.1 to 2.1.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v1.14.1...v2.1.0) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dockerimage-next.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerimage-next.yml b/.github/workflows/dockerimage-next.yml index dbfef0c24..7bc1ba756 100644 --- a/.github/workflows/dockerimage-next.yml +++ b/.github/workflows/dockerimage-next.yml @@ -21,7 +21,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - uses: docker/login-action@v1.14.1 + uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 483eaae88..138b0eedf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - uses: docker/login-action@v1.14.1 + uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} From 5a2f44fbd8ccad6648c91fb5e331af11a0f92479 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 01:02:00 +0000 Subject: [PATCH 14/30] fix(deps): bump actions/setup-python from 4.3.1 to 4.5.0 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.3.1 to 4.5.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4.3.1...v4.5.0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 138b0eedf..a969a1c3f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: steps: - uses: actions/checkout@v3.0.0 - name: Set up Python 3.8 - uses: actions/setup-python@v4.3.1 + uses: actions/setup-python@v4.5.0 with: python-version: 3.8 From 6a69f5b7823c4b4f9538389814839ba39d9599b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Feb 2023 01:03:17 +0000 Subject: [PATCH 15/30] fix(deps): bump actions/checkout from 3.0.0 to 3.3.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.0.0...v3.3.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/client.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/dockerimage-next.yml | 2 +- .github/workflows/release.yml | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29c886f93..5687f78b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: go-version: 1.17.8 id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3.0.0 + uses: actions/checkout@v3.3.0 - name: Get dependencies run: | diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 1d595ea75..bf3f30cf2 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -15,7 +15,7 @@ jobs: matrix: node-version: [15.11.x] steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.3.0 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.6.0 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 525d5ddd9..3a0ee04c4 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.0.0 + uses: actions/checkout@v3.3.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dockerimage-next.yml b/.github/workflows/dockerimage-next.yml index 7bc1ba756..50bfbc295 100644 --- a/.github/workflows/dockerimage-next.yml +++ b/.github/workflows/dockerimage-next.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.3.0 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a969a1c3f..ec60bdf5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.0.0 + uses: actions/checkout@v3.3.0 - name: Unshallow run: git fetch --prune --unshallow @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.3.0 with: fetch-depth: 0 - name: Set up QEMU @@ -66,7 +66,7 @@ jobs: publish-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.3.0 - name: Set up Python 3.8 uses: actions/setup-python@v4.5.0 with: From 1d35c518407331a9ad2174f4886d67d928dce566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Wed, 1 Mar 2023 12:07:34 +0400 Subject: [PATCH 16/30] docs: install instructions --- docs/getting-started/install.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/getting-started/install.md b/docs/getting-started/install.md index a8d14a7b1..aa3f60862 100644 --- a/docs/getting-started/install.md +++ b/docs/getting-started/install.md @@ -16,7 +16,8 @@ You can also do it from the terminal (UNIX systems only) : 1. Download latest release in the current directory ``` -curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install | bash +# Add --help at the end of the command for a list of install options +bash <( curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install ) ``` 2. Install phoneinfoga From 719bc31dc230d44e15e8a716cfe59626e56ca743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Wed, 8 Mar 2023 11:43:22 +0400 Subject: [PATCH 17/30] docs: readme --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 8e1e97db7..3529ee93c 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@

DocumentationAPI documentation • - Demo instanceRelated blog post

@@ -36,13 +35,11 @@ PhoneInfoga is one of the most advanced tools to scan international phone numbers. It allows you to first gather basic information such as country, area, carrier and line type, then use various techniques to try to find the VoIP provider or identify the owner. It works with a collection of scanners that must be configured in order for the tool to be effective. PhoneInfoga doesn't automate everything, it's just there to help investigating on phone numbers. -![web client screenshot](./docs/images/screenshot.png) - ## Current status This project is stable and production-ready. -**About demo instance**: This is a test service. Kittens will die if you abuse it. +You can try out the web client or REST API on the demo instance. **This is a test service**. Kittens will die if you abuse it. Most of scanners are not configured so you won't get relevant results. ## Features From f6fcd89a177342890fd6546b87bec65ce1dab81b Mon Sep 17 00:00:00 2001 From: sundowndev Date: Tue, 14 Feb 2023 13:44:10 +0400 Subject: [PATCH 18/30] ci: create homebrew workflow --- .github/workflows/homebrew.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/homebrew.yml diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.yml new file mode 100644 index 000000000..fd63bca90 --- /dev/null +++ b/.github/workflows/homebrew.yml @@ -0,0 +1,12 @@ +name: Homebrew Bump Formula +on: + release: + types: [published] +jobs: + homebrew: + runs-on: macos-latest + steps: + - uses: dawidd6/action-homebrew-bump-formula@v3 + with: + token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} + formula: phoneinfoga From ae667a8ddfa94abc8b4b4239c9adc53b1cc2b32c Mon Sep 17 00:00:00 2001 From: sundowndev Date: Tue, 14 Feb 2023 13:45:11 +0400 Subject: [PATCH 19/30] chore: update makefile Move golangci-lint install command into install-tools task --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e01c1b92b..207a49681 100644 --- a/Makefile +++ b/Makefile @@ -56,14 +56,14 @@ clean: .PHONY: lint lint: - @which golangci-lint > /dev/null 2>&1 || (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $(GOBINPATH) v1.46.2) - golangci-lint run -v --timeout=10m + golangci-lint run -v --timeout=2m .PHONY: install-tools install-tools: $(GOINSTALL) gotest.tools/gotestsum@v1.6.3 $(GOINSTALL) github.com/vektra/mockery/v2@v2.8.0 $(GOINSTALL) github.com/swaggo/swag/cmd/swag@v1.7.0 + @which golangci-lint > /dev/null 2>&1 || (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $(GOBINPATH) v1.46.2) go.mod: FORCE $(GOMOD) tidy From 7e303f69a115dc9550f9b17803edfa3f60911994 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Fri, 10 Mar 2023 09:27:55 +0400 Subject: [PATCH 20/30] docs: add homebrew installation --- docs/getting-started/install.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/getting-started/install.md b/docs/getting-started/install.md index aa3f60862..585e265b0 100644 --- a/docs/getting-started/install.md +++ b/docs/getting-started/install.md @@ -13,14 +13,14 @@ Follow the instructions : You can also do it from the terminal (UNIX systems only) : -1. Download latest release in the current directory +1. Download the latest release in the current directory ``` # Add --help at the end of the command for a list of install options bash <( curl -sSL https://raw.githubusercontent.com/sundowndev/phoneinfoga/master/support/scripts/install ) ``` -2. Install phoneinfoga +2. Install it globally ``` sudo install ./phoneinfoga /usr/local/bin/phoneinfoga ``` @@ -32,7 +32,15 @@ sudo install ./phoneinfoga /usr/local/bin/phoneinfoga To ensure your system is supported, please check the output of `echo "$(uname -s)_$(uname -m)"` in your terminal and see if it's available on the [GitHub release page](https://github.com/sundowndev/phoneinfoga/releases). -## Using Docker +## Homebrew + +PhoneInfoga is now available on Homebrew. Homebrew is a free and open-source package management system for Mac OS X. Install the official phoneinfoga formula from the terminal. + +```shell +brew install phoneinfoga +``` + +## Docker !!! info If you want to use the beta channel, you can use the `next` tag, it's updated directly from the master branch. But in most cases we recommend using [`latest`, `v2` or `stable` tags](https://hub.docker.com/r/sundowndev/phoneinfoga/tags) to only get release updates. @@ -69,7 +77,7 @@ services: - "80:5000" ``` -### From the source code +### Build from source You can download the source code, then build the docker images From bc1e54ae1a95c44b37458e58280b6d2d865ba0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Fri, 3 Mar 2023 14:40:17 +0400 Subject: [PATCH 21/30] docs: contribute --- docs/contribute.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/contribute.md b/docs/contribute.md index c31fb56e8..e208998f1 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -13,26 +13,26 @@ This page describe the project structure and gives you a bit of context to start **Requirements :** -- Node.js >= v10.x +- Node.js v15.x - npm or yarn - Go >= 1.16 -- [swag](https://github.com/swaggo/swag) +- [swag](https://github.com/swaggo/swag) (included in `make install-tools` below) **Note:** if you're using npm, just replace `yarn ` by `npm run `. ```shell +# Install tools needed to build, creating mocks or running tests +$ make install-tools + # Build static assets # This will create dist directory containing client's static files $ (cd web/client && yarn && yarn build) -# Generate in-memory assets -# This will put content of dist directory in memory. It's usually needed to build but -# the design requires you to do it anyway. +# Generate in-memory assets, then build the project. +# This will put content of dist directory in a single binary file. +# It's needed to build but the design requires you to do it anyway. # This step is needed at each change if you're developing on the client. -$ go generate ./... - -# Build the whole project -$ go build -v . +$ make build ``` If you're developing, you don't need to build at each changes, you can compile then run with the `go run` command : From 6d556586475e79bf021a23a340b0918f10680f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Sun, 19 Mar 2023 14:45:29 +0400 Subject: [PATCH 22/30] docs: contribute --- docs/contribute.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/contribute.md b/docs/contribute.md index e208998f1..c0f0161be 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -13,10 +13,9 @@ This page describe the project structure and gives you a bit of context to start **Requirements :** -- Node.js v15.x +- Nodejs >= v15 - npm or yarn - Go >= 1.16 -- [swag](https://github.com/swaggo/swag) (included in `make install-tools` below) **Note:** if you're using npm, just replace `yarn ` by `npm run `. From 2820266b4a835dfe2381cede344d247a7821db0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 00:57:54 +0000 Subject: [PATCH 23/30] fix(deps): bump actions/checkout from 3.3.0 to 3.4.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.3.0...v3.4.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/client.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/dockerimage-next.yml | 2 +- .github/workflows/release.yml | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5687f78b9..693b7234f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: go-version: 1.17.8 id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v3.4.0 - name: Get dependencies run: | diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index bf3f30cf2..497c18e79 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -15,7 +15,7 @@ jobs: matrix: node-version: [15.11.x] steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v3.4.0 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.6.0 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3a0ee04c4..c1ef26c09 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v3.4.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dockerimage-next.yml b/.github/workflows/dockerimage-next.yml index 50bfbc295..7d0b90f9c 100644 --- a/.github/workflows/dockerimage-next.yml +++ b/.github/workflows/dockerimage-next.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v3.4.0 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec60bdf5d..3db91fef7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v3.4.0 - name: Unshallow run: git fetch --prune --unshallow @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v3.4.0 with: fetch-depth: 0 - name: Set up QEMU @@ -66,7 +66,7 @@ jobs: publish-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.3.0 + - uses: actions/checkout@v3.4.0 - name: Set up Python 3.8 uses: actions/setup-python@v4.5.0 with: From d32c5e090d10dfdae5e11e014c9297a0a55786a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl?= Date: Thu, 23 Mar 2023 13:01:01 +0400 Subject: [PATCH 24/30] ci: homebrew workflow --- .github/workflows/homebrew.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.yml index fd63bca90..dd5df4e6b 100644 --- a/.github/workflows/homebrew.yml +++ b/.github/workflows/homebrew.yml @@ -2,6 +2,7 @@ name: Homebrew Bump Formula on: release: types: [published] + workflow_dispatch: jobs: homebrew: runs-on: macos-latest From 7e968e47d8c426542d61873475deb22b40058bd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 01:00:30 +0000 Subject: [PATCH 25/30] fix(deps): bump actions/checkout from 3.4.0 to 3.5.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.4.0...v3.5.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/client.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/dockerimage-next.yml | 2 +- .github/workflows/release.yml | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 693b7234f..6708b6121 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: go-version: 1.17.8 id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3.4.0 + uses: actions/checkout@v3.5.0 - name: Get dependencies run: | diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 497c18e79..8d4e6f652 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -15,7 +15,7 @@ jobs: matrix: node-version: [15.11.x] steps: - - uses: actions/checkout@v3.4.0 + - uses: actions/checkout@v3.5.0 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.6.0 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c1ef26c09..a562f2b09 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.4.0 + uses: actions/checkout@v3.5.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dockerimage-next.yml b/.github/workflows/dockerimage-next.yml index 7d0b90f9c..7070fbd1e 100644 --- a/.github/workflows/dockerimage-next.yml +++ b/.github/workflows/dockerimage-next.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.4.0 + - uses: actions/checkout@v3.5.0 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3db91fef7..b960bfe00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.4.0 + uses: actions/checkout@v3.5.0 - name: Unshallow run: git fetch --prune --unshallow @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.4.0 + - uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Set up QEMU @@ -66,7 +66,7 @@ jobs: publish-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.4.0 + - uses: actions/checkout@v3.5.0 - name: Set up Python 3.8 uses: actions/setup-python@v4.5.0 with: From 0c3842e277bfcc5ad63e90802434b059376a1b09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 01:00:53 +0000 Subject: [PATCH 26/30] fix(deps): bump actions/setup-go from 3.5.0 to 4.0.0 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.5.0 to 4.0.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3.5.0...v4.0.0) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6708b6121..e1207ca8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v3.5.0 + uses: actions/setup-go@v4.0.0 with: go-version: 1.17.8 id: go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b960bfe00..f85470060 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: node-version: 15.11.x - name: Set up Go - uses: actions/setup-go@v3.5.0 + uses: actions/setup-go@v4.0.0 with: go-version: 1.17.8 From 700eb43c8e2b8537016596c939b2193d3d2d1bd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 00:57:08 +0000 Subject: [PATCH 27/30] fix(deps): bump actions/checkout from 3.5.0 to 3.5.2 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.5.0...v3.5.2) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- .github/workflows/client.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/dockerimage-next.yml | 2 +- .github/workflows/release.yml | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1207ca8d..0614fa359 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: go-version: 1.17.8 id: go - name: Check out code into the Go module directory - uses: actions/checkout@v3.5.0 + uses: actions/checkout@v3.5.2 - name: Get dependencies run: | diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 8d4e6f652..64d7a5da4 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -15,7 +15,7 @@ jobs: matrix: node-version: [15.11.x] steps: - - uses: actions/checkout@v3.5.0 + - uses: actions/checkout@v3.5.2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3.6.0 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a562f2b09..c8a196973 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.5.0 + uses: actions/checkout@v3.5.2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dockerimage-next.yml b/.github/workflows/dockerimage-next.yml index 7070fbd1e..c22598a35 100644 --- a/.github/workflows/dockerimage-next.yml +++ b/.github/workflows/dockerimage-next.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.5.0 + - uses: actions/checkout@v3.5.2 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f85470060..e8c8d575a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.5.0 + uses: actions/checkout@v3.5.2 - name: Unshallow run: git fetch --prune --unshallow @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest if: contains(toJson(github.event.commits), '[action]') == false steps: - - uses: actions/checkout@v3.5.0 + - uses: actions/checkout@v3.5.2 with: fetch-depth: 0 - name: Set up QEMU @@ -66,7 +66,7 @@ jobs: publish-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.0 + - uses: actions/checkout@v3.5.2 - name: Set up Python 3.8 uses: actions/setup-python@v4.5.0 with: From 892134e9616a142dc37ebc4781776a91ff8aa895 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 00:57:45 +0000 Subject: [PATCH 28/30] fix(deps): bump actions/setup-python from 4.5.0 to 4.6.0 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4.5.0...v4.6.0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8c8d575a..ddd5d1b1a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,7 +68,7 @@ jobs: steps: - uses: actions/checkout@v3.5.2 - name: Set up Python 3.8 - uses: actions/setup-python@v4.5.0 + uses: actions/setup-python@v4.6.0 with: python-version: 3.8 From 8969e7baa08df5c329c9c07f83f8e2b69f3a2dd1 Mon Sep 17 00:00:00 2001 From: Guillaume cornet Date: Tue, 18 Apr 2023 19:52:27 +0200 Subject: [PATCH 29/30] fix: colored text on windows --- cmd/root.go | 2 +- cmd/scan.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f7e242bac..be3050def 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -23,6 +23,6 @@ func Execute() { } func exitWithError(err error) { - fmt.Println(color.RedString(err.Error())) + fmt.Fprintf(color.Output, "%s\n", color.RedString(err.Error())) os.Exit(1) } diff --git a/cmd/scan.go b/cmd/scan.go index 3e006dcd5..b2bc32474 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -11,7 +11,6 @@ import ( "github.com/sundowndev/phoneinfoga/v2/lib/number" "github.com/sundowndev/phoneinfoga/v2/lib/output" "github.com/sundowndev/phoneinfoga/v2/lib/remote" - "os" ) type ScanCmdOptions struct { @@ -53,7 +52,7 @@ func NewScanCmd(opts *ScanCmdOptions) *cobra.Command { } func runScan(opts *ScanCmdOptions) { - fmt.Printf(color.WhiteString("Running scan for phone number %s...\n\n"), opts.Number) + fmt.Fprintf(color.Output, color.WhiteString("Running scan for phone number %s...\n\n"), opts.Number) if valid := number.IsValid(opts.Number); !valid { logrus.WithFields(map[string]interface{}{ @@ -83,7 +82,7 @@ func runScan(opts *ScanCmdOptions) { result, errs := remoteLibrary.Scan(num) - err = output.GetOutput(output.Console, os.Stdout).Write(result, errs) + err = output.GetOutput(output.Console, color.Output).Write(result, errs) if err != nil { exitWithError(err) } From a6725343e5f8758583ba02a53b20edea41cdb066 Mon Sep 17 00:00:00 2001 From: Guillaume cornet Date: Wed, 19 Apr 2023 14:29:11 +0200 Subject: [PATCH 30/30] fix: server logs output --- cmd/root.go | 2 +- web/v2/api/server/server.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index be3050def..cf3d1fa24 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -23,6 +23,6 @@ func Execute() { } func exitWithError(err error) { - fmt.Fprintf(color.Output, "%s\n", color.RedString(err.Error())) + fmt.Fprintf(color.Error, "%s\n", color.RedString(err.Error())) os.Exit(1) } diff --git a/web/v2/api/server/server.go b/web/v2/api/server/server.go index efbe87975..6cf616982 100644 --- a/web/v2/api/server/server.go +++ b/web/v2/api/server/server.go @@ -1,6 +1,7 @@ package server import ( + "github.com/fatih/color" "github.com/gin-gonic/gin" "github.com/sundowndev/phoneinfoga/v2/web/v2/api" "github.com/sundowndev/phoneinfoga/v2/web/v2/api/handlers" @@ -12,6 +13,8 @@ type Server struct { } func NewServer() *Server { + gin.DefaultWriter = color.Output + gin.DefaultErrorWriter = color.Error s := &Server{ router: gin.Default(), }