Reads the cfg config file to stdout

stable
Justin Reichardt 2021-12-08 14:29:15 -06:00
parent 66ab1732bc
commit 8bfc224d5b
1 changed files with 29 additions and 5 deletions

View File

@ -25,10 +25,15 @@ import (
"runtime" "runtime"
"fmt" "fmt"
"os" "os"
"bufio"
"log"
) )
func main() { func main() {
// Detect which OS is running // Detect which OS is running
//tmpdir := ""
//hostsloc := ""
cfgloc := ""
switch runtime.GOOS { switch runtime.GOOS {
case "windows": case "windows":
fmt.Println("Windows is currently unsupported") fmt.Println("Windows is currently unsupported")
@ -36,16 +41,35 @@ func main() {
//tmpdir := "C:\\tmp" //tmpdir := "C:\\tmp"
//hostsloc := "C:\\Windows\\System32\\drivers\\etc\\hosts" //hostsloc := "C:\\Windows\\System32\\drivers\\etc\\hosts"
case "linux": case "linux":
tmpdir := "/tmp/" //tmpdir = "/tmp/"
hostsloc := "/etc/hosts" //hostsloc = "/etc/hosts"
cfgloc :="/etc/rhosts/rhosts.cfg" cfgloc ="/etc/rhosts/rhosts.cfg"
fmt.Println("linux:",tmpdir,hostsloc,cfgloc)
case "ios": case "ios":
fmt.Println("ios") fmt.Println("ios")
os.Exit(1)
default: default:
fmt.Println(runtime.GOOS," is not supported") log.Print(runtime.GOOS," is not supported")
os.Exit(1) os.Exit(1)
} }
// Parse Config // Parse Config
log.Print("Opening: ", cfgloc)
cfgf, err := os.Open(cfgloc)
defer cfgf.Close()
if err != nil {
log.Fatal(err)
}
cfgfb := bufio.NewScanner(cfgf)
cfgfb.Split(bufio.ScanLines)
for res := cfgfb.Scan();res;res = cfgfb.Scan() {
fmt.Println(cfgfb.Text())
}
err = cfgfb.Err()
if err != nil {
log.Fatal(err)
}
}
func cfgparse(buf string) string{
return ""
} }