diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-17 03:28:42 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-17 03:28:42 -0400 |
commit | e2df352ce6dbdbe8ac8076837c8f5d2cbd69208f (patch) | |
tree | 5b27b47583b1242d987c4377170561cc39691050 | |
parent | 0a1685fc6e8b87865c32e2baaded01ae70368a4b (diff) | |
download | teleterm-e2df352ce6dbdbe8ac8076837c8f5d2cbd69208f.tar.gz teleterm-e2df352ce6dbdbe8ac8076837c8f5d2cbd69208f.zip |
pull some more hardcoded values into constants
-rw-r--r-- | src/async_stdin.rs | 8 | ||||
-rw-r--r-- | src/client.rs | 9 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/async_stdin.rs b/src/async_stdin.rs index 5cfea44..e3b0ead 100644 --- a/src/async_stdin.rs +++ b/src/async_stdin.rs @@ -1,5 +1,7 @@ struct EventedStdin; +const STDIN: i32 = 0; + impl std::io::Read for EventedStdin { fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { let stdin = std::io::stdin(); @@ -16,7 +18,7 @@ impl mio::Evented for EventedStdin { interest: mio::Ready, opts: mio::PollOpt, ) -> std::io::Result<()> { - let fd = 0 as std::os::unix::io::RawFd; + let fd = STDIN as std::os::unix::io::RawFd; let eventedfd = mio::unix::EventedFd(&fd); eventedfd.register(poll, token, interest, opts) } @@ -28,13 +30,13 @@ impl mio::Evented for EventedStdin { interest: mio::Ready, opts: mio::PollOpt, ) -> std::io::Result<()> { - let fd = 0 as std::os::unix::io::RawFd; + let fd = STDIN as std::os::unix::io::RawFd; let eventedfd = mio::unix::EventedFd(&fd); eventedfd.reregister(poll, token, interest, opts) } fn deregister(&self, poll: &mio::Poll) -> std::io::Result<()> { - let fd = 0 as std::os::unix::io::RawFd; + let fd = STDIN as std::os::unix::io::RawFd; let eventedfd = mio::unix::EventedFd(&fd); eventedfd.deregister(poll) } diff --git a/src/client.rs b/src/client.rs index d4e925b..26ed108 100644 --- a/src/client.rs +++ b/src/client.rs @@ -10,6 +10,7 @@ const RECONNECT_BACKOFF_MAX: std::time::Duration = std::time::Duration::from_secs(60); const OAUTH_LISTEN_ADDRESS: &str = "127.0.0.1:44141"; +const OAUTH_BROWSER_SUCCESS_MESSAGE: &str = "authenticated successfully! now close this page and return to your terminal."; enum ReadSocket< S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static, @@ -398,10 +399,10 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static> .map(|_| (msg, sock)) }) .and_then(|(msg, sock)| { - let response = r"HTTP/1.1 200 OK - -authenticated successfully! now close this page and return to your terminal. -"; + let response = format!( + "HTTP/1.1 200 OK\n\n{}", + OAUTH_BROWSER_SUCCESS_MESSAGE + ); tokio::io::write_all(sock, response) .context(crate::error::WriteSocket) .map(|_| msg) |