17 Commits

Author SHA1 Message Date
7b7d706681 Move to GitLab 2021-11-20 22:08:05 +00:00
renovate[bot]
ebf0988f7d Update golang Docker tag to v1.17 (#3)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-10-19 22:49:07 +01:00
202e106486 Create workflow: auto-assign issues 2021-10-19 22:47:43 +01:00
3507540770 Merge branch 'main' of github.com:luketainton/iPilot 2021-03-07 16:53:59 +00:00
a4579b399e v1.3.10: Updated GHA flow 2021-03-07 16:53:37 +00:00
73c6eae26a Add repo URL to Dockerfile 2021-03-06 17:52:31 +00:00
renovate[bot]
eb0f36d314 Add renovate.json (#2)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-03-06 16:02:19 +00:00
7be52a79d6 v1.3.9: Migrate to new container registry 2021-03-06 15:50:42 +00:00
5f2e956e80 v1.3.8: Fix GitHub Actions build (7) 2021-03-06 15:35:38 +00:00
242137d421 v1.3.7: Fix GitHub Actions build (6) 2021-03-06 15:34:36 +00:00
0c2b7ae461 v1.3.6: Fix GitHub Actions build (5) 2021-03-06 15:33:40 +00:00
bb4d1439cf v1.3.5: Fix GitHub Actions build (4) 2021-03-06 15:27:21 +00:00
d8b07d11a1 v1.3.4: Fix GitHub Actions build (3) 2021-03-06 15:24:22 +00:00
3e75a5b445 v1.3.3: Fix GitHub Actions build (2) 2021-03-06 15:18:51 +00:00
46177264a1 v1.3.2: Fix GitHub Actions build 2021-03-06 15:15:49 +00:00
ec9e6ca83c Add Docker configuration 2021-03-06 15:11:40 +00:00
e1953f339d Version 1.3.1: [FIX] Allow disabling header 2021-02-19 23:33:19 +00:00
9 changed files with 163 additions and 3 deletions

View File

@@ -0,0 +1,63 @@
name: Build
on:
push:
tags: '*'
jobs:
prepare-data:
name: Prepare Data
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.prepare.outputs.SOURCE_TAG }}
repo: ${{ steps.prepare.outputs.REPO }}
lrepo: ${{ steps.prepare.outputs.LREPO }}
steps:
- id: prepare
name: Prepare environment variables
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
echo ::set-output name=REPO::${GITHUB_REPOSITORY#luketainton/}
echo ::set-output name=LREPO::${GITHUB_REPOSITORY#luketainton/} | tr '[:upper:]' '[:lower:]'
docker:
name: GitHub Package Registry
runs-on: ubuntu-latest
needs: [prepare-data]
steps:
- uses: actions/checkout@v2
- name: Login to GitHub Package Registry
run: echo ${{ secrets.PAT }} | docker login ghcr.io -u luketainton --password-stdin
- name: Build image for GitHub Package Registry
run: docker build . --file Dockerfile --tag ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:${{ needs.prepare-data.outputs.tag }} --tag ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:latest
- name: Push image to GitHub Package Registry
run: |
docker push ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:latest
docker push ghcr.io/luketainton/${{ needs.prepare-data.outputs.lrepo }}:${{ needs.prepare-data.outputs.tag }}
build:
name: Build and Release
runs-on: ubuntu-latest
needs: [prepare-data]
steps:
- uses: actions/checkout@v2
- name: Build artifacts
run: |
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=amd64 -e GOOS=darwin golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-amd64
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=arm64 -e GOOS=darwin golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-arm64
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=amd64 -e GOOS=linux golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-linux-amd64
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=amd64 -e GOOS=windows golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-amd64.exe
docker run --rm -w /go/src/app -v ${PWD}:/go/src/app -e CGO_ENABLED=0 -e GOARCH=386 -e GOOS=windows golang:alpine go build -o /go/src/app/${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-x86.exe
- uses: meeDamian/github-release@v2.0.3
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.prepare-data.outputs.tag }}
gzip: false
files: >
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-amd64
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-darwin-arm64
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-linux-amd64
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-amd64.exe
${{ needs.prepare-data.outputs.repo }}-${{ needs.prepare-data.outputs.tag }}-win-x86.exe

View File

@@ -0,0 +1,15 @@
name: Issue assignment
on:
issues:
types: [opened]
jobs:
auto-assign:
runs-on: ubuntu-latest
steps:
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
assignees: luketainton

View File

@@ -0,0 +1,5 @@
{
"extends": [
"config:base"
]
}

63
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,63 @@
stages:
- build-docker
- build-binary
- upload
- release
build-docker:
stage: build-docker
only:
- tags
image: docker:19.03.12
services:
- docker:19.03.12-dind
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest -t $IMAGE_TAG .
- docker build -t $IMAGE_TAG -t $CI_REGISTRY_IMAGE:latest .
- docker push $IMAGE_TAG
- docker push $CI_REGISTRY_IMAGE:latest
build-binary:
stage: build-binary
image: golang:1.17.3
before_script:
- cd $GOPATH/src
- mkdir -p gitlab.com/$CI_PROJECT_NAMESPACE
- cd gitlab.com/$CI_PROJECT_NAMESPACE
- ln -s $CI_PROJECT_DIR
- cd $CI_PROJECT_NAME
script:
- CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -o iPilot-${CI_COMMIT_TAG}-darwin-amd64
- CGO_ENABLED=0 GOARCH=arm64 GOOS=darwin go build -o iPilot-${CI_COMMIT_TAG}-darwin-arm64
- CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o iPilot-${CI_COMMIT_TAG}-linux-amd64
- CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -o iPilot-${CI_COMMIT_TAG}-win-amd64.exe
- CGO_ENABLED=0 GOARCH=386 GOOS=windows go build -o iPilot-${CI_COMMIT_TAG}-win-x86.exe
upload:
stage: upload
image: curlimages/curl:latest
rules:
- if: $CI_COMMIT_TAG
script:
- curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file iPilot-${CI_COMMIT_TAG}-darwin-amd64 ${PACKAGE_REGISTRY_URL}
- curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file iPilot-${CI_COMMIT_TAG}-darwin-arm64 ${PACKAGE_REGISTRY_URL}
- curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file iPilot-${CI_COMMIT_TAG}-linux-amd64 ${PACKAGE_REGISTRY_URL}
- curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file iPilot-${CI_COMMIT_TAG}-win-amd64.exe ${PACKAGE_REGISTRY_URL}
- curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file iPilot-${CI_COMMIT_TAG}-win-x86.exe ${PACKAGE_REGISTRY_URL}
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:v0.4.0
rules:
- if: $CI_COMMIT_TAG
script:
- |
release-cli create --name "$CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"iPilot-${CI_COMMIT_TAG}-darwin-amd64\",\"url\":\"iPilot-${CI_COMMIT_TAG}-darwin-amd64\"}" \
--assets-link "{\"name\":\"iPilot-${CI_COMMIT_TAG}-darwin-arm64\",\"url\":\"iPilot-${CI_COMMIT_TAG}-darwin-arm64\"}" \
--assets-link "{\"name\":\"iPilot-${CI_COMMIT_TAG}-linux-amd64\",\"url\":\"iPilot-${CI_COMMIT_TAG}-linux-amd64\"}" \
--assets-link "{\"name\":\"iPilot-${CI_COMMIT_TAG}-win-amd64.exe\",\"url\":\"iPilot-${CI_COMMIT_TAG}-win-amd64.exe\"}" \
--assets-link "{\"name\":\"iPilot-${CI_COMMIT_TAG}-win-x86.exe\",\"url\":\"iPilot-${CI_COMMIT_TAG}-win-x86.exe\"}"

10
Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM golang:1.17-alpine as build
WORKDIR /go/src/app
COPY . /go/src/app
RUN CGO_ENABLED=0 go build -o /go/bin/app
FROM gcr.io/distroless/base-debian10
LABEL maintainer="Luke Tainton <luke@tainton.uk>"
LABEL org.opencontainers.image.source="https://github.com/luketainton/iPilot"
COPY --from=build /go/bin/app /
CMD ["/app"]

View File

@@ -2,7 +2,6 @@ package main
import ( import (
"fmt" "fmt"
"os"
"strings" "strings"
) )
@@ -26,8 +25,6 @@ type IPAddressInfo struct {
func printIPInfo(input string, wantPrefixes bool) { func printIPInfo(input string, wantPrefixes bool) {
var IPInfo IPAddressInfo = getIPInfo(input) var IPInfo IPAddressInfo = getIPInfo(input)
fmt.Printf("%+v\n", IPInfo)
os.Exit(200)
var location string = IPInfo.Country + "/" + IPInfo.RegionName + "/" + IPInfo.City var location string = IPInfo.Country + "/" + IPInfo.RegionName + "/" + IPInfo.City
var bgpAS string = strings.Fields(IPInfo.AS)[0] var bgpAS string = strings.Fields(IPInfo.AS)[0]
fmt.Println("IP Address: ", IPInfo.IPAddress) fmt.Println("IP Address: ", IPInfo.IPAddress)

View File

@@ -17,6 +17,7 @@ func main() {
flag.Usage = func() { flag.Usage = func() {
fmt.Printf("Usage of iPilot: \n") fmt.Printf("Usage of iPilot: \n")
fmt.Printf("Example: iPilot -b=false -i=me -p \n")
fmt.Printf(" -b bool enable/disable header (default true)\n") fmt.Printf(" -b bool enable/disable header (default true)\n")
fmt.Printf(" -h bool view help\n") fmt.Printf(" -h bool view help\n")
fmt.Printf(" -i string IP address or domain\n") fmt.Printf(" -i string IP address or domain\n")

View File

@@ -16,5 +16,8 @@ Here are some ways that you can run the script:
| `./iPilot -i google.com` | Run against the domain name `google.com` | | `./iPilot -i google.com` | Run against the domain name `google.com` |
| `./iPilot -i google.com -p` | Run against the domain name `google.com` and lists BGP prefixes | | `./iPilot -i google.com -p` | Run against the domain name `google.com` and lists BGP prefixes |
## Support
For support please open an issue on [GitLab](https://gitlab.com/luketainton/iPilot) or email [ipilot@help.tainton.uk](mailto:ipilot@help.tainton.uk).
## Credits ## Credits
This script runs thanks to the APIs provided by [IP-API](http://ip-api.com) and [HackerTarget](https://hackertarget.com/as-ip-lookup). This script runs thanks to the APIs provided by [IP-API](http://ip-api.com) and [HackerTarget](https://hackertarget.com/as-ip-lookup).

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module github.com/luketainton/iPilot
go 1.16