First commit of 0.5.* branch.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use std::time::Duration;
|
||||
|
||||
pub const DB_VERSION: u32 = 0;
|
||||
pub const CHAIN_VERSION: u32 = 0;
|
||||
pub const CHAIN_VERSION: u32 = 1;
|
||||
|
||||
pub const ZONE_DIFFICULTY: u32 = 28;
|
||||
pub const ZONE_MIN_DIFFICULTY: u32 = 22;
|
||||
pub const ORIGIN_DIFFICULTY: u32 = 30;
|
||||
pub const DOMAIN_DIFFICULTY: u32 = 24;
|
||||
pub const SIGNER_DIFFICULTY: u32 = 16;
|
||||
pub const KEYSTORE_DIFFICULTY: u32 = 23;
|
||||
|
||||
@@ -37,7 +37,7 @@ pub const ZONE_MAX_LENGTH: usize = 10;
|
||||
pub const MAX_RECONNECTS: u32 = 5;
|
||||
|
||||
pub const DB_NAME: &str = "blockchain.db";
|
||||
pub const CLASS_ZONE: &str = "zone";
|
||||
pub const CLASS_ORIGIN: &str = "origin";
|
||||
pub const CLASS_DOMAIN: &str = "domain";
|
||||
pub const ALFIS_DEBUG: &str = "ALFIS_DEBUG";
|
||||
|
||||
@@ -46,7 +46,7 @@ pub const LISTEN_PORT: u16 = 4244;
|
||||
pub const UI_REFRESH_DELAY_MS: u128 = 250;
|
||||
pub const LOG_REFRESH_DELAY_SEC: u64 = 60;
|
||||
|
||||
pub const POLL_TIMEOUT: Option<Duration> = Some(Duration::from_millis(250));
|
||||
pub const POLL_TIMEOUT: Option<Duration> = Some(Duration::from_millis(25000));
|
||||
pub const MAX_PACKET_SIZE: usize = 1 * 1024 * 1024; // 1 Mb
|
||||
pub const MAX_READ_BLOCK_TIME: u128 = 500;
|
||||
pub const MAX_IDLE_SECONDS: u64 = 180;
|
||||
|
||||
@@ -32,6 +32,13 @@ pub fn check_domain(name: &str, allow_dots: bool) -> bool {
|
||||
if name.starts_with('.') || name.starts_with('-') || name.ends_with('.') || name.ends_with('-') {
|
||||
return false;
|
||||
}
|
||||
let parts: Vec<&str> = name.rsplitn(2, ".").collect();
|
||||
if parts.len() == 2 {
|
||||
if parts[1].len() < 3 && is_numeric(parts[1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let mut last_dot = false;
|
||||
let mut last_hyphen = false;
|
||||
for char in name.chars() {
|
||||
@@ -60,6 +67,15 @@ pub fn check_domain(name: &str, allow_dots: bool) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn is_numeric(str: &str) -> bool {
|
||||
for char in str.chars() {
|
||||
if !char.is_numeric() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub fn get_domain_zone(domain: &str) -> String {
|
||||
let parts: Vec<&str> = domain.rsplitn(2, ".").collect();
|
||||
if !parts.is_empty() {
|
||||
@@ -160,6 +176,9 @@ mod test {
|
||||
assert!(!check_domain("ab.c-", true));
|
||||
assert!(!check_domain(".ab.c", true));
|
||||
assert!(!check_domain("ab.c-", true));
|
||||
assert!(check_domain("777.com", true));
|
||||
assert!(!check_domain("77.com", true));
|
||||
assert!(!check_domain("7.com", true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user