forked from Silverfish/proton-bridge
Import/Export backend
This commit is contained in:
@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2020 Proton Technologies AG
|
||||
//
|
||||
// This file is part of ProtonMail Bridge.
|
||||
//
|
||||
// ProtonMail Bridge is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ProtonMail Bridge is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with ProtonMail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package args
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FilterProcessSerialNumberFromArgs removes additional flag from MacOS. More info ProcessSerialNumber
|
||||
// http://mirror.informatimago.com/next/developer.apple.com/documentation/Carbon/Reference/Process_Manager/prmref_main/data_type_5.html#//apple_ref/doc/uid/TP30000208/C001951
|
||||
func FilterProcessSerialNumberFromArgs() {
|
||||
tmp := os.Args[:0]
|
||||
for _, arg := range os.Args {
|
||||
if !strings.Contains(arg, "-psn_") {
|
||||
tmp = append(tmp, arg)
|
||||
}
|
||||
}
|
||||
os.Args = tmp
|
||||
}
|
||||
@ -29,9 +29,6 @@ var (
|
||||
// BuildTime stamp of the build.
|
||||
BuildTime = ""
|
||||
|
||||
// AppShortName to make setup.
|
||||
AppShortName = "bridge"
|
||||
|
||||
// DSNSentry client keys to be able to report crashes to Sentry.
|
||||
DSNSentry = ""
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"mime/quotedprintable"
|
||||
"net/textproto"
|
||||
|
||||
"github.com/ProtonMail/gopenpgp/crypto"
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/emersion/go-textwrapper"
|
||||
openpgperrors "golang.org/x/crypto/openpgp/errors"
|
||||
|
||||
@ -317,9 +317,8 @@ func (cm *ClientManager) CheckConnection() error {
|
||||
retStatus := make(chan error)
|
||||
retAPI := make(chan error)
|
||||
|
||||
// Check protonstatus.com without SSL for performance reasons. vpn_status endpoint is fast and
|
||||
// returns only OK; this endpoint is not known by the public. We check the connection only.
|
||||
go checkConnection(client, "http://protonstatus.com/vpn_status", retStatus)
|
||||
// vpn_status endpoint is fast and returns only OK. We check the connection only.
|
||||
go checkConnection(client, "https://protonstatus.com/vpn_status", retStatus)
|
||||
|
||||
// Check of API reachability also uses a fast endpoint.
|
||||
go checkConnection(client, cm.GetRootURL()+"/tests/ping", retAPI)
|
||||
@ -351,7 +350,7 @@ func (cm *ClientManager) CheckConnection() error {
|
||||
func CheckConnection() error {
|
||||
client := &http.Client{Timeout: time.Second * 10}
|
||||
retStatus := make(chan error)
|
||||
checkConnection(client, "http://protonstatus.com/vpn_status", retStatus)
|
||||
go checkConnection(client, "https://protonstatus.com/vpn_status", retStatus)
|
||||
return <-retStatus
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,9 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/internal/importexport"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/constants"
|
||||
"github.com/kardianos/osext"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -57,7 +60,6 @@ var (
|
||||
)
|
||||
|
||||
type Updates struct {
|
||||
appName string
|
||||
version string
|
||||
revision string
|
||||
buildTime string
|
||||
@ -68,26 +70,44 @@ type Updates struct {
|
||||
installerFileBaseName string // File for initial install or manual reinstall. per goos [exe, dmg, sh].
|
||||
versionFileBaseName string // Text file containing information about current file. per goos [_linux,_darwin,_windows].json (have .sig file).
|
||||
updateFileBaseName string // File for automatic update. per goos [_linux,_darwin,_windows].tgz (have .sig file).
|
||||
macAppBundleName string // For update procedure.
|
||||
linuxFileBaseName string // Prefix of linux package names.
|
||||
macAppBundleName string // Name of Mac app file in the bundle for update procedure.
|
||||
cachedNewerVersion *VersionInfo // To have info about latest version even when the internet connection drops.
|
||||
}
|
||||
|
||||
// New inits Updates struct.
|
||||
// `appName` should be in camelCase format for file names. For installer files is converted to CamelCase.
|
||||
func New(appName, version, revision, buildTime, releaseNotes, releaseFixedBugs, updateTempDir string) *Updates {
|
||||
// NewBridge inits Updates struct for bridge.
|
||||
func NewBridge(updateTempDir string) *Updates {
|
||||
return &Updates{
|
||||
appName: appName,
|
||||
version: version,
|
||||
revision: revision,
|
||||
buildTime: buildTime,
|
||||
releaseNotes: releaseNotes,
|
||||
releaseFixedBugs: releaseFixedBugs,
|
||||
version: constants.Version,
|
||||
revision: constants.Revision,
|
||||
buildTime: constants.BuildTime,
|
||||
releaseNotes: bridge.ReleaseNotes,
|
||||
releaseFixedBugs: bridge.ReleaseFixedBugs,
|
||||
updateTempDir: updateTempDir,
|
||||
landingPagePath: appName + "/download",
|
||||
installerFileBaseName: strings.Title(appName) + "-Installer",
|
||||
landingPagePath: "bridge/download",
|
||||
installerFileBaseName: "Bridge-Installer",
|
||||
versionFileBaseName: "current_version",
|
||||
updateFileBaseName: appName + "_upgrade",
|
||||
macAppBundleName: "ProtonMail " + strings.Title(appName) + ".app", // For update procedure.
|
||||
updateFileBaseName: "bridge_upgrade",
|
||||
linuxFileBaseName: "protonmail-bridge",
|
||||
macAppBundleName: "ProtonMail Bridge.app",
|
||||
}
|
||||
}
|
||||
|
||||
// NewImportExport inits Updates struct for import/export.
|
||||
func NewImportExport(updateTempDir string) *Updates {
|
||||
return &Updates{
|
||||
version: constants.Version,
|
||||
revision: constants.Revision,
|
||||
buildTime: constants.BuildTime,
|
||||
releaseNotes: importexport.ReleaseNotes,
|
||||
releaseFixedBugs: importexport.ReleaseFixedBugs,
|
||||
updateTempDir: updateTempDir,
|
||||
landingPagePath: "blog/import-export-beta/",
|
||||
installerFileBaseName: "Import-Export-Installer",
|
||||
versionFileBaseName: "current_version_ie",
|
||||
updateFileBaseName: "ie_upgrade",
|
||||
linuxFileBaseName: "protonmail-import-export",
|
||||
macAppBundleName: "ProtonMail Import-Export.app",
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +185,7 @@ func (u *Updates) getLocalVersion(goos string) VersionInfo {
|
||||
}
|
||||
|
||||
if goos == "linux" {
|
||||
pkgName := "protonmail-" + u.appName
|
||||
pkgName := u.linuxFileBaseName
|
||||
pkgRel := "1"
|
||||
pkgBase := strings.Join([]string{Host, DownloadPath, pkgName}, "/")
|
||||
|
||||
|
||||
@ -174,5 +174,11 @@ func TestStartUpgrade(t *testing.T) {
|
||||
}
|
||||
|
||||
func newTestUpdates(version string) *Updates {
|
||||
return New("bridge", version, "rev123", "42", "• new feature", "• fixed foo", testUpdateDir)
|
||||
u := NewBridge(testUpdateDir)
|
||||
u.version = version
|
||||
u.revision = "rev123"
|
||||
u.buildTime = "42"
|
||||
u.releaseNotes = "• new feature"
|
||||
u.releaseFixedBugs = "• fixed foo"
|
||||
return u
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user