-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Periodically write a hostfile on the innernet server #336
base: main
Are you sure you want to change the base?
Conversation
@@ -338,6 +338,16 @@ impl DatabasePeer { | |||
Ok(peer_iter.collect::<Result<_, _>>()?) | |||
} | |||
|
|||
pub fn list_enabled(conn: &Connection) -> Result<Vec<Self>, ServerError> { | |||
let mut stmt = conn.prepare_cached(&format!( | |||
"SELECT {} FROM peers WHERE peers.is_redeemed = 1 AND peers.is_disabled = 0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd just do a SELECT ip, name
but the deserialization machinery is all in place to select the whole peer so I just went with that for now for convenience. Performance likely wouldn't be a problem unless you have a lot of peers.
If there is some expectation that this is pulled together enough to maybe work I'll give it a test drive. |
@alerque I would recommend testing it by creating a new network with this server binary, adding a peer, then running the serve command to see if it writes to the hostfile. If you don't get to it I'll test it out later. |
I have deployed e57ab94 on a production network by swapping out the system package for the last stable version (I am the Arch Linux packager for innernet) with an otherwise nearly identical package one built from this PR. I swapped out the package, restarted the server, and the |
@alerque nice, thanks for testing! I'll see what I can do about the naming, but glad to hear it at least somewhat works. |
e57ab94
to
d8cc175
Compare
Getting this started, spurred by a comment.
Related to #135 and #335
Right now this is implemented as a periodic tokio async task on the server when you run the
serve
command. I extracted theupdate_hosts_file()
function from the client into theshared
crate. That felt like the highest value location to add this functionality, though we could also add it to the various other server commands if we wish.Beware, I haven't tested this yet at all.