Merge branch 'master' into imap

This commit is contained in:
emersion 2017-12-12 13:47:00 +01:00
commit 789234bf17
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 25 additions and 5 deletions

View File

@ -11,16 +11,32 @@ Rationale:
* Standard-compliant (we don't care about Microsoft Outlook) * Standard-compliant (we don't care about Microsoft Outlook)
* Fully open-source * Fully open-source
## Usage ## Setup
### Golang
hydroxide is implemented with Go. Head to [Golang website](https://golang.org)
for setup information.
### Install and Setup
Install hydroxide
```shell
go get github.com/emersion/hydroxide/cmd/hydroxide
```
Your credentials will be stored on disk encrypted with a 32-byte random Your credentials will be stored on disk encrypted with a 32-byte random
password. When configuring your client, you'll need this password. password. When configuring your client, you'll need this password.
```shell ```shell
go get github.com/emersion/hydroxide
hydroxide auth <username> hydroxide auth <username>
``` ```
## Usage
hydroxide can be used in multiple modes.
### CardDAV ### CardDAV
You must setup an HTTPS reverse proxy to forward requests to `hydroxide`. You must setup an HTTPS reverse proxy to forward requests to `hydroxide`.

View File

@ -148,6 +148,7 @@ func main() {
s.Addr = "127.0.0.1:" + port s.Addr = "127.0.0.1:" + port
s.Domain = "localhost" // TODO: make this configurable s.Domain = "localhost" // TODO: make this configurable
s.AllowInsecureAuth = true // TODO: remove this s.AllowInsecureAuth = true // TODO: remove this
//s.Debug = os.Stdout
log.Println("Starting SMTP server at", s.Addr) log.Println("Starting SMTP server at", s.Addr)
log.Fatal(s.ListenAndServe()) log.Fatal(s.ListenAndServe())

View File

@ -4,6 +4,7 @@ package protonmail
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -23,7 +24,8 @@ type resp struct {
func (r *resp) Err() error { func (r *resp) Err() error {
if err := r.apiError; err != nil { if err := r.apiError; err != nil {
return r.apiError err.code = r.Code
return err
} }
return nil return nil
} }
@ -33,11 +35,12 @@ type maybeError interface {
} }
type apiError struct { type apiError struct {
code int // populated by resp
Message string `json:"Error"` Message string `json:"Error"`
} }
func (err apiError) Error() string { func (err apiError) Error() string {
return err.Message return fmt.Sprintf("[%v] %v", err.code, err.Message)
} }
// Client is a ProtonMail API client. // Client is a ProtonMail API client.

View File

@ -237,7 +237,7 @@ func (u *user) Send(from string, to []string, r io.Reader) error {
if len(resp.Keys) == 0 { if len(resp.Keys) == 0 {
plaintextRecipients = append(plaintextRecipients, rcpt.Address) plaintextRecipients = append(plaintextRecipients, rcpt.Address)
break continue
} }
// TODO: only keys with Send == 1 // TODO: only keys with Send == 1