Reads the cfg config file to stdout
parent
66ab1732bc
commit
8bfc224d5b
|
|
@ -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 ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue