diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 305dc802b..0614fa359 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,12 +14,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v3.2.0 + uses: actions/setup-go@v4.0.0 with: 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.5.2 - name: Get dependencies run: | diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 1d595ea75..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.0.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 525d5ddd9..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.0.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 dbfef0c24..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.0.0 + - uses: actions/checkout@v3.5.2 with: fetch-depth: 0 @@ -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/homebrew.yml b/.github/workflows/homebrew.yml new file mode 100644 index 000000000..dd5df4e6b --- /dev/null +++ b/.github/workflows/homebrew.yml @@ -0,0 +1,13 @@ +name: Homebrew Bump Formula +on: + release: + types: [published] + workflow_dispatch: +jobs: + homebrew: + runs-on: macos-latest + steps: + - uses: dawidd6/action-homebrew-bump-formula@v3 + with: + token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} + formula: phoneinfoga diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aabc5d311..ddd5d1b1a 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.5.2 - name: Unshallow run: git fetch --prune --unshallow @@ -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@v4.0.0 with: go-version: 1.17.8 @@ -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 @@ -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.5.2 with: fetch-depth: 0 - name: Set up QEMU @@ -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 }} @@ -66,9 +66,9 @@ jobs: publish-docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.0.0 + - uses: actions/checkout@v3.5.2 - name: Set up Python 3.8 - uses: actions/setup-python@v4.3.1 + uses: actions/setup-python@v4.6.0 with: python-version: 3.8 diff --git a/Makefile b/Makefile index 5c0d72030..207a49681 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 ./... @@ -48,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 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 diff --git a/cmd/root.go b/cmd/root.go index f7e242bac..cf3d1fa24 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.Error, "%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) } 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/docs/contribute.md b/docs/contribute.md index c31fb56e8..c0f0161be 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -13,26 +13,25 @@ This page describe the project structure and gives you a bit of context to start **Requirements :** -- Node.js >= v10.x +- Nodejs >= v15 - npm or yarn - Go >= 1.16 -- [swag](https://github.com/swaggo/swag) **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 : diff --git a/docs/getting-started/install.md b/docs/getting-started/install.md index a8d14a7b1..585e265b0 100644 --- a/docs/getting-started/install.md +++ b/docs/getting-started/install.md @@ -13,13 +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 ``` -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 +2. Install it globally ``` sudo install ./phoneinfoga /usr/local/bin/phoneinfoga ``` @@ -31,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. @@ -68,7 +77,7 @@ services: - "80:5000" ``` -### From the source code +### Build from source You can download the source code, then build the docker images diff --git a/support/scripts/install b/support/scripts/install old mode 100644 new mode 100755 index e6b6c0a10..c4714891d --- a/support/scripts/install +++ b/support/scripts/install @@ -1,38 +1,259 @@ -#!/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)" +OS="$(uname -s)_$(uname -m)" +PHONEINFOGA_VERSION= +AUTOMATIC= +SKIP_CHECKSUM=1 +CURL_INSTALLED=false +WGET_INSTALLED=false -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" +choose_wget_or_curl() { - 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 + which curl > /dev/null + [ $? -eq 1 ] || CURL_INSTALLED=true - tar xfv "phoneinfoga_$os.tar.gz" - [ $? -eq 0 ] || exit 1 - - # Clear downloaded assets - rm phoneinfoga_$os.tar.gz - rm phoneinfoga_SHA256SUMS + 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 - echo "Installation completed successfully." - echo "Check the version : ./phoneinfoga version" - echo "You can now install the program globally : sudo mv ./phoneinfoga /usr/bin/phoneinfoga" -else - echo "Your OS/Arch is not supported." - echo "Read more at https://sundowndev.github.io/phoneinfoga/install/" - exit 1 -fi + which wget > /dev/null + [ $? -eq 1 ] || WGET_INSTALLED=true -exit 0 + 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." | fold -s + echo + 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 +} + + +validate_OS_type() { + + if [[ -z "${OS}" ]]; then + echo "ERROR: Unable to determine your system type." + exit 1 + fi +} + + +validate_supported_OS() { + + SUPPORTED_OS_TYPES=( + "Darwin_arm64" + "Darwin_x86_64" + "Linux_arm64" + "Linux_armv6" + "Linux_armv7" + "Linux_i386" + "Linux_x86_64" + "Windows_arm64" + "Windows_armv6" + "Windows_armv7" + "Windows_i386" + "Windows_x86_64" + ) + + 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 + +} + + +validate_checksum() { + + echo "Validating checksum ..." + 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 + 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() { + + echo "Downloading PhoneInfoga Version $PHONEINFOGA_VERSION for $OS" + + if $CURL_INSTALLED; then + curl --progress-bar -LOC - "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + + elif $WGET_INSTALLED; then + wget --quiet --show-progress "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/phoneinfoga_$OS.tar.gz" + + fi +} + + +manual_download_latest_release() { + + 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 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 "Downloading $OPT version $PHONEINFOGA_VERSION" + echo "https://github.com/sundowndev/phoneinfoga/releases/download/$PHONEINFOGA_VERSION/$OPT" + + 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 + ;; + esac + done +} + + +unpack_and_cleanup() { + + local FILE + FILE=$(find . -name "phoneinfoga_*.tar.gz") + + tar -xzf $FILE + [ $? -eq 0 ] || exit 1 + + echo "Cleaning up ..." + rm $FILE +} + + +main() { + + validate_OS_type + validate_supported_OS + choose_wget_or_curl + + if [[ -z "$1" ]]; then + echo + else + while [[ "$1" == -* ]]; do + case "$1" in + + -h | --help) + usage + exit 0 + ;; + + -m | --manual) + AUTOMATIC=1 + ;; + + -s | --skip-checksum) + SKIP_CHECKSUM=0 + ;; + + *) + 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 == 1 ]]; then + validate_checksum + elif [[ $SKIP_CHECKSUM == 0 ]]; then + echo + 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" + 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'" + + exit 0 +} + + +main "${@}" 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) } 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(), }