├── .gitattributes ├── schema ├── 2-grant-access.sql └── 1-create-mail-tables.sql ├── docker-compose.yml ├── .gitignore ├── config └── config.json.example ├── structures.go ├── go.mod ├── Dockerfile ├── README.md ├── delete.go ├── patch └── index.html ├── auth.go ├── account.go ├── .github └── workflows │ └── codeql.yml ├── utils.go ├── check.go ├── patch.go ├── receive.go ├── inbound_parse.go ├── wiimail.go ├── main.go ├── send.go ├── go.sum └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text eol=lf 3 | -------------------------------------------------------------------------------- /schema/2-grant-access.sql: -------------------------------------------------------------------------------- 1 | -- Make sure to change the username if you've edited it elsewhere. 2 | GRANT ALL PRIVILEGES ON *.* TO 'rc24'@'%'; 3 | FLUSH PRIVILEGES; -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2.4" 2 | 3 | services: 4 | mail: 5 | build: . 6 | volumes: 7 | - ./config:/go/src/github.com/RiiConnect24/Mail-Go/config 8 | #ports: 9 | # Container 80 -> Host 8080 10 | #- "8080:80" 11 | restart: on-failure 12 | network_mode: "host" 13 | cpu_percent: 25 14 | mem_limit: 2048000000 15 | volumes: 16 | mail_data: 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | 16 | .idea/ 17 | 18 | config/ 19 | !config/config.json.example -------------------------------------------------------------------------------- /config/config.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "Port": 3306, 3 | "Host": "0.0.0.0", 4 | "Username": "redacted", 5 | "Password": "redacted", 6 | "DBName": "WC24Mail", 7 | "Interval": 10, 8 | "BindTo": "localhost:8080", 9 | "SendGridKey": "redacted", 10 | "SendGridDomain": "rc24.xyz", 11 | "Debug": false, 12 | "PatchBaseDomain": "http://mtw.rc24.xyz", 13 | "RavenDSN": "redacted", 14 | "Datadog": true 15 | } 16 | -------------------------------------------------------------------------------- /structures.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var ConfigMagic = []byte("WcCf") 4 | 5 | type ConfigFormat struct { 6 | Magic [4]byte 7 | Version int32 8 | FriendCode int64 9 | AmountOfCreations int32 10 | HasRegistered int32 11 | MailDomain [64]byte 12 | Passwd [32]byte 13 | Mlchkid [36]byte 14 | AccountURL [128]byte 15 | CheckURL [128]byte 16 | ReceiveURL [128]byte 17 | DeleteURL [128]byte 18 | SendURL [128]byte 19 | _ [220]byte // Most likely reserved. 20 | TitleBooting int32 21 | Checksum [4]byte 22 | } 23 | 24 | // Config structure for `config.json`. 25 | type Config struct { 26 | Port int 27 | Host string 28 | Username string 29 | Password string 30 | DBName string 31 | Interval int 32 | BindTo string 33 | SendGridKey string 34 | SendGridDomain string 35 | Debug bool 36 | PatchBaseDomain string 37 | RavenDSN string 38 | Datadog bool 39 | SupportEmail string 40 | } 41 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/RiiConnect24/Mail-Go 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/DataDog/datadog-go/v5 v5.0.1 7 | github.com/RiiConnect24/wiino v0.0.0-20210419165641-a2614cecbcca 8 | github.com/getsentry/sentry-go v0.11.0 9 | github.com/go-sql-driver/mysql v1.6.0 10 | github.com/google/uuid v1.3.0 11 | github.com/logrusorgru/aurora/v3 v3.0.0 12 | golang.org/x/image v0.0.0-20211028202545-6944b10bf410 13 | gopkg.in/DataDog/dd-trace-go.v1 v1.33.0 14 | ) 15 | 16 | require ( 17 | github.com/DataDog/datadog-go v4.4.0+incompatible // indirect 18 | github.com/DataDog/gostackparse v0.5.0 // indirect 19 | github.com/DataDog/sketches-go v1.0.0 // indirect 20 | github.com/Microsoft/go-winio v0.5.0 // indirect 21 | github.com/google/pprof v0.0.0-20210423192551-a2663126120b // indirect 22 | github.com/opentracing/opentracing-go v1.2.0 // indirect 23 | github.com/philhofer/fwd v1.1.1 // indirect 24 | github.com/tinylib/msgp v1.1.2 // indirect 25 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect 26 | golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect 27 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect 28 | google.golang.org/protobuf v1.25.0 // indirect 29 | ) 30 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.17-alpine3.14 as builder 2 | 3 | # We assume only git is needed for all dependencies. 4 | # openssl is already built-in. 5 | RUN apk add -U --no-cache git 6 | 7 | WORKDIR /go/src/github.com/RiiConnect24/Mail-Go 8 | 9 | # Cache pulled dependencies if not updated. 10 | COPY go.mod . 11 | COPY go.sum . 12 | RUN go mod download 13 | 14 | # Copy necessary parts of the Mail-Go source into builder's source 15 | COPY *.go ./ 16 | COPY patch patch 17 | 18 | # Build to name "app". 19 | RUN go build -o app . 20 | 21 | ########### 22 | # RUNTIME # 23 | ########### 24 | FROM alpine:3.14 25 | 26 | WORKDIR /go/src/github.com/RiiConnect24/Mail-Go/ 27 | 28 | ENV DOCKERIZE_VERSION v0.6.1 29 | RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 30 | && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ 31 | && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && apk add -U --no-cache ca-certificates 32 | 33 | COPY --from=builder /go/src/github.com/RiiConnect24/Mail-Go/ . 34 | 35 | # Wait until there's an actual MySQL connection we can use to start. 36 | CMD ["dockerize", "-wait", "tcp://127.0.0.1:3306", "-timeout", "60s", "/go/src/github.com/RiiConnect24/Mail-Go/app"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mail-Go 2 | [![License](https://img.shields.io/github/license/riiconnect24/mail-go.svg?style=flat-square)](http://www.gnu.org/licenses/agpl-3.0) 3 | ![Production List](https://img.shields.io/discord/206934458954153984.svg?style=flat-square) 4 | [![Go Report Card](https://goreportcard.com/badge/github.com/RiiConnect24/Mail-Go?style=flat-square)](https://goreportcard.com/report/github.com/RiiConnect24/Mail-Go) 5 | 6 | This is an effort to rewrite Wii Mail legacy PHP scripts into golang. 7 | Some reasons why: 8 | - `apache2` has the fun tendency to go overboard on memory usage. 9 | - `go` is fun. 10 | 11 | # How to develop 12 | The source is entirely here, with each individual cgi component in their own file. 13 | A `Dockerfile` is available to create an image. You can use `docker-compose.yml` to develop on this specific component with its own mysql, or use *something that doesn't yet exist* to develop on RC24 as a whole. 14 | You can use `docker-compose up` to start up both MariaDB and Mail-Go. 15 | 16 | # How can I use the patcher for my own usage? 17 | You're welcome to `POST /patch` with a `nwc24msg.cfg` under form key `uploaded_config`. 18 | 19 | # What should I do if I'm adding a new dependency? 20 | We use Go's 1.11+ module feature. Make sure you have this enabled. For more information, see [the Go wiki](https://github.com/golang/go/wiki/Modules). 21 | 22 | # Credits 23 | Thanks to Disconnect24 contributors that wrote the code, currently under a forked repo. 24 | -------------------------------------------------------------------------------- /delete.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "fmt" 6 | "net/http" 7 | "strconv" 8 | ) 9 | 10 | func initDeleteDB() { 11 | var err error 12 | deleteStmt, err = db.Prepare("DELETE FROM mails WHERE sent = 1 AND recipient_id = ?") 13 | if err != nil { 14 | LogError("Error creating delete prepared statement", err) 15 | panic(err) 16 | } 17 | } 18 | 19 | var deleteStmt *sql.Stmt 20 | 21 | // Delete handles delete requests of mail. 22 | func Delete(w http.ResponseWriter, r *http.Request, db *sql.DB) { 23 | // These may be empty. This is expected: 24 | // our authentication function will handle accordingly. 25 | mlid := r.Form.Get("mlid") 26 | passwd := r.Form.Get("passwd") 27 | 28 | err := checkPasswdValidity(mlid, passwd) 29 | if err == ErrInvalidCredentials { 30 | fmt.Fprintf(w, GenNormalErrorCode(240, "An authentication error occurred.")) 31 | return 32 | } else if err != nil { 33 | fmt.Fprintf(w, GenNormalErrorCode(541, "Something weird happened.")) 34 | LogError("Error parsing delete authentication", err) 35 | return 36 | } 37 | 38 | delnum := r.Form.Get("delnum") 39 | floatValue, err := strconv.ParseFloat(delnum, 64) 40 | if err != nil { 41 | fmt.Fprintf(w, GenNormalErrorCode(340, "Invalid delete value.")) 42 | return 43 | } 44 | _, err = deleteStmt.Exec(mlid[1:]) 45 | 46 | if global.Datadog { 47 | err = dataDogClient.Incr("mail.deleted_mail", nil, floatValue) 48 | if err != nil { 49 | LogError("Unable to update deleted_mail.", err) 50 | } 51 | } 52 | 53 | if err != nil { 54 | LogError("Error deleting from database", err) 55 | fmt.Fprint(w, GenNormalErrorCode(541, "Issue deleting mail from the database.")) 56 | } else { 57 | fmt.Fprint(w, GenSuccessResponse(), 58 | "deletenum=", delnum) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /patch/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RiiConnect24 Mail 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | RiiConnect24 Mail 14 |
15 | 19 |
20 |
21 | 22 |
23 |
24 |
25 |

Patch:

26 |

Please submit your config with the form; we'll register you right away!

27 |
28 | 29 |
30 |
31 | 32 |
33 |
34 |

Recommendation: You should use the Mail Patcher that runs as Wii homebrew, click here for the link. Only use this patcher if you are experiencing a problem using the app.

35 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /auth.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/sha512" 5 | "database/sql" 6 | "encoding/hex" 7 | "errors" 8 | "regexp" 9 | ) 10 | 11 | func initAuthDB() { 12 | var err error 13 | validatePasswdStmt, err = db.Prepare("SELECT IF(EXISTS(SELECT passwd FROM accounts WHERE mlid = ? AND passwd = ?), 1, 0)") 14 | if err != nil { 15 | LogError("Unable to prepare auth statement", err) 16 | panic(err) 17 | } 18 | } 19 | 20 | var ( 21 | validatePasswdStmt *sql.Stmt 22 | ErrInvalidCredentials = errors.New("an authentication error occurred") 23 | ) 24 | 25 | // sendAuthRegex describes a regex to validate a given mlid and passwd from the client. 26 | // This technically should be mlid=w1234123412341234\r\npasswd=xyz, but \n is used 27 | // for ease of interoperability with UNIX-centric clients. 28 | var sendAuthRegex = regexp.MustCompile(`^mlid=(w\d{16})\r?\npasswd=(.{16,32})$`) 29 | 30 | // parseSendAuth obtains a mlid and passwd from the given format. 31 | // If it is unable to do so, it returns empty strings for both. 32 | // It additionally determines whether the given mlid is valid - 33 | // if not, it returns empty strings for both values as well. 34 | func parseSendAuth(format string) (string, string) { 35 | match := sendAuthRegex.FindStringSubmatch(format) 36 | if match != nil { 37 | // Format: 38 | // [0] = raw string 39 | // [1] = mlid match 40 | // [2] = passwd match 41 | return match[1], match[2] 42 | } else { 43 | return "", "" 44 | } 45 | } 46 | 47 | // hashAuthParam salts and hashes the passed parameter appropriately. 48 | func hashAuthParam(param string) string { 49 | hashByte := sha512.Sum512(append(salt, []byte(param)...)) 50 | return hex.EncodeToString(hashByte[:]) 51 | } 52 | 53 | // checkPasswdValidity returns an error if credentials are invalid, 54 | // or a database error occurred. If not, it returns nil. 55 | func checkPasswdValidity(mlid string, passwd string) error { 56 | if mlid == "" || passwd == "" || !friendCodeIsValid(mlid) { 57 | return ErrInvalidCredentials 58 | } 59 | 60 | passwdHash := hashAuthParam(passwd) 61 | 62 | // Query the database. 63 | exists := false 64 | result := validatePasswdStmt.QueryRow(mlid, passwdHash) 65 | err := result.Scan(&exists) 66 | if err != nil { 67 | return err 68 | } 69 | 70 | // Return our queried result. 71 | if exists { 72 | return nil 73 | } else { 74 | return ErrInvalidCredentials 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /account.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/sha512" 5 | "database/sql" 6 | "encoding/hex" 7 | "fmt" 8 | _ "github.com/go-sql-driver/mysql" 9 | "github.com/logrusorgru/aurora/v3" 10 | "log" 11 | "net/http" 12 | "strconv" 13 | ) 14 | 15 | func initAccountDB() { 16 | var err error 17 | createAccountStmt, err = db.Prepare("INSERT IGNORE INTO `accounts` (`mlid`,`passwd`, `mlchkid` ) VALUES (?, ?, ?)") 18 | if err != nil { 19 | LogError("Unable to prepare account statement", err) 20 | panic(err) 21 | } 22 | } 23 | 24 | var createAccountStmt *sql.Stmt 25 | 26 | func Account(w http.ResponseWriter, r *http.Request) { 27 | var is string 28 | // Check if we should use `=` for a Wii or 29 | // `:` for the Homebrew patcher. 30 | if r.URL.Path == "/cgi-bin/account.cgi" { 31 | is = "=" 32 | } else { 33 | is = ":" 34 | } 35 | 36 | wiiID := r.Form.Get("mlid") 37 | if !friendCodeIsValid(wiiID) { 38 | fmt.Fprint(w, GenAccountErrorCode(610, is, "Invalid Wii Friend Code.")) 39 | return 40 | } else if wiiID == "" { 41 | fmt.Fprint(w, GenNormalErrorCode(310, "Unable to parse parameters.")) 42 | return 43 | } 44 | 45 | w.Header().Add("Content-Type", "text/plain;charset=utf-8") 46 | 47 | passwd := RandStringBytesMaskImprSrc(16) 48 | passwdByte := sha512.Sum512(append(salt, []byte(passwd)...)) 49 | passwdHash := hex.EncodeToString(passwdByte[:]) 50 | 51 | mlchkid := RandStringBytesMaskImprSrc(32) 52 | mlchkidByte := sha512.Sum512(append(salt, []byte(mlchkid)...)) 53 | mlchkidHash := hex.EncodeToString(mlchkidByte[:]) 54 | 55 | result, err := createAccountStmt.Exec(wiiID, passwdHash, mlchkidHash) 56 | if err != nil { 57 | fmt.Fprint(w, GenAccountErrorCode(410, is, "Database error.")) 58 | LogError("Unable to execute statement", err) 59 | return 60 | } 61 | 62 | affected, err := result.RowsAffected() 63 | if err != nil { 64 | fmt.Fprint(w, GenAccountErrorCode(410, is, "Database error.")) 65 | LogError("Unable to get rows affected", err) 66 | return 67 | } 68 | 69 | if affected == 0 { 70 | fmt.Fprint(w, GenAccountErrorCode(211, is, "Duplicate registration.")) 71 | return 72 | } 73 | 74 | if global.Datadog { 75 | err = dataDogClient.Incr("mail.accounts_registered", nil, 1) 76 | if err != nil { 77 | LogError("Unable to update accounts_registered.", err) 78 | } 79 | } 80 | 81 | fmt.Fprint(w, GenSuccessResponseTyped(is), 82 | "mlid", is, wiiID, "\n", 83 | "passwd", is, passwd, "\n", 84 | "mlchkid", is, mlchkid, "\n") 85 | } 86 | 87 | func GenAccountErrorCode(error int, is string, reason string) string { 88 | log.Println(aurora.Red("[Warning]"), "Encountered error", error, "with reason", reason) 89 | 90 | return fmt.Sprint( 91 | "cd", is, strconv.Itoa(error), "\n", 92 | "msg", is, reason, "\n") 93 | } 94 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "master" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "master" ] 20 | schedule: 21 | - cron: '17 6 * * 1' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'go' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Use only 'java' to analyze code written in Java, Kotlin or both 38 | # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both 39 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 40 | 41 | steps: 42 | - name: Checkout repository 43 | uses: actions/checkout@v3 44 | 45 | # Initializes the CodeQL tools for scanning. 46 | - name: Initialize CodeQL 47 | uses: github/codeql-action/init@v2 48 | with: 49 | languages: ${{ matrix.language }} 50 | # If you wish to specify custom queries, you can do so here or in a config file. 51 | # By default, queries listed here will override any specified in a config file. 52 | # Prefix the list here with "+" to use these queries and those in the config file. 53 | 54 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 55 | # queries: security-extended,security-and-quality 56 | 57 | 58 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). 59 | # If this step fails, then you should remove it and run the build manually (see below) 60 | - name: Autobuild 61 | uses: github/codeql-action/autobuild@v2 62 | 63 | # ℹ️ Command-line programs to run using the OS shell. 64 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 65 | 66 | # If the Autobuild fails above, remove it and uncomment the following three lines. 67 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 68 | 69 | # - run: | 70 | # echo "Run, Build Application using script" 71 | # ./location_of_script_within_repo/buildscript.sh 72 | 73 | - name: Perform CodeQL Analysis 74 | uses: github/codeql-action/analyze@v2 75 | with: 76 | category: "/language:${{matrix.language}}" 77 | -------------------------------------------------------------------------------- /schema/1-create-mail-tables.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 5.7.18, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: WC24Mail 4 | -- ------------------------------------------------------ 5 | -- Server version 5.7.18-0ubuntu0.16.04.1 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `accounts` 20 | -- 21 | 22 | CREATE DATABASE IF NOT EXISTS WC24Mail; 23 | USE WC24Mail; 24 | DROP TABLE IF EXISTS `accounts`; 25 | /*!40101 SET @saved_cs_client = @@character_set_client */; 26 | /*!40101 SET character_set_client = utf8 */; 27 | CREATE TABLE `accounts` ( 28 | `mlid` varchar(17) DEFAULT NULL COMMENT 'Mail ID', 29 | `passwd` varchar(128) DEFAULT NULL COMMENT 'Password', 30 | `mlchkid` varchar(128) DEFAULT NULL COMMENT 'Mail Check ID', 31 | UNIQUE KEY `mlid` (`mlid`), 32 | UNIQUE KEY `mlchkid` (`mlchkid`), 33 | UNIQUE KEY `passwd` (`passwd`) 34 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='WiiConnect24 "Accounts"'; 35 | /*!40101 SET character_set_client = @saved_cs_client */; 36 | 37 | -- 38 | -- Table structure for table `mails` 39 | -- 40 | 41 | DROP TABLE IF EXISTS `mails`; 42 | /*!40101 SET @saved_cs_client = @@character_set_client */; 43 | /*!40101 SET character_set_client = utf8 */; 44 | CREATE TABLE `mails` ( 45 | `mail_id` varchar(255) NOT NULL, 46 | `message_id` varchar(255) NOT NULL, 47 | `sender_wiiID` varchar(255) DEFAULT NULL, 48 | `mail` mediumtext, 49 | `recipient_id` varchar(16) DEFAULT NULL, 50 | `sent` tinyint(1) NOT NULL DEFAULT '0', 51 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 52 | PRIMARY KEY (`mail_id`), 53 | UNIQUE KEY `mail_id` (`mail_id`), 54 | KEY `message_id` (`message_id`) 55 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Sent mails from send.cgi'; 56 | /*!40101 SET character_set_client = @saved_cs_client */; 57 | 58 | -- 59 | -- Table structure for table `stats` 60 | -- 61 | 62 | DROP TABLE IF EXISTS `stats`; 63 | /*!40101 SET @saved_cs_client = @@character_set_client */; 64 | /*!40101 SET character_set_client = utf8 */; 65 | CREATE TABLE `stats` ( 66 | `WiiFC` varchar(16) NOT NULL, 67 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP 68 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Statistical data'; 69 | /*!40101 SET character_set_client = @saved_cs_client */; 70 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 71 | 72 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 73 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 74 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 75 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 76 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 77 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 78 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 79 | 80 | -- Dump completed on 2017-07-30 10:47:30 -------------------------------------------------------------------------------- /utils.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/RiiConnect24/wiino/golang" 6 | "github.com/getsentry/sentry-go" 7 | _ "github.com/go-sql-driver/mysql" 8 | "github.com/logrusorgru/aurora/v3" 9 | "log" 10 | "math/rand" 11 | "regexp" 12 | "strconv" 13 | "time" 14 | ) 15 | 16 | // https://stackoverflow.com/a/31832326/3874884 17 | var src = rand.NewSource(time.Now().UnixNano()) 18 | 19 | const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 20 | const ( 21 | letterIdxBits = 6 // 6 bits to represent a letter index 22 | letterIdxMask = 1<= 0; { 33 | if remain == 0 { 34 | cache, remain = src.Int63(), letterIdxMax 35 | } 36 | if idx := int(cache & letterIdxMask); idx < len(letterBytes) { 37 | b[i] = letterBytes[idx] 38 | i-- 39 | } 40 | cache >>= letterIdxBits 41 | remain-- 42 | } 43 | 44 | return string(b) 45 | } 46 | 47 | // GenMailErrorCode formulates a proper response needed for mail-specific errors. 48 | func GenMailErrorCode(mailNumber string, error int, reason string) string { 49 | if error != 100 { 50 | log.Println(aurora.Red("[Warning]"), "Encountered error", error, "with reason", reason) 51 | } 52 | 53 | return fmt.Sprint( 54 | "cd", mailNumber[1:], "=", strconv.Itoa(error), "\n", 55 | "msg", mailNumber[1:], "=", reason, "\n") 56 | } 57 | 58 | // GenNormalErrorCode formulates a proper response for overall errors. 59 | func GenNormalErrorCode(error int, reason string) string { 60 | switch error { 61 | case 220: 62 | break 63 | default: 64 | log.Println(aurora.Red("[Warning]"), "Encountered error", error, "with reason", reason) 65 | } 66 | return fmt.Sprint( 67 | "cd=", strconv.Itoa(error), "\n", 68 | "msg=", reason, "\n") 69 | } 70 | 71 | // GenSuccessResponse returns a successful message, using = as the divider between characters. 72 | func GenSuccessResponse() string { 73 | return GenSuccessResponseTyped("=") 74 | } 75 | 76 | // GenSuccessResponseTyped returns a successful message, using the specified character as a divider. 77 | func GenSuccessResponseTyped(divider string) string { 78 | return fmt.Sprint( 79 | "cd", divider, "100\n", 80 | "msg", divider, "Success.\n") 81 | } 82 | 83 | // friendCodeIsValid determines if a friend code is valid by 84 | // checking not empty, is 17 in length, and starts with w. 85 | // It then checks the numerical validity of the friend code. 86 | func friendCodeIsValid(friendCode string) bool { 87 | // An empty or invalid length mlid is automatically false. 88 | if friendCode == "" || len(friendCode) != 17 { 89 | return false 90 | } 91 | 92 | // Ensure the provided mlid is the correct format. 93 | if !mailRegex.MatchString(friendCode) { 94 | return false 95 | } 96 | 97 | // We verified previously that the last 16 characters are digits. This should not fail. 98 | // However, should it, we do not want to hint to the user any error occurred and return false. 99 | wiiId, err := strconv.Atoi(friendCode[1:]) 100 | if err != nil { 101 | return false 102 | } 103 | 104 | return wiino.NWC24CheckUserID(uint64(wiiId)) == 0 105 | } 106 | 107 | // GenerateBoundary returns a string with the format Nintendo used for boundaries. 108 | func GenerateBoundary() string { 109 | return fmt.Sprint(time.Now().Format("200601021504"), "/", random(1000000, 9999999)) 110 | } 111 | 112 | func LogError(reason string, err error) { 113 | // Log to console 114 | log.Printf("%s: %v", reason, err) 115 | 116 | // and if it's available, Sentry. 117 | sentry.CaptureException(err) 118 | } 119 | -------------------------------------------------------------------------------- /check.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha1" 6 | "database/sql" 7 | "encoding/hex" 8 | "fmt" 9 | "net/http" 10 | ) 11 | 12 | var ( 13 | // MailCheckKey is used as the basis of the SHA-1 HMAC performed for the challenge. 14 | MailCheckKey = []byte{0xce, 0x4c, 0xf2, 0x9a, 0x3d, 0x6b, 0xe1, 0xc2, 0x61, 0x91, 0x72, 0xb5, 0xcb, 0x29, 0x8c, 0x89, 0x72, 0xd4, 0x50, 0xad} 15 | ) 16 | 17 | func initCheckDB() { 18 | var err error 19 | userExistsStmt, err = db.Prepare("SELECT `mlid` FROM accounts WHERE `mlchkid` = ?") 20 | if err != nil { 21 | LogError("Unable to prepare user exists statement", err) 22 | panic(err) 23 | } 24 | 25 | hasMailStmt, err = db.Prepare(`SELECT COUNT(*) > 0 26 | FROM mails 27 | USE INDEX(recipient_id_index) 28 | WHERE mails.recipient_id = ? 29 | AND mails.sent = 0`) 30 | 31 | if err != nil { 32 | LogError("Unable to prepare length statement", err) 33 | panic(err) 34 | } 35 | } 36 | 37 | var userExistsStmt *sql.Stmt 38 | var hasMailStmt *sql.Stmt 39 | 40 | // Check handles adding the proper interval for check.cgi along with future 41 | // challenge solving and future mail existence checking. 42 | func Check(w http.ResponseWriter, r *http.Request, db *sql.DB, interval string) { 43 | // Used later on for challenge solving. 44 | var res string 45 | 46 | // Add required headers 47 | w.Header().Add("Content-Type", "text/plain;charset=utf-8") 48 | w.Header().Add("X-Wii-Mail-Download-Span", interval) 49 | w.Header().Add("X-Wii-Mail-Check-Span", interval) 50 | 51 | mlchkid := r.Form.Get("mlchkid") 52 | if mlchkid == "" { 53 | fmt.Fprintf(w, GenNormalErrorCode(320, "Unable to parse parameters.")) 54 | return 55 | } 56 | 57 | // Check mlchkid 58 | var mlid string 59 | 60 | hash := hashAuthParam(mlchkid) 61 | result := userExistsStmt.QueryRow(hash) 62 | err := result.Scan(&mlid) 63 | if err == sql.ErrNoRows { 64 | // Looks like that user didn't exist. 65 | fmt.Fprintf(w, GenNormalErrorCode(321, "User not found.")) 66 | return 67 | } else if err != nil { 68 | fmt.Fprintf(w, GenNormalErrorCode(320, "Unable to parse parameters.")) 69 | LogError("Unable to run check query", err) 70 | return 71 | } 72 | 73 | // By default, we'll assume there's no mail. 74 | mailFlag := "000000000000000000000000000000000" 75 | var hasMail bool 76 | 77 | // recipient_id has no w as a prefix to its mlid, so we must strip when querying. 78 | result = hasMailStmt.QueryRow(mlid[1:]) 79 | err = result.Scan(&hasMail) 80 | if err != nil { 81 | fmt.Fprintf(w, GenNormalErrorCode(320, "Unable to query mail availability")) 82 | LogError("Unable to query mail availability", err) 83 | return 84 | } 85 | 86 | if hasMail { 87 | // mailFlag needs to be not one, apparently. 88 | // The Wii will refuse to check otherwise. 89 | mailFlag = RandStringBytesMaskImprSrc(33) // This isn't how Nintendo did the mail flag, how they did it is currently unknown. 90 | } else { 91 | // mailFlag was already set to 0 above. 92 | } 93 | 94 | chlng := r.Form.Get("chlng") 95 | if chlng == "" { 96 | fmt.Fprintf(w, GenNormalErrorCode(320, "Unable to parse parameters.")) 97 | return 98 | } 99 | 100 | h := hmac.New(sha1.New, MailCheckKey) 101 | h.Write([]byte(chlng)) 102 | h.Write([]byte("\n")) 103 | h.Write([]byte(mlid)) 104 | h.Write([]byte("\n")) 105 | h.Write([]byte(mailFlag)) 106 | h.Write([]byte("\n")) 107 | h.Write([]byte(interval)) 108 | res = hex.EncodeToString(h.Sum(nil)) 109 | 110 | err = result.Err() 111 | if err != nil { 112 | fmt.Fprintf(w, GenNormalErrorCode(420, "Unable to formulate authentication statement.")) 113 | LogError("Generic database issue", err) 114 | return 115 | } 116 | 117 | if global.Datadog { 118 | err := dataDogClient.Incr("mail.checked", nil, 1) 119 | if err != nil { 120 | LogError("Unable to update checked.", err) 121 | } 122 | } 123 | 124 | // https://github.com/RiiConnect24/Mail-Go/wiki/check.cgi for response format 125 | fmt.Fprint(w, GenSuccessResponse(), 126 | "res=", res, "\n", 127 | "mail.flag=", mailFlag, "\n", 128 | "interval=", interval) 129 | } 130 | -------------------------------------------------------------------------------- /patch.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "crypto/sha512" 6 | "encoding/binary" 7 | "encoding/hex" 8 | "errors" 9 | "fmt" 10 | "io/ioutil" 11 | ) 12 | 13 | // ModifyNwcConfig takes an original config, applies needed patches to the URL and such, 14 | // updates the checksum and returns either nil, error or a patched config w/o error. 15 | func ModifyNwcConfig(originalConfig []byte) ([]byte, error) { 16 | if len(originalConfig) == 0 { 17 | return nil, errors.New("config seems to be empty. double check you uploaded a file") 18 | } 19 | 20 | if len(originalConfig) != 1024 { 21 | return nil, errors.New("invalid config size") 22 | } 23 | 24 | var config ConfigFormat 25 | configReadingBuf := bytes.NewBuffer(originalConfig) 26 | err := binary.Read(configReadingBuf, binary.BigEndian, &config) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | if bytes.Compare(config.Magic[:], ConfigMagic) != 0 { 32 | return nil, errors.New("invalid magic") 33 | } 34 | 35 | // Figure out mlid 36 | mlid := fmt.Sprintf("w%016d", config.FriendCode) 37 | 38 | // Go ahead and push generated data. 39 | mlchkid := RandStringBytesMaskImprSrc(32) 40 | mlchkidByte := sha512.Sum512(append(salt, []byte(mlchkid)...)) 41 | mlchkidHash := hex.EncodeToString(mlchkidByte[:]) 42 | 43 | passwd := RandStringBytesMaskImprSrc(16) 44 | passwdByte := sha512.Sum512(append(salt, []byte(passwd)...)) 45 | passwdHash := hex.EncodeToString(passwdByte[:]) 46 | 47 | // We can reuse the statement defined for normal account creation. 48 | _, err = createAccountStmt.Exec(mlid, mlchkidHash, passwdHash) 49 | if err != nil { 50 | LogError("Error running account statement", err) 51 | return nil, err 52 | } 53 | 54 | if global.Datadog { 55 | err = dataDogClient.Incr("mail.accounts_registered", nil, 1) 56 | if err != nil { 57 | LogError("Unable to update accounts_registered.", err) 58 | } 59 | } 60 | 61 | // Alright, now it's time to patch. 62 | var newMailDomain [64]byte 63 | copy(newMailDomain[:], []byte("@"+global.SendGridDomain)) 64 | config.MailDomain = newMailDomain 65 | 66 | // Copy changed credentials 67 | var newMlchkid [36]byte 68 | copy(newMlchkid[:], []byte(mlchkid)) 69 | config.Mlchkid = newMlchkid 70 | 71 | var newPasswd [32]byte 72 | copy(newPasswd[:], []byte(passwd)) 73 | config.Passwd = newPasswd 74 | 75 | // The following is extremely redundantly written. TODO: fix that? 76 | var newAccountURL [128]byte 77 | copy(newAccountURL[:], []byte(global.PatchBaseDomain+"/cgi-bin/account.cgi")) 78 | config.AccountURL = newAccountURL 79 | 80 | var newCheckURL [128]byte 81 | copy(newCheckURL[:], []byte(global.PatchBaseDomain+"/cgi-bin/check.cgi")) 82 | config.CheckURL = newCheckURL 83 | 84 | var newRecieveURL [128]byte 85 | copy(newRecieveURL[:], []byte(global.PatchBaseDomain+"/cgi-bin/receive.cgi")) 86 | config.ReceiveURL = newRecieveURL 87 | 88 | var newDeleteURL [128]byte 89 | copy(newDeleteURL[:], []byte(global.PatchBaseDomain+"/cgi-bin/delete.cgi")) 90 | config.DeleteURL = newDeleteURL 91 | 92 | var newSendURL [128]byte 93 | copy(newSendURL[:], []byte(global.PatchBaseDomain+"/cgi-bin/send.cgi")) 94 | config.SendURL = newSendURL 95 | 96 | // Enable title booting 97 | config.TitleBooting = 1 98 | 99 | // Read from struct to buffer 100 | fileBuf := new(bytes.Buffer) 101 | err = binary.Write(fileBuf, binary.BigEndian, config) 102 | if err != nil { 103 | return nil, err 104 | } 105 | patchedConfig, err := ioutil.ReadAll(fileBuf) 106 | if err != nil { 107 | return nil, err 108 | } 109 | 110 | var checksumInt uint32 111 | 112 | // Checksum. 113 | // We loop from 1020 to avoid current checksum. 114 | // Take every 4 bytes, add 'er up! 115 | for i := 0; i < 1020; i += 4 { 116 | addition := binary.BigEndian.Uint32(patchedConfig[i : i+4]) 117 | checksumInt += addition 118 | } 119 | 120 | // Grab lower 32 bits of int 121 | var finalChecksum uint32 122 | finalChecksum = checksumInt & 0xFFFFFFFF 123 | binaryChecksum := make([]byte, 4) 124 | binary.BigEndian.PutUint32(binaryChecksum, finalChecksum) 125 | 126 | // Update patched config checksum 127 | copy(patchedConfig[1020:1024], binaryChecksum) 128 | return patchedConfig, nil 129 | } 130 | -------------------------------------------------------------------------------- /receive.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "fmt" 6 | "math/rand" 7 | "net/http" 8 | "strconv" 9 | "strings" 10 | "time" 11 | ) 12 | 13 | func initReceiveDB() { 14 | var err error 15 | getReceiveStmt, err = db.Prepare("SELECT mail_id, mail FROM mails WHERE recipient_id = ? AND sent = 0 ORDER BY timestamp ASC") 16 | if err != nil { 17 | LogError("Error preparing mail retrieval statement", err) 18 | panic(err) 19 | } 20 | 21 | // Statement to mark as sent once put in mail output 22 | updateMailStateStmt, err = db.Prepare("UPDATE mails SET sent = 1 WHERE mail_id = ?") 23 | if err != nil { 24 | LogError("Error preparing mail state update statement", err) 25 | panic(err) 26 | } 27 | } 28 | 29 | var getReceiveStmt *sql.Stmt 30 | var updateMailStateStmt *sql.Stmt 31 | 32 | // Receive loops through stored mail and formulates a response. 33 | // Then, if applicable, marks the mail as received. 34 | func Receive(w http.ResponseWriter, r *http.Request, db *sql.DB) { 35 | mlid := r.Form.Get("mlid") 36 | passwd := r.Form.Get("passwd") 37 | 38 | err := checkPasswdValidity(mlid, passwd) 39 | if err == ErrInvalidCredentials { 40 | fmt.Fprintf(w, GenNormalErrorCode(230, "An authentication error occurred.")) 41 | return 42 | } else if err != nil { 43 | fmt.Fprintf(w, GenNormalErrorCode(531, "Something weird happened.")) 44 | LogError("Error receiving.", err) 45 | return 46 | } 47 | 48 | maxsize, err := strconv.Atoi(r.Form.Get("maxsize")) 49 | if err != nil { 50 | fmt.Fprint(w, GenNormalErrorCode(330, "maxsize needs to be an int.")) 51 | return 52 | } 53 | 54 | // We must strip the first w from the received mlid as the database stores it without. 55 | storedMail, err := getReceiveStmt.Query(mlid[1:]) 56 | if err != nil { 57 | LogError("Error running query against mlid", err) 58 | return 59 | } 60 | 61 | var totalMailOutput string 62 | amountOfMail := 0 63 | mailSize := 0 64 | 65 | // Loop through mail and make the output. 66 | wc24MimeBoundary := GenerateBoundary() 67 | w.Header().Add("Content-Type", fmt.Sprint("multipart/mixed; boundary=", wc24MimeBoundary)) 68 | 69 | defer storedMail.Close() 70 | for storedMail.Next() { 71 | // Mail is the content of the mail stored in the database. 72 | var mailId string 73 | var mail string 74 | err = storedMail.Scan(&mailId, &mail) 75 | if err != nil { 76 | // Hopefully not, but make sure the row layout is the same. 77 | panic(err) 78 | } 79 | individualMail := fmt.Sprint("\r\n--", wc24MimeBoundary, "\r\n") 80 | individualMail += "Content-Type: text/plain\r\n\r\n" 81 | 82 | // In the RiiConnect24 database, some mail use CRLF 83 | // instead of a Unix newline. 84 | // We go ahead and remove this from the mail 85 | // in order to not confuse the Wii. 86 | // BUG(larsenv): make the database not do this 87 | mail = strings.Replace(mail, "\n", "\r\n", -1) 88 | mail = strings.Replace(mail, "\r\r\n", "\r\n", -1) 89 | individualMail += mail 90 | 91 | // Don't add if the mail would exceed max size. 92 | if (len(totalMailOutput) + len(individualMail)) > maxsize { 93 | continue 94 | } else { 95 | totalMailOutput += individualMail 96 | amountOfMail++ 97 | 98 | // Make mailSize reflect our actions. 99 | mailSize += len(mail) 100 | 101 | // We're committed at this point. Mark it that way in the db. 102 | _, err := updateMailStateStmt.Exec(mailId) 103 | if err != nil { 104 | LogError("Unable to mark mail as sent", err) 105 | } 106 | } 107 | } 108 | 109 | // Make sure nothing failed. 110 | err = storedMail.Err() 111 | if err != nil { 112 | LogError("General database error", err) 113 | } 114 | 115 | if global.Datadog { 116 | err := dataDogClient.Incr("mail.received_mail", nil, float64(amountOfMail)) 117 | if err != nil { 118 | LogError("Unable to update received_mail.", err) 119 | } 120 | } 121 | 122 | request := fmt.Sprint("--", wc24MimeBoundary, "\r\n", 123 | "Content-Type: text/plain\r\n\r\n", 124 | "This part is ignored.\r\n\r\n\r\n\n", 125 | GenSuccessResponse(), 126 | "mailnum=", amountOfMail, "\n", 127 | "mailsize=", mailSize, "\n", 128 | "allnum=", amountOfMail, "\n", 129 | totalMailOutput, 130 | "\r\n--", wc24MimeBoundary, "--\r\n") 131 | fmt.Fprint(w, request) 132 | } 133 | 134 | func random(min, max int) int { 135 | rand.Seed(time.Now().Unix()) 136 | return rand.Intn(max-min) + min 137 | } 138 | -------------------------------------------------------------------------------- /inbound_parse.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "encoding/json" 6 | "fmt" 7 | "io/ioutil" 8 | "strings" 9 | 10 | "log" 11 | "net/http" 12 | "net/mail" 13 | "regexp" 14 | 15 | "github.com/google/uuid" 16 | ) 17 | 18 | func initInboundParseDB() { 19 | var err error 20 | inboundParseStmt, err = db.Prepare("INSERT INTO `mails` (`sender_wiiID`,`mail`, `recipient_id`, `mail_id`, `message_id`) VALUES (?, ?, ?, ?, ?)") 21 | if err != nil { 22 | LogError("Unable to prepare inbound parse statement", err) 23 | panic(err) 24 | } 25 | } 26 | 27 | var inboundParseStmt *sql.Stmt 28 | var mailDomain *regexp.Regexp 29 | 30 | func sendGridHandler(w http.ResponseWriter, r *http.Request) { 31 | // We sincerely hope someone won't attempt to send more than a 11MB image. 32 | // but, if they do, now they have 10mb for image and 1mb for text + etc 33 | // (still probably too much) 34 | err := r.ParseMultipartForm(-1) 35 | if err != nil { 36 | log.Printf("Unable to parse form: %v", err) 37 | return 38 | } 39 | 40 | text := r.Form.Get("text") 41 | 42 | if r.Form.Get("from") == "" || r.Form.Get("to") == "" { 43 | // something was nil 44 | log.Println("Something happened to SendGrid... is someone else accessing?") 45 | return 46 | } 47 | 48 | // If there's no text in the email. 49 | if text == "" { 50 | text = "No message provided." 51 | } 52 | 53 | // Figure out who sent it. 54 | fromAddress, err := mail.ParseAddress(r.Form.Get("from")) 55 | if err != nil { 56 | log.Printf("given from address is invalid: %v", err) 57 | return 58 | } 59 | 60 | toAddress := r.Form.Get("to") 61 | // Validate who's being mailed. 62 | potentialMailInformation := mailDomain.FindStringSubmatch(toAddress) 63 | if potentialMailInformation == nil || potentialMailInformation[2] != global.SendGridDomain { 64 | log.Println("to address didn't match") 65 | return 66 | } 67 | // 16 digit ID 68 | recipientMlid := potentialMailInformation[1] 69 | 70 | // We "create" a response for the Wii to use, based off attachments and multipart components. 71 | type File struct { 72 | Filename string `go:"filename"` 73 | Charset string `go:"charset"` 74 | Type string `go:"type"` 75 | } 76 | 77 | var attachedFile []byte 78 | 79 | attachmentInfo := make(map[string]File) 80 | err = json.Unmarshal([]byte(r.Form.Get("attachment-info")), &attachmentInfo) 81 | if err == nil { 82 | hasImage := false 83 | hasAttachedText := false 84 | 85 | for name, attachment := range attachmentInfo { 86 | attachmentData, _, err := r.FormFile(name) 87 | if err == http.ErrMissingFile { 88 | // We don't care if there's nothing, it'll just stay nil. 89 | } else if err != nil { 90 | log.Printf("failed to read attachment from form: %v", err) 91 | return 92 | } else { 93 | if strings.Contains(attachment.Type, "image") && hasImage == false { 94 | attachedFile, err = ioutil.ReadAll(attachmentData) 95 | if err != nil { 96 | log.Printf("failed to read image attachment from form: %v", err) 97 | return 98 | } 99 | hasImage = true 100 | } else if strings.Contains(attachment.Type, "text") && hasAttachedText == false && text == "No message provided." { 101 | attachedText, err := ioutil.ReadAll(attachmentData) 102 | text = string(attachedText) 103 | if err != nil { 104 | log.Printf("failed to read text attachment from form: %v", err) 105 | return 106 | } 107 | hasAttachedText = true 108 | } 109 | } 110 | } 111 | } 112 | 113 | wiiMail, err := FormulateMail(fromAddress.Address, toAddress, r.Form.Get("subject"), text, attachedFile) 114 | if err != nil { 115 | log.Printf("error formulating mail: %v", err) 116 | return 117 | } 118 | 119 | // On a normal Wii service, we'd return the cd/msg response. 120 | // This goes to SendGrid, and we hope the database error is resolved 121 | // later on - any non-success tells it to POST again. 122 | _, err = inboundParseStmt.Exec(fromAddress.Address, wiiMail, recipientMlid, uuid.New().String(), uuid.New().String()) 123 | if err != nil { 124 | log.Printf("Database error: %v", err) 125 | w.WriteHeader(http.StatusInternalServerError) 126 | return 127 | } 128 | 129 | if global.Datadog { 130 | err := dataDogClient.Incr("mail.received_mail_sendgrid", nil, 1) 131 | if err != nil { 132 | LogError("Unable to update received_mail_sendgrid.", err) 133 | } 134 | } 135 | 136 | fmt.Fprint(w, "thanks sendgrid") 137 | } 138 | -------------------------------------------------------------------------------- /wiimail.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "encoding/base64" 7 | "fmt" 8 | "golang.org/x/image/draw" 9 | "io/ioutil" 10 | "log" 11 | "strings" 12 | 13 | "image" 14 | // We use jpeg to actually send to the Wii. 15 | "image/jpeg" 16 | 17 | // We don't actually use the following formats for encoding, 18 | // they're here for image format detection. 19 | _ "image/gif" 20 | _ "image/png" 21 | 22 | _ "golang.org/x/image/bmp" 23 | _ "golang.org/x/image/tiff" 24 | _ "golang.org/x/image/webp" 25 | ) 26 | 27 | const CRLF = "\r\n" 28 | 29 | func FormulateMail(from string, to string, subject string, body string, potentialImage []byte) (string, error) { 30 | boundary := GenerateBoundary() 31 | 32 | // Set up headers and set up first boundary with body. 33 | // The body could be empty: that's fine, it'll have no value 34 | // (compared to nil) and the Wii will ignore that section. 35 | mailContent := fmt.Sprint("From: ", from, CRLF, 36 | "Subject: ", subject, CRLF, 37 | "To: ", to, CRLF, 38 | "MIME-Version: 1.0", CRLF, 39 | `Content-Type: MULTIPART/mixed; BOUNDARY="`, boundary, `"`, CRLF, 40 | CRLF, 41 | "--", boundary, CRLF, 42 | "Content-Type: TEXT/plain; CHARSET=utf-8", CRLF, 43 | "Content-Description: wiimail", CRLF, 44 | CRLF, 45 | ) 46 | 47 | normalMailFormat := fmt.Sprint(mailContent, 48 | body, 49 | strings.Repeat(CRLF, 3), 50 | "--", boundary, "--") 51 | 52 | // If there's an attachment, we need to factor that in. 53 | // Otherwise we're done. 54 | if potentialImage == nil { 55 | return normalMailFormat, nil 56 | } 57 | 58 | // The image library interprets known file types automatically. 59 | givenImg, _, err := image.Decode(bytes.NewReader(potentialImage)) 60 | if err != nil { 61 | log.Printf("Error transforming image: %v %s", err, potentialImage) 62 | return normalMailFormat, nil 63 | } 64 | 65 | // The Wii has a max image size of 8192x8192px. 66 | // If any dimension exceeds that, scale to fit. 67 | outputImg := resize(givenImg, 8192, 8192) 68 | 69 | // Encode image as JPEG for the Wii to handle. 70 | var outputImgWriter bytes.Buffer 71 | err = jpeg.Encode(bufio.NewWriter(&outputImgWriter), outputImg, nil) 72 | if err != nil { 73 | log.Printf("Error transforming image: %v", err) 74 | return genError(mailContent, body, boundary), err 75 | } 76 | 77 | outputImgBytes, err := ioutil.ReadAll(bufio.NewReader(&outputImgWriter)) 78 | if err != nil { 79 | log.Printf("Error transforming image: %v", err) 80 | return genError(mailContent, body, boundary), err 81 | } 82 | 83 | // The Wii's mailbox is roughly 7.3mb. 84 | // We'll cap any generated image at 7mb. 85 | if len(outputImgBytes) > 7*1024*1024 { 86 | return genError(mailContent, body, boundary), nil 87 | } 88 | 89 | encodedImage := base64.StdEncoding.EncodeToString(outputImgBytes) 90 | 91 | var splitEncoding string 92 | // 76 is a widely accepted base64 newline max char standard for mail. 93 | for { 94 | if len(encodedImage) >= 76 { 95 | // Separate the next 73. 96 | splitEncoding += encodedImage[:76] + CRLF 97 | encodedImage = encodedImage[76:] 98 | } else { 99 | // To the end. 100 | splitEncoding += encodedImage[:] 101 | break 102 | } 103 | } 104 | 105 | return fmt.Sprint(mailContent, 106 | body, 107 | strings.Repeat(CRLF, 3), 108 | "--", boundary, CRLF, 109 | // Now we can put our image data. 110 | "Content-Type: IMAGE/jpeg; name=converted.jpeg", CRLF, 111 | "Content-Transfer-Encoding: BASE64", CRLF, 112 | "Content-Disposition: attachment; filename=converted.jpeg", CRLF, 113 | CRLF, 114 | splitEncoding, CRLF, 115 | CRLF, 116 | "--", boundary, "--", 117 | ), nil 118 | } 119 | 120 | func genError(mailContent string, body string, boundary string) string { 121 | return fmt.Sprint(mailContent, 122 | body, 123 | CRLF, 124 | "---", 125 | CRLF, 126 | "An error occurred processing the attached image.", CRLF, 127 | "For more information, ask the sender to forward this mail to ", 128 | global.SupportEmail, 129 | strings.Repeat(CRLF, 3), 130 | "--", boundary, "--") 131 | } 132 | 133 | func resize(origImage image.Image, maxWidth int, maxHeight int) image.Image { 134 | width := origImage.Bounds().Size().X 135 | height := origImage.Bounds().Size().Y 136 | 137 | if width > maxWidth { 138 | height = height * maxWidth / width 139 | width = maxWidth 140 | } 141 | 142 | if height > maxHeight { 143 | width = width * maxHeight / height 144 | height = maxHeight 145 | } 146 | 147 | if width != maxWidth && height != maxHeight { 148 | // No resize needs to occur. 149 | return origImage 150 | } 151 | 152 | newImage := image.NewRGBA(image.Rect(0, 0, width, height)) 153 | draw.BiLinear.Scale(newImage, newImage.Bounds(), origImage, origImage.Bounds(), draw.Over, nil) 154 | return newImage 155 | } 156 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/rand" 5 | "database/sql" 6 | "encoding/json" 7 | "fmt" 8 | "github.com/DataDog/datadog-go/v5/statsd" 9 | "github.com/getsentry/sentry-go" 10 | _ "github.com/go-sql-driver/mysql" 11 | "github.com/logrusorgru/aurora/v3" 12 | "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" 13 | "gopkg.in/DataDog/dd-trace-go.v1/profiler" 14 | "io/ioutil" 15 | "log" 16 | "net/http" 17 | "os" 18 | "regexp" 19 | "strconv" 20 | ) 21 | 22 | var global Config 23 | var db *sql.DB 24 | var salt []byte 25 | var dataDogClient *statsd.Client 26 | 27 | func logRequest(handler http.Handler) http.Handler { 28 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 29 | // Parse form for further usage. 30 | r.ParseForm() 31 | 32 | if global.Debug { 33 | log.Printf("%s %s", aurora.Blue(r.Method), aurora.Red(r.URL)) 34 | for name, value := range r.Form { 35 | log.Print(name, " ", aurora.Green("=>"), " ", value) 36 | } 37 | 38 | log.Printf("Accessing from: %s", aurora.Blue(r.Host)) 39 | } 40 | 41 | // Finally, serve. 42 | handler.ServeHTTP(w, r) 43 | }) 44 | } 45 | 46 | func checkHandler(w http.ResponseWriter, r *http.Request) { 47 | Check(w, r, db, strconv.Itoa(global.Interval)) 48 | } 49 | 50 | func receiveHandler(w http.ResponseWriter, r *http.Request) { 51 | Receive(w, r, db) 52 | } 53 | 54 | func deleteHandler(w http.ResponseWriter, r *http.Request) { 55 | Delete(w, r, db) 56 | } 57 | 58 | func sendHandler(w http.ResponseWriter, r *http.Request) { 59 | Send(w, r, db, global) 60 | } 61 | 62 | func configHandle(w http.ResponseWriter, r *http.Request) { 63 | switch r.Method { 64 | case "POST": 65 | r.ParseForm() 66 | 67 | fileWriter, _, err := r.FormFile("uploaded_config") 68 | if err != nil || err == http.ErrMissingFile { 69 | LogError("Incorrect file", err) 70 | w.WriteHeader(http.StatusBadRequest) 71 | fmt.Fprintf(w, "It seems your file upload went awry. Contact our support email: %s\nError: %v", global.SupportEmail, err) 72 | return 73 | } 74 | 75 | file, err := ioutil.ReadAll(fileWriter) 76 | if err != nil { 77 | LogError("Unable to read file", err) 78 | w.WriteHeader(http.StatusBadRequest) 79 | fmt.Fprintf(w, "It seems your file upload went awry. Contact our support email: %s\nError: %v", global.SupportEmail, err) 80 | return 81 | } 82 | 83 | patched, err := ModifyNwcConfig(file) 84 | if err != nil { 85 | LogError("Unable to patch", err) 86 | w.WriteHeader(http.StatusBadRequest) 87 | fmt.Fprintf(w, "It seems your patching went awry. Contact our support email: %s\nError: %v", global.SupportEmail, err) 88 | return 89 | } 90 | w.Header().Add("Content-Type", "application/octet-stream") 91 | w.Header().Add("Content-Disposition", "attachment; filename=\"nwc24msg.cfg\"") 92 | w.Write(patched) 93 | break 94 | case "GET": 95 | fmt.Fprint(w, "This page doesn't do anything by itself. Try going to the main site.") 96 | default: 97 | break 98 | } 99 | } 100 | 101 | func main() { 102 | if global.Datadog { 103 | tracer.Start( 104 | tracer.WithService("mail"), 105 | tracer.WithEnv("prod"), 106 | tracer.WithAgentAddr("127.0.0.1:8126"), 107 | ) 108 | defer tracer.Stop() 109 | 110 | if err := profiler.Start( 111 | profiler.WithService("mail"), 112 | profiler.WithEnv("prod"), 113 | ); err != nil { 114 | log.Fatal(err) 115 | } 116 | defer profiler.Stop() 117 | } 118 | 119 | // Get salt for passwords 120 | saltLocation := "config/salt.bin" 121 | salt, err := ioutil.ReadFile(saltLocation) 122 | if os.IsNotExist(err) { 123 | log.Println("No salt found. Creating....") 124 | salt = make([]byte, 128) 125 | 126 | _, err := rand.Read(salt) 127 | if err != nil { 128 | panic(err) 129 | } 130 | 131 | err = ioutil.WriteFile("config/salt.bin", salt, os.ModePerm) 132 | if err != nil { 133 | panic(err) 134 | } 135 | } else if err != nil { 136 | panic(err) 137 | } 138 | 139 | // Read config 140 | file, err := os.Open("config/config.json") 141 | if err != nil { 142 | panic(err) 143 | } 144 | decoder := json.NewDecoder(file) 145 | err = decoder.Decode(&global) 146 | if err != nil { 147 | panic(err) 148 | } 149 | 150 | if global.Debug { 151 | log.Println("Connecting to MySQL...") 152 | } 153 | db, err = sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s", 154 | global.Username, global.Password, global.Host, global.Port, global.DBName)) 155 | if err != nil { 156 | panic(err) 157 | } 158 | 159 | // Ensure Mail-Go does not overload the backing database. 160 | db.SetMaxOpenConns(50) 161 | db.SetMaxIdleConns(10) 162 | 163 | err = db.Ping() 164 | if err != nil { 165 | panic(err) 166 | } 167 | 168 | // Prepare database 169 | initAccountDB() 170 | initAuthDB() 171 | initCheckDB() 172 | initDeleteDB() 173 | initInboundParseDB() 174 | initReceiveDB() 175 | initSendDB() 176 | 177 | // Configure Sentry 178 | if global.RavenDSN != "" { 179 | err := sentry.Init(sentry.ClientOptions{ 180 | Dsn: global.RavenDSN, 181 | }) 182 | if err != nil { 183 | panic(err) 184 | } 185 | } 186 | 187 | // Lastly, Datadog as a whole. 188 | if global.Datadog { 189 | dataDogClient, err = statsd.New("127.0.0.1:8125") 190 | if err != nil { 191 | panic(err) 192 | } 193 | } 194 | 195 | // Mail calls 196 | http.HandleFunc("/cgi-bin/account.cgi", Account) 197 | http.HandleFunc("/cgi-bin/patcher.cgi", Account) 198 | http.HandleFunc("/cgi-bin/check.cgi", checkHandler) 199 | http.HandleFunc("/cgi-bin/receive.cgi", receiveHandler) 200 | http.HandleFunc("/cgi-bin/delete.cgi", deleteHandler) 201 | http.HandleFunc("/cgi-bin/send.cgi", sendHandler) 202 | 203 | mailDomain = regexp.MustCompile(`w(\d{16})\@(` + global.SendGridDomain + `)`) 204 | 205 | // Inbound parse 206 | http.HandleFunc("/sendgrid/parse", sendGridHandler) 207 | 208 | // Site 209 | http.HandleFunc("/patch", configHandle) 210 | http.Handle("/", http.FileServer(http.Dir("./patch"))) 211 | 212 | log.Println("Running...") 213 | 214 | // We do this to log all access to the page. 215 | log.Fatal(http.ListenAndServe(global.BindTo, logRequest(http.DefaultServeMux))) 216 | } 217 | -------------------------------------------------------------------------------- /send.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "database/sql" 6 | "fmt" 7 | "github.com/google/uuid" 8 | "github.com/logrusorgru/aurora/v3" 9 | "log" 10 | "net/http" 11 | "net/smtp" 12 | "regexp" 13 | "strings" 14 | ) 15 | 16 | func initSendDB() { 17 | var err error 18 | mailInsertStmt, err = db.Prepare("INSERT INTO `mails` (`sender_wiiID`,`mail`, `recipient_id`, `mail_id`, `message_id`) VALUES (?, ?, ?, ?, ?)") 19 | if err != nil { 20 | LogError("Error preparing mail insertion statement", err) 21 | panic(err) 22 | } 23 | 24 | accountExistsStmt, err = db.Prepare("SELECT EXISTS(SELECT 1 FROM `accounts` WHERE `mlid` = ?)") 25 | if err != nil { 26 | LogError("Error preparing account existence statement", err) 27 | panic(err) 28 | } 29 | } 30 | 31 | var mailInsertStmt *sql.Stmt 32 | var accountExistsStmt *sql.Stmt 33 | 34 | var mailFormName = regexp.MustCompile(`m\d+`) 35 | var mailFrom = regexp.MustCompile(`^MAIL FROM:\s(.*)@(?:.*)$`) 36 | var mailFrom2 = regexp.MustCompile(`^From:\s(.*)@(?:.*)$`) 37 | var rcptFrom = regexp.MustCompile(`^RCPT TO:\s(.*)@(.*)$`) 38 | 39 | // Send takes POSTed mail by the Wii and stores it in the database for future usage. 40 | func Send(w http.ResponseWriter, r *http.Request, db *sql.DB, config Config) { 41 | w.Header().Add("Content-Type", "text/plain;charset=utf-8") 42 | 43 | // Create maps for storage of mail. 44 | mailPart := make(map[string]string) 45 | 46 | // Parse form in preparation for finding mail. 47 | err := r.ParseMultipartForm(-1) 48 | if err != nil { 49 | fmt.Fprint(w, GenNormalErrorCode(350, "Failed to parse mail.")) 50 | LogError("Failed to parse mail", err) 51 | return 52 | } 53 | 54 | if global.Debug { 55 | // We won't print file contents within the multipart form. 56 | for name, values := range r.MultipartForm.Value { 57 | log.Println(aurora.Green(name + ":")) 58 | for value := range values { 59 | log.Println(aurora.Cyan("->"), value) 60 | } 61 | } 62 | } 63 | 64 | // This may be empty if mlid is not present. 65 | // We expect this, however - our authentication function will determine. 66 | mlid, passwd := parseSendAuth(r.Form.Get("mlid")) 67 | err = checkPasswdValidity(mlid, passwd) 68 | if err == ErrInvalidCredentials { 69 | fmt.Fprintf(w, GenNormalErrorCode(250, "An authentication error occurred.")) 70 | return 71 | } else if err != nil { 72 | fmt.Fprintf(w, GenNormalErrorCode(551, "Something weird happened.")) 73 | LogError("Error querying authentication database", err) 74 | return 75 | } 76 | 77 | for name, contents := range r.MultipartForm.Value { 78 | if mailFormName.MatchString(name) { 79 | mailPart[name] = contents[0] 80 | } 81 | } 82 | 83 | eventualOutput := GenSuccessResponse() 84 | eventualOutput += fmt.Sprint("mlnum=", len(mailPart), "\n") 85 | 86 | // Handle all the mail! \o/ 87 | for mailNumber, contents := range mailPart { 88 | var linesToRemove string 89 | // I'm making this a string for similar reasons as below. 90 | // Plus it beats repeated `strconv.Itoa`s 91 | var wiiRecipientIDs []string 92 | var pcRecipientIDs []string 93 | // Yes, senderID is a string. >.< 94 | // The database contains `w<16 digit ID>` due to previous PHP scripts. 95 | // POTENTIAL TODO: remove w from database? 96 | var senderID string 97 | var data string 98 | 99 | // For every new line, handle as needed. 100 | scanner := bufio.NewScanner(strings.NewReader(contents)) 101 | for scanner.Scan() { 102 | line := scanner.Text() 103 | // Add it to this mail's overall data. 104 | data += fmt.Sprintln(line) 105 | 106 | if line == "DATA" { 107 | // We don't actually need to do anything here, 108 | // just carry on. 109 | linesToRemove += fmt.Sprintln(line) 110 | continue 111 | } 112 | 113 | potentialMailFromWrapper := mailFrom.FindStringSubmatch(line) 114 | if potentialMailFromWrapper != nil { 115 | potentialMailFrom := potentialMailFromWrapper[1] 116 | // Ensure MAIL FROM matches the authed mlid (#29) 117 | if potentialMailFrom != mlid { 118 | eventualOutput += GenMailErrorCode(mailNumber, 351, "Attempt to impersonate another user.") 119 | break 120 | } else if potentialMailFrom == "w9999999900000000" { 121 | eventualOutput += GenMailErrorCode(mailNumber, 351, "w9999999900000000 tried to send mail.") 122 | break 123 | } 124 | senderID = potentialMailFrom 125 | linesToRemove += fmt.Sprintln(line) 126 | continue 127 | } 128 | 129 | potentialMailFromWrapper2 := mailFrom2.FindStringSubmatch(line) 130 | if potentialMailFromWrapper2 != nil { 131 | potentialMailFrom2 := potentialMailFromWrapper2[1] 132 | // Ensure From matches the authed mlid (#29) 133 | if potentialMailFrom2 != mlid { 134 | eventualOutput += GenMailErrorCode(mailNumber, 351, "Attempt to impersonate another user.") 135 | return 136 | } else if potentialMailFrom2 == "w9999999900000000" { 137 | eventualOutput += GenMailErrorCode(mailNumber, 351, "w9999999900000000 tried to send mail.") 138 | return 139 | } 140 | } 141 | 142 | // -1 signifies all matches 143 | potentialRecipientWrapper := rcptFrom.FindAllStringSubmatch(line, -1) 144 | if potentialRecipientWrapper != nil { 145 | // We only need to work with the first match, which should be all we need. 146 | potentialRecipient := potentialRecipientWrapper[0] 147 | 148 | // layout: 149 | // potentialRecipient[0] = original matched string w/o groups 150 | // potentialRecipient[1] = w<16 digit ID> 151 | // potentialRecipient[2] = domain being sent to 152 | if potentialRecipient[2] == "wii.com" { 153 | // We're not gonna allow you to send to a defunct domain. ;P 154 | } else if potentialRecipient[2] == config.SendGridDomain { 155 | // Wii <-> Wii mail. We can handle this. 156 | wiiRecipientIDs = append(wiiRecipientIDs, potentialRecipient[1]) 157 | } else { 158 | // PC <-> Wii mail. We can't handle this, but SendGrid can. 159 | email := fmt.Sprintf("%s@%s", potentialRecipient[1], potentialRecipient[2]) 160 | pcRecipientIDs = append(pcRecipientIDs, email) 161 | } 162 | 163 | linesToRemove += fmt.Sprintln(line) 164 | } 165 | } 166 | if err := scanner.Err(); err != nil { 167 | eventualOutput += GenMailErrorCode(mailNumber, 551, "Issue iterating over strings.") 168 | LogError("Error reading from scanner", err) 169 | return 170 | } 171 | mailContents := strings.Replace(data, linesToRemove, "", -1) 172 | // Replace all @wii.com references in the 173 | // friend request email with our own domain. 174 | // Format: w9004342343324713@wii.com 175 | mailContents = strings.Replace(mailContents, 176 | fmt.Sprintf("%s@wii.com ", senderID, senderID), 177 | fmt.Sprintf("%s@%s ", senderID, global.SendGridDomain, senderID, global.SendGridDomain), 178 | -1) 179 | 180 | // We're done figuring out the mail, now it's time to act as needed. 181 | // For Wii recipients, we can just insert into the database. 182 | i := 0 183 | for _, wiiRecipient := range wiiRecipientIDs { 184 | if i > 10 { 185 | continue 186 | } 187 | 188 | // Check that the account actually exists (#15) 189 | var exists bool 190 | existsErr := accountExistsStmt.QueryRow(wiiRecipient).Scan(&exists) 191 | if existsErr != nil && existsErr != sql.ErrNoRows { 192 | eventualOutput += GenMailErrorCode(mailNumber, 551, "Issue verifying recipients.") 193 | LogError("Error verifying recipient account existence", err) 194 | return 195 | } else if !exists { 196 | // Account doesn't exist, ignore 197 | continue 198 | } 199 | 200 | // Splice wiiRecipient to drop w from 16 digit ID. 201 | _, err := mailInsertStmt.Exec(senderID, mailContents, wiiRecipient[1:], uuid.New().String(), uuid.New().String()) 202 | if err != nil { 203 | eventualOutput += GenMailErrorCode(mailNumber, 450, "Database error.") 204 | LogError("Error inserting mail", err) 205 | return 206 | } 207 | 208 | i += 1 209 | } 210 | 211 | i = 0 212 | for _, pcRecipient := range pcRecipientIDs { 213 | if i > 10 { 214 | continue 215 | } 216 | 217 | err := handlePCmail(config, senderID, pcRecipient, mailContents) 218 | if err != nil { 219 | LogError("Error sending mail via SendGrid", err) 220 | eventualOutput += GenMailErrorCode(mailNumber, 551, "Issue sending mail via SendGrid.") 221 | return 222 | } 223 | 224 | if pcRecipient == "trigger@applet.ifttt.com" { 225 | // Send dummy confirmation mail for IFTTT. 226 | var iftttMail string 227 | 228 | iftttMail = "From: trigger@applet.ifttt.com\n" 229 | iftttMail += "Subject: Trigger\n" 230 | iftttMail += "To: " + senderID + "@rc24.xyz\n" 231 | iftttMail += "MIME-Version: 1.0\n" 232 | iftttMail += "Content-Type: MULTIPART/mixed; BOUNDARY=\"ifttt\"\n" 233 | iftttMail += "--ifttt\n" 234 | iftttMail += "Content-Type: TEXT/plain; CHARSET=utf-8\n" 235 | iftttMail += "Content-Description: wiimail\n\n" 236 | iftttMail += "Trigger has been ran!\n\n" 237 | // iftttMail += "--ifttt--" 238 | 239 | _, err := mailInsertStmt.Exec("trigger@applet.ifttt.com", iftttMail, senderID[1:], uuid.New().String(), uuid.New().String()) 240 | if err != nil { 241 | eventualOutput += GenMailErrorCode(mailNumber, 450, "Database error.") 242 | LogError("Error inserting mail", err) 243 | return 244 | } 245 | } 246 | 247 | i += 1 248 | } 249 | eventualOutput += GenMailErrorCode(mailNumber, 100, "Success.") 250 | 251 | if global.Datadog { 252 | err := dataDogClient.Incr("mail.sent_mail", nil, 1.0) 253 | if err != nil { 254 | LogError("Unable to update sent_mail.", err) 255 | } 256 | } 257 | } 258 | 259 | // We're completely done now. 260 | fmt.Fprint(w, eventualOutput) 261 | } 262 | 263 | func handlePCmail(config Config, senderID string, pcRecipient string, mailContents string) error { 264 | // Connect to the remote SMTP server. 265 | host := "smtp.sendgrid.net" 266 | auth := smtp.PlainAuth( 267 | "", 268 | "apikey", 269 | config.SendGridKey, 270 | host, 271 | ) 272 | // The only reason we can get away with the following is 273 | // because the Wii POSTs valid SMTP syntax. 274 | return smtp.SendMail( 275 | fmt.Sprint(host, ":587"), 276 | auth, 277 | fmt.Sprintf("%s@%s", senderID, config.SendGridDomain), 278 | []string{pcRecipient}, 279 | []byte(mailContents), 280 | ) 281 | 282 | } 283 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= 3 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 4 | github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= 5 | github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= 6 | github.com/DataDog/datadog-go v4.4.0+incompatible h1:R7WqXWP4fIOAqWJtUKmSfuc7eDsBT58k9AY5WSHVosk= 7 | github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= 8 | github.com/DataDog/datadog-go/v5 v5.0.1 h1:wVj5wM28FxSEct3shrbUg+MPN29nvPhVu33+0qCvFfE= 9 | github.com/DataDog/datadog-go/v5 v5.0.1/go.mod h1:ZI9JFB4ewXbw1sBnF4sxsR2k1H3xjV+PUAOUsHvKpcU= 10 | github.com/DataDog/gostackparse v0.5.0 h1:jb72P6GFHPHz2W0onsN51cS3FkaMDcjb0QzgxxA4gDk= 11 | github.com/DataDog/gostackparse v0.5.0/go.mod h1:lTfqcJKqS9KnXQGnyQMCugq3u1FP6UZMfWR0aitKFMM= 12 | github.com/DataDog/sketches-go v1.0.0 h1:chm5KSXO7kO+ywGWJ0Zs6tdmWU8PBXSbywFVciL6BG4= 13 | github.com/DataDog/sketches-go v1.0.0/go.mod h1:O+XkJHWk9w4hDwY2ZUDU31ZC9sNYlYo8DiFsxjYeo1k= 14 | github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= 15 | github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= 16 | github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 17 | github.com/RiiConnect24/wiino v0.0.0-20210419165641-a2614cecbcca h1:bqvl4vwPEGdpC//xahkhDpVTwe1ym6wTWv6EdiRxxXY= 18 | github.com/RiiConnect24/wiino v0.0.0-20210419165641-a2614cecbcca/go.mod h1:BmIQ5QOpoum6rxYqqAjdpwwdfoQeKVi1xnxeEU+56ro= 19 | github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= 20 | github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= 21 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 22 | github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= 23 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 24 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 25 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 26 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 27 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 28 | github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= 29 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 30 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= 31 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 32 | github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= 33 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 34 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 35 | github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= 36 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 37 | github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= 38 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 39 | github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= 40 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 41 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 42 | github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= 43 | github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= 44 | github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= 45 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 46 | github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= 47 | github.com/getsentry/sentry-go v0.11.0 h1:qro8uttJGvNAMr5CLcFI9CHR0aDzXl0Vs3Pmw/oTPg8= 48 | github.com/getsentry/sentry-go v0.11.0/go.mod h1:KBQIxiZAetw62Cj8Ri964vAEWVdgfaUCn30Q3bCvANo= 49 | github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= 50 | github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= 51 | github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= 52 | github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= 53 | github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= 54 | github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= 55 | github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 56 | github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= 57 | github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= 58 | github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= 59 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 60 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 61 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 62 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 63 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 64 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 65 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 66 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= 67 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= 68 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= 69 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= 70 | github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= 71 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 72 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 73 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 74 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 75 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 76 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 77 | github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 78 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 79 | github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 80 | github.com/google/pprof v0.0.0-20210423192551-a2663126120b h1:l2YRhr+YLzmSp7KJMswRVk/lO5SwoFIcCLzJsVj+YPc= 81 | github.com/google/pprof v0.0.0-20210423192551-a2663126120b/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 82 | github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 83 | github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 84 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 85 | github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 86 | github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 87 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 88 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 89 | github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 90 | github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= 91 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 92 | github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= 93 | github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= 94 | github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= 95 | github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= 96 | github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= 97 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 98 | github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 99 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 100 | github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= 101 | github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= 102 | github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= 103 | github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= 104 | github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= 105 | github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= 106 | github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= 107 | github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= 108 | github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= 109 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 110 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 111 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 112 | github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= 113 | github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= 114 | github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4= 115 | github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc= 116 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 117 | github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 118 | github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 119 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 120 | github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= 121 | github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= 122 | github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= 123 | github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= 124 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 125 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 126 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 127 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 128 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 129 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 130 | github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= 131 | github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= 132 | github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= 133 | github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= 134 | github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= 135 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 136 | github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 137 | github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= 138 | github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= 139 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 140 | github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ= 141 | github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= 142 | github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= 143 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 144 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 145 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 146 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 147 | github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= 148 | github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 149 | github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= 150 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 151 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 152 | github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 153 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 154 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 155 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 156 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 157 | github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= 158 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 159 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 160 | github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= 161 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 162 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 163 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 164 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 165 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 166 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 167 | github.com/tinylib/msgp v1.1.2 h1:gWmO7n0Ys2RBEb7GPYB9Ujq8Mk5p2U08lRnmMcGy6BQ= 168 | github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= 169 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 170 | github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= 171 | github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= 172 | github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= 173 | github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= 174 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 175 | github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= 176 | github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= 177 | github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= 178 | github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= 179 | github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= 180 | github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= 181 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 182 | github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= 183 | github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= 184 | github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= 185 | github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= 186 | golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 187 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 188 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 189 | golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 190 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 191 | golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ= 192 | golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= 193 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 194 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 195 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 196 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 197 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 198 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 199 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 200 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 201 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 202 | golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 203 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 204 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 205 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 206 | golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 207 | golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 208 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 209 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 210 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 211 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 212 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 213 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 214 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 215 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 216 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 217 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 218 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 219 | golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 220 | golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 221 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 222 | golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 223 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= 224 | golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 225 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 226 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 227 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 228 | golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= 229 | golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 230 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 231 | golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 232 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 233 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 234 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 235 | golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 236 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 237 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 238 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 239 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 240 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 241 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 242 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 243 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 244 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 245 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 246 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 247 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 248 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 249 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 250 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 251 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 252 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= 253 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= 254 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 255 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 256 | google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= 257 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 258 | gopkg.in/DataDog/dd-trace-go.v1 v1.33.0 h1:goLas2M46NJ1NH6c5sPUI/KrYAaaiBZkctJMj2dgJ/w= 259 | gopkg.in/DataDog/dd-trace-go.v1 v1.33.0/go.mod h1:MFdmxQL1OfAGjPrYPU02P82Z5lJ/19f4JVAvXwK1brY= 260 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 261 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 262 | gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= 263 | gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= 264 | gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 265 | gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= 266 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 267 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 268 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 269 | gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 270 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 271 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 272 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 273 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . --------------------------------------------------------------------------------