From a3518032beb19aec94b167faea60f249ea8fef02 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Fri, 6 Dec 2013 17:39:40 -0600 Subject: [PATCH] Added config file integration, updated some styles --- config.json | 2 +- gophish.go | 34 ++++++++++++++++++++++++++++++---- static/css/main.css | 4 ++++ templates/dashboard.html | 2 +- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/config.json b/config.json index fd3eca4e..c9de72dd 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "url" : "localhost:3333", "smtp" : { - "server" : "smtp.example.com", + "host" : "smtp.example.com", "port" : 25, "user" : "username", "pass" : "password" diff --git a/gophish.go b/gophish.go index 5f58d659..66b397d3 100644 --- a/gophish.go +++ b/gophish.go @@ -25,11 +25,37 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import ( +import ( + "encoding/json" + "fmt" + "io/ioutil" "net/http" + "os" ) +type SMTPServer struct { + Server string `json:"host"` + Port int `json:"port"` + User string `json:"user"` + Password string `json:"password"` +} + +type Config struct { + URL string `json:"url"` + SMTP SMTPServer `json:"smtp"` +} + +var config Config + func main() { - http.Handle("/", createRouter()) - http.ListenAndServe("localhost:3333", nil) -} \ No newline at end of file + // Get the config file + config_file, e := ioutil.ReadFile("./config.json") + if e != nil { + fmt.Printf("File error: %v\n", e) + os.Exit(1) + } + json.Unmarshal(config_file, &config) + fmt.Printf("Gophish server started at http://%s\n", config.URL) + http.Handle("/", createRouter()) + http.ListenAndServe(config.URL, nil) +} diff --git a/static/css/main.css b/static/css/main.css index 9dbb8813..06334129 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -60,4 +60,8 @@ footer > p { color:#444444; font-family: 'Open Sans', sans-serif; +} + +.header { + margin-top:10px; } \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index 0545eaf6..c6b59225 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1,7 +1,7 @@ {{define "content"}} {{template "nav"}}
-

+

Dashboard