Merge pull request #2 from christopherwoodall/1-env-auth-over-ride

Set/Get environmental variables in `main.go`
This commit is contained in:
Angelina Tsuboi
2023-07-10 15:47:20 -07:00
committed by GitHub
4 changed files with 54 additions and 21 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -2,18 +2,18 @@
``` ```
. . . . . . . . . . . . . . . . . .
. . . ________ . . . ________
. ///////// . . . . . . . ///////// . . . . . .
. ________ . . ///////// . . . ________ . . ///////// . .
|.____. /\ ///////// . . . . |.____. /\ ///////// . . . .
. // \/ |\ ///////// . // \/ |\ /////////
// \ | \ ///////// _______ _______ _______ _____ __ _ _______ _______ . // \ | \ ///////// _______ _______ _______ _____ __ _ _______ _______ .
|| | | ///////// . . |______ |_____| | | | \ | | |______ | || | | ///////// . . |______ |_____| | | | \ | | |______ |
. || | |// ///// ______| | | | __|__ | \_| | |______ |_____ . . || | |// ///// ______| | | | __|__ | \_| | |______ |_____ .
\\ / // \/ . \\ / // \/ .
\\.___./ //\ ,_\ . . . \\.___./ //\ ,_\ . . .
. . \ //////\ / \ . . Satellite OSINT CLI Tool . . . . \ //////\ / \ . . Satellite OSINT CLI Tool . .
. ///////// \| | . . ///////// \| | .
. ///////// . \ __ / . Made by Angelina Tsuboi (G4LXY) . . ///////// . \ __ / . Made by Angelina Tsuboi (G4LXY) .
. ///////// . . . . ///////// . . .
. . ///////// . . . . . . . . ///////// . . . . . .
@@ -26,7 +26,7 @@
### Features ### Features
- Satellite Catalog Retrieval from NORAD ID or Selection Menu - Satellite Catalog Retrieval from NORAD ID or Selection Menu
- Display Satellite Telemetry - Display Satellite Telemetry
- Visual and Radio Orbital Predictions - Visual and Radio Orbital Predictions
- Parse Two Line Elements (TLE) - Parse Two Line Elements (TLE)
### Preview ### Preview
@@ -37,17 +37,17 @@ Make an account at [**Space Track**](https://space-track.org) save username and
Create an account at [**N2YO**](https://n2yo.com) and save API key. Create an account at [**N2YO**](https://n2yo.com) and save API key.
Update `main.go` to have proper credentials The CLI will prompt for both Space Track and N2YO credentials if none are present in your environmental variables. To export your credentials enter the following commands:
``` ```bash
os.Setenv("SPACE_TRACK_USERNAME", "username") $ export SPACE_TRACK_USERNAME="YOUR_USER_NAME"
os.Setenv("SPACE_TRACK_PASSWORD", "password") $ export SPACE_TRACK_PASSWORD="YOUR_PASSWORD"
os.Setenv("N2YO_API_KEY", "api-key") $ export N2YO_API_KEY="YOUR_API_KEY"
``` ```
To build from source, you will need Go installed. To build from source, you will need Go installed.
```bash ```bash
$ export GO111MODULE=on $ export GO111MODULE=on
$ go get ./... $ go get ./...
$ go run main.go $ go run main.go
``` ```
@@ -61,5 +61,5 @@ To get a general overview of the underlying concepts of this tool, [read this ar
### Upcoming Features ### Upcoming Features
+ [ ] Map Layout of Satellite Positioning + [ ] Map Layout of Satellite Positioning
+ [ ] Including the [SGP4 Algorithm](joshuaferrara/go-satellite) for Position Prediction + [ ] Including the [SGP4 Algorithm](joshuaferrara/go-satellite) for Position Prediction

43
main.go
View File

@@ -1,17 +1,50 @@
/* /*
Copyright © 2023 NAME HERE <EMAIL ADDRESS> Copyright © 2023 Angelina Tsuboi angelinatsuboi@proton.me
*/ */
package main package main
import ( import (
"bufio"
"fmt"
"os" "os"
"strings"
"github.com/ANG13T/SatIntel/cli" "github.com/ANG13T/SatIntel/cli"
) )
func setEnvironmentalVariable(envKey string) string {
reader := bufio.NewReader(os.Stdin)
fmt.Printf("%s: ", envKey)
input, err := reader.ReadString('\n')
if err != nil {
fmt.Println("Error reading input:", err)
os.Exit(1)
}
input = strings.TrimSuffix(input, "\n")
if err := os.Setenv(envKey, input); err != nil {
fmt.Printf("Error setting environment variable %s: %v\n", envKey, err)
os.Exit(1)
}
return input
}
func checkEnvironmentalVariable(envKey string) {
_, found := os.LookupEnv(envKey)
if !found {
setEnvironmentalVariable(envKey)
}
}
func main() { func main() {
os.Setenv("SPACE_TRACK_USERNAME", "username") checkEnvironmentalVariable("SPACE_TRACK_USERNAME")
os.Setenv("SPACE_TRACK_PASSWORD", "password") checkEnvironmentalVariable("SPACE_TRACK_PASSWORD")
os.Setenv("N2YO_API_KEY", "api-key") checkEnvironmentalVariable("N2YO_API_KEY")
cli.SatIntel() cli.SatIntel()
} }

View File

@@ -3,10 +3,10 @@ package osint
import ( import (
"io/ioutil" "io/ioutil"
"fmt" "fmt"
"github.com/iskaa02/qalam/gradient" "github.com/iskaa02/qalam/gradient"
"encoding/json" "encoding/json"
"github.com/TwiN/go-color" "github.com/TwiN/go-color"
"net/http" "net/http"
"strconv" "strconv"
"os" "os"
) )
@@ -31,7 +31,7 @@ func SatellitePositionVisualization() {
var norad string var norad string
fmt.Scanln(&norad) fmt.Scanln(&norad)
GetLocation(norad) GetLocation(norad)
} }
return return
} }