From 872eee960c4145957d3f7df63713039ed2aa1e36 Mon Sep 17 00:00:00 2001 From: superwhiskers Date: Tue, 10 Apr 2018 18:36:30 +0000 Subject: [PATCH] fix the directory --- .gitignore | 2 +- maryo.go | 8 ++++---- proxy.go | 20 ++++++++++---------- setup.go | 40 ++++++++++++++++++++-------------------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index f6e3502..9c4b65b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ maryo.exe config.json .vscode -maryo/ +maryo-data/ diff --git a/maryo.go b/maryo.go index d22aa92..465eeba 100644 --- a/maryo.go +++ b/maryo.go @@ -23,7 +23,7 @@ func main() { consoleSequence(fmt.Sprintf("%s", code("reset"))) // parse some flags here - config := flag.String("config", "maryo/config.json", "value for config file path (default is maryo/config.json)") + config := flag.String("config", "maryo-data/config.json", "value for config file path (default is maryo/config.json)") logging := flag.Bool("logging", false, "if set, the proxy will log all request data (only needed for debugging)") doSetup := flag.Bool("setup", false, "if set, maryo will go through setup again") generateCerts := flag.Bool("regencerts", false, "if set, maryo will generate self-signed certificates for private use") @@ -87,10 +87,10 @@ func main() { fileMap["cert"] = "ne" // check the cert - if doesFileExist("maryo/cert.pem") != false { + if doesFileExist("maryo-data/cert.pem") != false { // check the key - if doesFileExist("maryo/key.pem") != false { + if doesFileExist("maryo-data/key.pem") != false { // say it is valid if it is there fileMap["cert"] = "va" @@ -120,7 +120,7 @@ func main() { } else if fileMap["cert"] == "ne" { // i'm not going to force you to set it up again - fmt.Printf("you don't have any certs in the maryo folder\n") + fmt.Printf("you don't have any certs in the maryo-data folder\n") fmt.Printf("you have three different options:\n") fmt.Printf(" 1. run this program with the --regencerts flag\n") fmt.Printf(" 2. run this program with the --setup flag") diff --git a/proxy.go b/proxy.go index d17eb5c..01861ca 100644 --- a/proxy.go +++ b/proxy.go @@ -5,7 +5,7 @@ maryo/proxy.go the proxy that makes this program a reverse proxy made by that magical 3ds person -written by Superwhiskers, licensed under gnu gplv3. +written by superwhiskers, licensed under gnu gplv3. if you want a copy, go to http://www.gnu.org/licenses/ */ @@ -40,16 +40,16 @@ func startProxy(configName string, logging bool) { decryptAll := config["config"].(map[string]interface{})["decryptOutgoing"].(string) // check if log file exists - if doesFileExist("maryo/proxy.log") == false { + if doesFileExist("maryo-data/proxy.log") == false { // make it then - createFile("maryo/proxy.log") + createFile("maryo-data/proxy.log") } // write current timestamp to log t := time.Now().Format("20060102150405") - writeFile("maryo/proxy.log", fmt.Sprintf("-> started log [%s]\n", t)) + writeFile("maryo-data/proxy.log", fmt.Sprintf("-> started log [%s]\n", t)) // get ip ip := getIP() @@ -58,7 +58,7 @@ func startProxy(configName string, logging bool) { fmt.Printf("-- proxy log --\n") consoleSequence(fmt.Sprintf("-> local IP address is %s%s%s\n", code("green"), ip, code("reset"))) consoleSequence(fmt.Sprintf("-> hosting proxy on %s:9437%s\n", code("green"), code("reset"))) - writeFile("maryo/proxy.log", fmt.Sprintf("-> got local ip as %s, hosting on port :9437", ip)) + writeFile("maryo-data/proxy.log", fmt.Sprintf("-> got local ip as %s, hosting on port :9437", ip)) // load that proxy proxy := goproxy.NewProxyHttpServer() @@ -85,7 +85,7 @@ func startProxy(configName string, logging bool) { // log the request consoleSequence(fmt.Sprintf("-> request to %s%s%s\n", code("green"), r.URL.Host, code("reset"))) - writeFile("maryo/proxy.log", fmt.Sprintf("-> got request to %s\n", r.URL.Host)) + writeFile("maryo-data/proxy.log", fmt.Sprintf("-> got request to %s\n", r.URL.Host)) // get prettified request @@ -125,9 +125,9 @@ func startProxy(configName string, logging bool) { } // always log to file - writeFile("maryo/proxy.log", fmt.Sprintf("-> request data to %s\n", r.URL.Host)) - writeFile("maryo/proxy.log", fmt.Sprintf("%s", string(reqData[:]))) - writeFile("maryo/proxy.log", fmt.Sprintf("\n\n")) + writeFile("maryo-data/proxy.log", fmt.Sprintf("-> request data to %s\n", r.URL.Host)) + writeFile("maryo-data/proxy.log", fmt.Sprintf("%s", string(reqData[:]))) + writeFile("maryo-data/proxy.log", fmt.Sprintf("\n\n")) // attempt to proxy it to the servers listed in config @@ -153,7 +153,7 @@ func startProxy(configName string, logging bool) { // log the redirect consoleSequence(fmt.Sprintf("-> proxying %s%s%s to %s%s%s\n", code("green"), r.URL.Host, code("reset"), code("green"), redirTo, code("reset"))) - writeFile("maryo/proxy.log", fmt.Sprintf("-> proxying %s to %s", r.URL.Host, redirTo)) + writeFile("maryo-data/proxy.log", fmt.Sprintf("-> proxying %s to %s", r.URL.Host, redirTo)) // redirect it r.URL.Host = redirTo diff --git a/setup.go b/setup.go index f2bafee..977134a 100644 --- a/setup.go +++ b/setup.go @@ -38,33 +38,33 @@ func doCertGen() { // create necissary directories for this // maryo folder - if doesDirExist("maryo") == false { + if doesDirExist("maryo-data") == false { // make it - makeDirectory("maryo") + makeDirectory("maryo-data") } // clean the cert and key if they exist // cert.pem - if doesFileExist("maryo/cert.pem") == true { + if doesFileExist("maryo-data/cert.pem") == true { // delete the cert - deleteFile("maryo/cert.pem") + deleteFile("maryo-data/cert.pem") } // key.pem - if doesFileExist("maryo/key.pem") == true { + if doesFileExist("maryo-data/key.pem") == true { // delete the key - deleteFile("maryo/key.pem") + deleteFile("maryo-data/key.pem") } // generate the needed cert and key - err := httpscerts.Generate("maryo/cert.pem", "maryo/key.pem", fmt.Sprintf("%s:9437", ip)) + err := httpscerts.Generate("maryo-data/cert.pem", "maryo-data/key.pem", fmt.Sprintf("%s:9437", ip)) // handle the error (if there is one) if err != nil { @@ -633,10 +633,10 @@ func setup(fileMap map[string]string) { } // make sure the maryo folder exists - if doesDirExist("maryo") == false { + if doesDirExist("maryo-data") == false { // make it if it doesn't - makeDirectory("maryo") + makeDirectory("maryo-data") } @@ -644,44 +644,44 @@ func setup(fileMap map[string]string) { if fileMap["config"] == "iv" { // delete the existing config - deleteFile("maryo/config.json") + deleteFile("maryo-data/config.json") // create a new one - createFile("maryo/config.json") + createFile("maryo-data/config.json") // write the data to the file - writeByteToFile("maryo/config.json", stringifiedConfig) + writeByteToFile("maryo-data/config.json", stringifiedConfig) } else if fileMap["config"] == "ne" { // create the config - createFile("maryo/config.json") + createFile("maryo-data/config.json") // write the config to the file - writeByteToFile("maryo/config.json", stringifiedConfig) + writeByteToFile("maryo-data/config.json", stringifiedConfig) } else if fileMap["config"] == "uk" { // detect status of config and do the // things to write to it. - if doesFileExist("maryo/config.json") == true { + if doesFileExist("maryo-data/config.json") == true { // delete existing config - deleteFile("maryo/config.json") + deleteFile("maryo-data/config.json") // create a new one - createFile("maryo/config.json") + createFile("maryo-data/config.json") // write the config to it - writeByteToFile("maryo/config.json", stringifiedConfig) + writeByteToFile("maryo-data/config.json", stringifiedConfig) } else { // create the config - createFile("maryo/config.json") + createFile("maryo-data/config.json") // write the config to the file - writeByteToFile("maryo/config.json", stringifiedConfig) + writeByteToFile("maryo-data/config.json", stringifiedConfig) }