forked from Silverfish/proton-bridge
Other: add straightforward linters
This commit is contained in:
@ -61,7 +61,7 @@ func NewBasicTLSDialer() *BasicTLSDialer {
|
||||
func (b *BasicTLSDialer) DialTLS(network, address string) (conn net.Conn, err error) {
|
||||
dialer := &net.Dialer{Timeout: 30 * time.Second} // Alternative Routes spec says this should be a 30s timeout.
|
||||
|
||||
var tlsConfig *tls.Config = nil
|
||||
var tlsConfig *tls.Config
|
||||
|
||||
// If we are not dialing the standard API then we should skip cert verification checks.
|
||||
if address != rootURL {
|
||||
|
||||
@ -39,7 +39,7 @@ func NewProxyTLSDialer(dialer TLSDialer, cm *ClientManager) *ProxyTLSDialer {
|
||||
// DialTLS dials the given network/address. If it fails, it retries using a proxy.
|
||||
func (d *ProxyTLSDialer) DialTLS(network, address string) (conn net.Conn, err error) {
|
||||
if conn, err = d.dialer.DialTLS(network, address); err == nil {
|
||||
return
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
if !d.cm.allowProxy {
|
||||
|
||||
@ -107,6 +107,8 @@ func (em *EventMessage) UnmarshalJSON(b []byte) (err error) {
|
||||
case EventUpdate, EventUpdateFlags:
|
||||
em.Updated = &EventMessageUpdated{ID: raw.ID}
|
||||
return json.Unmarshal(raw.Message, em.Updated)
|
||||
case EventDelete:
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -121,6 +123,7 @@ func (em *EventMessage) MarshalJSON() ([]byte, error) {
|
||||
raw.Message, err = json.Marshal(em.Created)
|
||||
case EventUpdate, EventUpdateFlags:
|
||||
raw.Message, err = json.Marshal(em.Updated)
|
||||
case EventDelete:
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
)
|
||||
|
||||
// Flags
|
||||
// Key flags.
|
||||
const (
|
||||
UseToVerifyFlag = 1 << iota
|
||||
UseToEncryptFlag
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// System labels
|
||||
// System labels.
|
||||
const (
|
||||
InboxLabel = "0"
|
||||
AllDraftsLabel = "1"
|
||||
@ -188,7 +188,7 @@ func (c *client) DeleteLabel(id string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// LeastUsedColor is intended to return color for creating a new inbox or label
|
||||
// LeastUsedColor is intended to return color for creating a new inbox or label.
|
||||
func LeastUsedColor(colors []string) (color string) {
|
||||
color = LabelColors[0]
|
||||
frequency := map[string]int{}
|
||||
|
||||
@ -24,14 +24,14 @@ import (
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
)
|
||||
|
||||
// Draft actions
|
||||
// Draft actions.
|
||||
const (
|
||||
DraftActionReply = 0
|
||||
DraftActionReplyAll = 1
|
||||
DraftActionForward = 2
|
||||
)
|
||||
|
||||
// PackageFlag for send message package types
|
||||
// PackageFlag for send message package types.
|
||||
type PackageFlag int
|
||||
|
||||
func (p *PackageFlag) Has(flag PackageFlag) bool { return iHasFlag(int(*p), int(flag)) }
|
||||
@ -65,7 +65,7 @@ const (
|
||||
SignatureAttachedArmored = SignatureFlag(2)
|
||||
)
|
||||
|
||||
// DraftReq defines paylod for creating drafts
|
||||
// DraftReq defines paylod for creating drafts.
|
||||
type DraftReq struct {
|
||||
Message *Message
|
||||
ParentID string `json:",omitempty"`
|
||||
|
||||
@ -52,7 +52,7 @@ func getTrustedServerWithHandler(handler http.HandlerFunc) *httptest.Server {
|
||||
return proxy
|
||||
}
|
||||
|
||||
// server.crt
|
||||
// server.crt data.
|
||||
const servercrt = `
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE5TCCA82gAwIBAgIJAKsmhcMFGfGcMA0GCSqGSIb3DQEBCwUAMIGsMQswCQYD
|
||||
|
||||
@ -172,11 +172,11 @@ func checkHeader(h http.Header, field, exp string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func isAuthReq(r *http.Request, uid, token string) error { // nolint[unparam]
|
||||
func isAuthReq(r *http.Request, uid, token string) error { //nolint[unparam] always retrieves testUID
|
||||
if err := checkHeader(r.Header, "x-pm-uid", uid); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkHeader(r.Header, "authorization", "Bearer "+token); err != nil {
|
||||
if err := checkHeader(r.Header, "authorization", "Bearer "+token); err != nil { //nolint[revive] can return the error right away but this is easier to read
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@ -33,7 +33,7 @@ import (
|
||||
var ErrTLSMismatch = errors.New("no TLS fingerprint match found")
|
||||
|
||||
// TrustedAPIPins contains trusted public keys of the protonmail API and proxies.
|
||||
// NOTE: the proxy pins are the same for all proxy servers, guaranteed by infra team ;)
|
||||
// NOTE: the proxy pins are the same for all proxy servers, guaranteed by infra team ;).
|
||||
var TrustedAPIPins = []string{ // nolint[gochecknoglobals]
|
||||
// api.protonmail.ch
|
||||
`pin-sha256="drtmcR2kFkM8qJClsuWgUzxgBkePfRCkRpqUesyDmeE="`, // current
|
||||
|
||||
@ -29,7 +29,7 @@ const (
|
||||
PaidAdminRole
|
||||
)
|
||||
|
||||
// User status
|
||||
// User status.
|
||||
const (
|
||||
DeletedUser = 0
|
||||
DisabledUser = 1
|
||||
|
||||
Reference in New Issue
Block a user