Implemented immidiate check of DNS records, reverted Edge usage.
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ rust-crypto = "^0.2"
|
||||
blakeout = "0.1.0"
|
||||
num_cpus = "1.13.0"
|
||||
byteorder = "1.3.2"
|
||||
web-view = { version = "0.7.3", features = ["edge"] }
|
||||
web-view = { version = "0.7.3", features = [] }
|
||||
tinyfiledialogs = "3.3.10"
|
||||
serde = { version = "1.0.123", features = ["derive"] }
|
||||
serde_json = "1.0.42"
|
||||
|
||||
@@ -46,6 +46,7 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>) {
|
||||
LoadKey => { action_load_key(&context, web_view); }
|
||||
CreateKey => { keys::create_key(Arc::clone(&context)); }
|
||||
SaveKey => { action_save_key(&context); }
|
||||
CheckRecord { data } => { action_check_record(web_view, data); }
|
||||
CheckDomain { name } => { action_check_domain(&context, web_view, name); }
|
||||
MineDomain { name, records, .. } => {
|
||||
action_create_domain(Arc::clone(&context), Arc::clone(&miner), web_view, name, &records);
|
||||
@@ -105,6 +106,13 @@ fn action_check_zone(context: &Arc<Mutex<Context>>, web_view: &mut WebView<()>,
|
||||
}
|
||||
}
|
||||
|
||||
fn action_check_record(web_view: &mut WebView<()>, data: String) {
|
||||
match serde_json::from_str::<DnsRecord>(&data) {
|
||||
Ok(_) => { web_view.eval("recordOkay(true)").expect("Error evaluating!"); }
|
||||
Err(e) => { web_view.eval("recordOkay(false)").expect("Error evaluating!"); dbg!(e); }
|
||||
}
|
||||
}
|
||||
|
||||
fn action_check_domain(context: &Arc<Mutex<Context>>, web_view: &mut WebView<()>, name: String) {
|
||||
let name = name.to_lowercase();
|
||||
let c = context.lock().unwrap();
|
||||
@@ -230,6 +238,7 @@ fn action_create_domain(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>,
|
||||
let data = DomainData::new(zone.clone(), records);
|
||||
let data = serde_json::to_string(&data).unwrap();
|
||||
create_domain(c, miner, &name, &data, difficulty, &context.keystore);
|
||||
let _ = web_view.eval("domainMiningStarted()");
|
||||
}
|
||||
}
|
||||
MineResult::WrongName => { show_warning(web_view, "You can't mine this domain!"); }
|
||||
@@ -304,6 +313,7 @@ pub enum Cmd {
|
||||
SaveKey,
|
||||
CheckZone { name: String },
|
||||
MineZone { name: String, data: String },
|
||||
CheckRecord { data: String },
|
||||
CheckDomain { name: String },
|
||||
MineDomain { name: String, records: String, tags: String },
|
||||
TransferDomain { name: String, owner: String },
|
||||
|
||||
+20
-5
@@ -48,9 +48,7 @@ function refresh_records_list() {
|
||||
function showNewRecordDialog() {
|
||||
button_positive = document.getElementById("new_record_positive_button");
|
||||
button_positive.onclick = function() {
|
||||
addRecord(get_record_from_dialog()); // It will refresh list
|
||||
dialog = document.getElementById("new_record_dialog");
|
||||
dialog.className = "modal";
|
||||
checkRecord(get_record_from_dialog());
|
||||
};
|
||||
|
||||
button_negative = document.getElementById("new_record_negative_button");
|
||||
@@ -65,7 +63,7 @@ function showNewRecordDialog() {
|
||||
}
|
||||
|
||||
function get_record_from_dialog() {
|
||||
record_name = document.getElementById("record_name").value;
|
||||
record_name = document.getElementById("record_name").value.toLowerCase();
|
||||
record_type = document.getElementById("record_type").value;
|
||||
record_ttl = parseInt(document.getElementById("record_ttl").value);
|
||||
record_data = document.getElementById("record_data").value;
|
||||
@@ -123,11 +121,28 @@ function saveKey() {
|
||||
external.invoke(JSON.stringify({cmd: 'saveKey'}));
|
||||
}
|
||||
|
||||
function checkRecord(data) {
|
||||
external.invoke(JSON.stringify({cmd: 'checkRecord', data: JSON.stringify(data)}));
|
||||
}
|
||||
|
||||
function recordOkay(okay) {
|
||||
if (okay) {
|
||||
addRecord(get_record_from_dialog()); // It will refresh list
|
||||
dialog = document.getElementById("new_record_dialog");
|
||||
dialog.className = "modal";
|
||||
} else {
|
||||
showWarning('Record is not valid!');
|
||||
}
|
||||
}
|
||||
|
||||
function createDomain() {
|
||||
new_domain = document.getElementById("new_domain").value;
|
||||
new_domain = document.getElementById("new_domain").value.toLowerCase();
|
||||
new_dom_records = JSON.stringify(recordsBuffer);
|
||||
new_dom_tags = document.getElementById("new_domain_tags").value;
|
||||
external.invoke(JSON.stringify({cmd: 'mineDomain', name: new_domain, records: new_dom_records, tags: new_dom_tags}));
|
||||
}
|
||||
|
||||
function domainMiningStarted() {
|
||||
recordsBuffer = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user