This repository has been archived by the owner on May 11, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eclipse+Goclipse support. Cleaner folders.
- Loading branch information
Showing
24 changed files
with
168 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
.*.swp | ||
static/doc/*.html | ||
scramble | ||
scramble.sql | ||
build | ||
bin/ | ||
pkg/ | ||
.settings/ | ||
src/*.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>scramble</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.googlecode.goclipse.goBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>goclipse.goNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"scramble" | ||
) | ||
|
||
func main() { | ||
// HTTP Static Files + REST API | ||
scramble.StartHTTPServer() | ||
|
||
// SMTP Incoming Messages | ||
scramble.StartSMTPServer() | ||
scramble.StartSMTPSaver() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package scramble | ||
|
||
import ( | ||
"errors" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package scramble | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package scramble | ||
|
||
import "testing" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package scramble | ||
|
||
import ( | ||
"net/http" | ||
"strings" | ||
) | ||
|
||
// | ||
// SERVE HTML, CSS, JS | ||
// | ||
|
||
func staticHandler(w http.ResponseWriter, r *http.Request) { | ||
var path string | ||
if strings.HasSuffix(r.URL.Path, "/") { | ||
path = r.URL.Path + "index.html" | ||
} else { | ||
path = r.URL.Path | ||
} | ||
http.ServeFile(w, r, "static/"+path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package main | ||
package scramble | ||
|
||
import ( | ||
"database/sql" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package scramble | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"runtime/debug" | ||
"strings" | ||
"time" | ||
) | ||
|
||
// Stick it as a deferred statement in gouroutines to prevent the program from crashing. | ||
// Catches panics and emails a report to the configured AdminEmails | ||
func Recover() { | ||
if e := recover(); e != nil { | ||
stack := string(debug.Stack()) | ||
errorString := fmt.Sprintf("%s:\n%s", e, stack) | ||
log.Println("<!> " + errorString) | ||
messageID := GenerateMessageID().String() | ||
if len(GetConfig().AdminEmails) > 0 { | ||
go smtpSendSafe(&OutgoingEmail{ | ||
Email: Email{ | ||
EmailHeader: EmailHeader{ | ||
MessageID: messageID, | ||
ThreadID: messageID, | ||
UnixTime: time.Now().Unix(), | ||
From: "daemon@" + GetConfig().SMTPMxHost, | ||
To: strings.Join(GetConfig().AdminEmails, ","), | ||
}, | ||
}, | ||
IsPlaintext: true, | ||
PlaintextSubject: "Panic from Scramble server " + GetConfig().SMTPMxHost, | ||
PlaintextBody: errorString, | ||
}) | ||
} else { | ||
log.Printf("Set AdminEmails: ['your_email@host',...] in config to receive alerts") | ||
} | ||
} | ||
} |
Oops, something went wrong.