-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add enterprise cargo feature + Allow copying SEL licensed code for te…
- Loading branch information
Showing
19 changed files
with
82 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,25 @@ | |
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL | ||
*/ | ||
|
||
use std::{sync::Arc, time::Duration}; | ||
use std::sync::Arc; | ||
|
||
use arc_swap::ArcSwap; | ||
use directory::{Directories, Directory}; | ||
use jmap_proto::types::collection::Collection; | ||
use se_licensing::license::LicenseValidator; | ||
use store::{BitmapKey, BlobBackend, BlobStore, FtsStore, LookupStore, Store, Stores}; | ||
use store::{BlobBackend, BlobStore, FtsStore, LookupStore, Store, Stores}; | ||
use utils::config::Config; | ||
|
||
use crate::{ | ||
expr::*, listener::tls::TlsManager, manager::config::ConfigManager, webhooks::Webhooks, Core, | ||
Enterprise, Network, | ||
Network, | ||
}; | ||
|
||
#[cfg(feature = "enterprise")] | ||
use crate::Enterprise; | ||
#[cfg(feature = "enterprise")] | ||
use jmap_proto::types::collection::Collection; | ||
#[cfg(feature = "enterprise")] | ||
use se_licensing::license::LicenseValidator; | ||
|
||
use self::{ | ||
imap::ImapConfig, jmap::settings::JmapConfig, scripts::Scripting, smtp::SmtpConfig, | ||
storage::Storage, | ||
|
@@ -122,14 +127,18 @@ impl Core { | |
// SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <[email protected]> | ||
// SPDX-License-Identifier: LicenseRef-SEL | ||
|
||
#[cfg(feature = "enterprise")] | ||
let enterprise = match config.value("enterprise.license-key").map(|key| { | ||
LicenseValidator::new().try_parse(key).and_then(|key| { | ||
key.into_validated_key(config.value("lookup.default.hostname").unwrap_or_default()) | ||
}) | ||
}) { | ||
Some(Ok(license)) => { | ||
match data | ||
.get_bitmap(BitmapKey::document_ids(u32::MAX, Collection::Principal)) | ||
.get_bitmap(store::BitmapKey::document_ids( | ||
u32::MAX, | ||
Collection::Principal, | ||
)) | ||
.await | ||
{ | ||
Ok(Some(bitmap)) if bitmap.len() > license.accounts as u64 => { | ||
|
@@ -152,7 +161,7 @@ impl Core { | |
_ => Some(Enterprise { | ||
license, | ||
undelete_period: config | ||
.property_or_default::<Option<Duration>>( | ||
.property_or_default::<Option<std::time::Duration>>( | ||
"enterprise.undelete-period", | ||
"false", | ||
) | ||
|
@@ -206,6 +215,7 @@ impl Core { | |
blobs: stores.blob_stores, | ||
ftss: stores.fts_stores, | ||
}, | ||
#[cfg(feature = "enterprise")] | ||
enterprise, | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL | ||
*/ | ||
|
||
use std::{borrow::Cow, net::IpAddr, sync::Arc, time::Duration}; | ||
use std::{borrow::Cow, net::IpAddr, sync::Arc}; | ||
|
||
use arc_swap::ArcSwap; | ||
use config::{ | ||
|
@@ -35,6 +35,7 @@ use opentelemetry_sdk::{ | |
Resource, | ||
}; | ||
use opentelemetry_semantic_conventions::resource::{SERVICE_NAME, SERVICE_VERSION}; | ||
#[cfg(feature = "enterprise")] | ||
use se_licensing::license::LicenseKey; | ||
use sieve::Sieve; | ||
use store::LookupStore; | ||
|
@@ -71,6 +72,7 @@ pub struct Core { | |
pub jmap: JmapConfig, | ||
pub imap: ImapConfig, | ||
pub web_hooks: Webhooks, | ||
#[cfg(feature = "enterprise")] | ||
pub enterprise: Option<Enterprise>, | ||
} | ||
|
||
|
@@ -85,10 +87,11 @@ pub struct Network { | |
// SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <[email protected]> | ||
// SPDX-License-Identifier: LicenseRef-SEL | ||
|
||
#[cfg(feature = "enterprise")] | ||
#[derive(Clone)] | ||
pub struct Enterprise { | ||
pub license: LicenseKey, | ||
pub undelete_period: Option<Duration>, | ||
pub undelete_period: Option<std::time::Duration>, | ||
} | ||
|
||
// SPDX-SnippetEnd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
pub mod dkim; | ||
pub mod domain; | ||
#[cfg(feature = "enterprise")] | ||
pub mod enterprise; | ||
pub mod log; | ||
pub mod principal; | ||
|
@@ -24,6 +25,8 @@ use serde::Serialize; | |
|
||
use super::{http::ToHttpResponse, HttpRequest, HttpResponse, JsonResponse}; | ||
use crate::{auth::AccessToken, JMAP}; | ||
|
||
#[cfg(feature = "enterprise")] | ||
use se_common::EnterpriseCore; | ||
|
||
#[derive(Serialize)] | ||
|
@@ -95,6 +98,7 @@ impl JMAP { | |
// SPDX-SnippetBegin | ||
// SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <[email protected]> | ||
// SPDX-License-Identifier: LicenseRef-SEL | ||
#[cfg(feature = "enterprise")] | ||
"pro" if is_superuser => { | ||
// WARNING: TAMPERING WITH THIS FUNCTION IS STRICTLY PROHIBITED | ||
// Any attempt to modify, bypass, or disable this license validation mechanism | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ enum ActionClass { | |
Account, | ||
Store(usize), | ||
Acme(String), | ||
#[cfg(feature = "enterprise")] | ||
ReloadLicense, | ||
} | ||
|
||
|
@@ -113,6 +114,7 @@ pub fn spawn_housekeeper(core: JmapInstance, mut rx: mpsc::Receiver<Event>) { | |
// SPDX-License-Identifier: LicenseRef-SEL | ||
|
||
// Enterprise Edition license management | ||
#[cfg(feature = "enterprise")] | ||
if let Some(enterprise) = &core_.enterprise { | ||
queue.schedule( | ||
Instant::now() + enterprise.license.expires_in(), | ||
|
@@ -347,6 +349,7 @@ pub fn spawn_housekeeper(core: JmapInstance, mut rx: mpsc::Receiver<Event>) { | |
// SPDX-SnippetBegin | ||
// SPDX-FileCopyrightText: 2020 Stalwart Labs Ltd <[email protected]> | ||
// SPDX-License-Identifier: LicenseRef-SEL | ||
#[cfg(feature = "enterprise")] | ||
ActionClass::ReloadLicense => { | ||
match core_.reload().await { | ||
Ok(result) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ serde = { version = "1.0", features = ["derive"]} | |
|
||
[features] | ||
test_mode = [] | ||
enterprise = ["common/enterprise"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.