Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ffdyndns
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Freifunk Luebeck
ffdyndns
Commits
595229c9
Commit
595229c9
authored
3 years ago
by
Paul
Browse files
Options
Downloads
Patches
Plain Diff
errorhandling for nsupdate
parent
a37ffbe4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#4562
passed with warnings
3 years ago
Stage: build
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/ffdyndns.rs
+6
-1
6 additions, 1 deletion
src/ffdyndns.rs
src/main.rs
+1
-1
1 addition, 1 deletion
src/main.rs
src/nsupdate/mod.rs
+19
-21
19 additions, 21 deletions
src/nsupdate/mod.rs
src/nsupdate/nsupdate.rs
+1
-1
1 addition, 1 deletion
src/nsupdate/nsupdate.rs
with
27 additions
and
24 deletions
src/ffdyndns.rs
+
6
−
1
View file @
595229c9
...
...
@@ -34,6 +34,11 @@ pub enum Error {
RecordTypeNotMatching
,
}
impl
From
<
String
>
for
Error
{
fn
from
(
foo
:
String
)
->
Self
{
Self
::
UpdateError
(
foo
)
}
}
impl
Display
for
Error
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
...
...
@@ -85,7 +90,7 @@ impl Service {
nsup
.add_command
(
nsupdate
::
nsupdate
::
UpdateCommand
::
delete
(
&
update
.domain
));
nsup
.add_command
(
nsupdate
::
nsupdate
::
UpdateCommand
::
add
(
&
update
.domain
,
update
.addr
));
nsupdate
::
run_nsupdate
(
nsup
);
nsupdate
::
run_nsupdate
(
nsup
)
?
;
Ok
(())
}
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
1
−
1
View file @
595229c9
#![feature(proc_macro_hygiene,
decl_macro)]
#![feature(proc_macro_hygiene,
decl_macro
,
exit_status_error
)]
mod
config
;
mod
db
;
...
...
This diff is collapsed.
Click to expand it.
src/nsupdate/mod.rs
+
19
−
21
View file @
595229c9
...
...
@@ -6,37 +6,35 @@ use std::process::Stdio;
use
std
::
io
::
Write
;
use
nsupdate
::
UpdateMessage
;
use
log
::{
warn
,
info
,
debug
};
use
std
::
io
::
Read
;
use
std
::
thread
;
pub
fn
run_nsupdate
(
msg
:
UpdateMessage
)
{
pub
fn
run_nsupdate
(
msg
:
UpdateMessage
)
->
Result
<
(),
String
>
{
let
mut
child
=
Command
::
new
(
NSUPDATE_BIN
)
.stdout
(
Stdio
::
null
())
.stdin
(
Stdio
::
piped
())
// .arg("--launch=remote")
// .arg("--no-config")
// .arg("--daemon=no")
// .arg("--log-dns-queries=yes")
// .arg("--loglevel=5")
// .arg("--disable-syslog")
// .arg(format!("--socket-dir={}", CTRL_SOCKET))
// .arg(format!("--local-port={}", self.dns_port))
// .arg(format!("--local-address={}", self.dns_address))
// .arg(format!("--remote-connection-string={}", REMOTE_API_URL))
.stderr
(
Stdio
::
piped
())
.spawn
()
.expect
(
"cannot start pdns_server"
);
let
mut
stdin
=
child
.stdin
.take
()
.expect
(
"stdin for nsupdate process is not available"
);
let
mut
stderr
=
child
.stderr
.take
()
.expect
(
"stderr for nsupdate process is not available"
);
let
updatestring
=
msg
.finalize
();
debug!
(
"sending to nsupdate: {}"
,
updatestring
);
warn!
(
"writing to nsupdate"
);
stdin
.write_all
(
updatestring
.as_bytes
())
.expect
(
"cannot write to nsupdate process"
);
// finish input
stdin
.write
(
b"
\n
"
)
.unwrap
();
stdin
.write
(
&
[
0x4
])
.unwrap
();
stdin
.flush
()
.unwrap
();
warn!
(
"wating for nsupdate to exit"
);
// child.wait().unwrap();
warn!
(
"nsupdate exited"
);
let
stdin_thread
=
thread
::
spawn
(
move
||
{
stdin
.write_all
(
updatestring
.as_bytes
())
.expect
(
"cannot write to nsupdate process"
);
// finish input
stdin
.flush
()
.unwrap
();
drop
(
stdin
);
});
let
mut
error
=
String
::
new
();
stderr
.read_to_string
(
&
mut
error
)
.unwrap
();
let
rcode
=
child
.wait
()
.unwrap
();
info!
(
"nsupdate returned {}"
,
rcode
);
stdin_thread
.join
()
.unwrap
();
rcode
.exit_ok
()
.map_err
(|
_
|
{
error
})
}
This diff is collapsed.
Click to expand it.
src/nsupdate/nsupdate.rs
+
1
−
1
View file @
595229c9
...
...
@@ -5,7 +5,7 @@ use crate::DNSTTL;
// server 127.0.0.1
// update delete a.dyn.example.com
A
// update delete a.dyn.example.com
// update add a.dyn.example.com 60 A 123.23.123.1
// send
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment