Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Mail-Go v1.2 - Official Release for RC24 - Please Read (#26)
Browse files Browse the repository at this point in the history
Thanks a lot!
  • Loading branch information
Puppercino authored and larsenv committed Aug 11, 2018
1 parent cd1285d commit ead93ec
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
* text eol=lf
33 changes: 14 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
FROM golang:1.10-alpine as builder
FROM golang:1.10

# Install git so go get will work.
# Additionally, install g++ so that
# lilliput can compile.
RUN apk add -U --no-cache git g++
# For later timing purposes
RUN apt-get update && apt-get install -y wget

ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
# Clean packages
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && apt-get clean

# Pre-download listed dependencies to take
# advantage of Docker cache.
RUN mkdir -p /go/src/github.com/RiiConnect24/Mail-Go
WORKDIR /go/src/github.com/RiiConnect24/Mail-Go
COPY get.sh /go/src/github.com/RiiConnect24/Mail-Go
RUN mkdir -p /go/src/Mail-Go
WORKDIR /go/src/Mail-Go
COPY get.sh /go/src/Mail-Go
RUN sh get.sh

# Copy the entire Mail-Go source into builder's source.
Expand All @@ -19,15 +23,6 @@ RUN go get ./...
# Build to name "app".
RUN GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o app .

# Create a new image so we can have a smaller overall source iamge.
FROM disconnect24/docker-mail-runtime-base
WORKDIR /
COPY --from=builder /go/src/github.com/RiiConnect24/Mail-Go/app .

# Copy for site templates.
RUN mkdir -p patch/templates
ADD patch/templates patch/templates

# Wait until there's an actual MySQL connection we can use to start.
#CMD ["dockerize", "-wait", "tcp://database:3306", "-timeout", "60s", "/app"]
CMD ["/app"]
# CMD ["dockerize", "-wait", "tcp://database:3306", "-timeout", "60s", "/go/src/Mail-Go/app"]
CMD ["/app"]
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
# We must wait for the DB to import/etc before starting ourselves.
depends_on:
- "database"
restart: on-failure

volumes:
mail_data:
mail_data:
2 changes: 1 addition & 1 deletion get.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# Script allowing us to cache Go dependencies in Docker cache.
go get github.com/google/uuid
go get github.com/Disconnect24/lilliput
go get github.com/discordapp/lilliput
go get github.com/logrusorgru/aurora
go get github.com/go-sql-driver/mysql
go get github.com/getsentry/raven-go
3 changes: 1 addition & 2 deletions inbound_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"net/http"
"net/mail"
"regexp"
"database/sql"
)

var mailDomain *regexp.Regexp

func SendGrid(w http.ResponseWriter, r *http.Request, db *sql.DB) {
func sendGridHandler(w http.ResponseWriter, r *http.Request) {
// We sincerely hope someone won't attempt to send more than a 11MB image.
// but, if they do, now they have 10mb for image and 1mb for text + etc
// (still probably too much)
Expand Down
52 changes: 15 additions & 37 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (
"database/sql"
"encoding/json"
"fmt"
"github.com/RiiConnect24/Mail-Go/patch"
"github.com/Disconnect24/Mail-Go/patch"
"github.com/getsentry/raven-go"
_ "github.com/go-sql-driver/mysql"
"github.com/logrusorgru/aurora"
"html/template"
"io/ioutil"
"log"
"net/http"
Expand All @@ -19,7 +18,6 @@ import (

var global patch.Config
var db *sql.DB
var templates *template.Template
var salt []byte
var ravenClient *raven.Client

Expand Down Expand Up @@ -57,10 +55,6 @@ func sendHandler(w http.ResponseWriter, r *http.Request) {
Send(w, r, db, global)
}

func sendGridHandler(w http.ResponseWriter, r *http.Request) {
SendGrid(w, r, db)
}

func configHandle(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "POST":
Expand Down Expand Up @@ -152,22 +146,6 @@ func main() {
}
}

// Load templates for HTML serving later on
templateLocation := "./patch/templates"
templateDir, err := os.Open(templateLocation)
if err != nil {
panic(err)
}
templateDirList, err := templateDir.Readdir(-1)
if err != nil {
panic(err)
}
var templatePaths []string
for _, templateFile := range templateDirList {
templatePaths = append(templatePaths, fmt.Sprint(templateLocation, "/", templateFile.Name()))
}
templates, err = template.ParseFiles(templatePaths...)

// Mail calls
http.HandleFunc("/cgi-bin/account.cgi", Account)
http.HandleFunc("/cgi-bin/patcher.cgi", Account)
Expand All @@ -182,25 +160,25 @@ func main() {
http.HandleFunc("/sendgrid/parse", sendGridHandler)

// Site
http.HandleFunc("/patch", configHandle)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// We only want the primary page.
if r.URL.Path != "/" {
// Load from site folder
var file []byte
var err error
if r.URL.Path == "/" {
// We want index.html
file, err = ioutil.ReadFile("./patch/site/index.html")
} else {
file, err = ioutil.ReadFile("./patch/site" + r.URL.Path)
}

// We only want existing pages.
if err != nil {
http.NotFound(w, r)
return
}

s1 := templates.Lookup("header.tmpl")
s1.ExecuteTemplate(w, "header", nil)
fmt.Println()
s2 := templates.Lookup("patch.tmpl")
s2.ExecuteTemplate(w, "content", nil)
fmt.Println()
s3 := templates.Lookup("footer.tmpl")
s3.ExecuteTemplate(w, "footer", nil)
fmt.Println()
s3.Execute(w, nil)
w.Write(file)
})
http.HandleFunc("/patch", configHandle)

log.Println("Running...")

Expand Down
Binary file added patch/site/DC24logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions patch/site/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Disconnect24 Patcher</title>
<style type="text/css">
.default {
font-family: Gill Sans, Gill Sans MT, Myriad Pro, DejaVu Sans Condensed, Helvetica, Arial, sans-serif;
text-align: center;
color: #FFFFFF;
background-color: black
}
</style>
</head>

<body class="default">
<div/>
<h1>Disconnect24 Mail</h1>
<p><img src="DC24logo.png" width="531" height="187" alt=""/>
</p>
<h2>Mail Patcher v1.2</h2>
<h3>This time it actually works.™</h3>
<p>Upload your nwc24msg.cfg below to register your Wii.</p>
<form action="/patch" method="post" enctype="multipart/form-data" class="dropzone">
<div class="default">
<input type="file" name="uploaded_config" class="textB"/><span class="textB"><br/><br/>
</span>
<input class="textB" type="submit" value="Upload and Patch!"/><span class="textB">
</span>
</div>
<h4>Recommendation: You should use the Disconnect24 Patcher at:</h4>
<h5>https://github.com/Disconnect24/dc24-channel/releases</h5>
</form>
</body>
</html>
7 changes: 0 additions & 7 deletions patch/templates/footer.tmpl

This file was deleted.

20 changes: 0 additions & 20 deletions patch/templates/header.tmpl

This file was deleted.

14 changes: 0 additions & 14 deletions patch/templates/patch.tmpl

This file was deleted.

2 changes: 1 addition & 1 deletion send.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bufio"
"database/sql"
"fmt"
"github.com/RiiConnect24/Mail-Go/patch"
"github.com/Disconnect24/Mail-Go/patch"
"github.com/google/uuid"
"net/http"
"net/smtp"
Expand Down
2 changes: 1 addition & 1 deletion wiimail.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/base64"
"fmt"
"github.com/Disconnect24/lilliput"
"github.com/discordapp/lilliput"
"log"
"strings"
)
Expand Down

0 comments on commit ead93ec

Please sign in to comment.