hand

finger proxy server
Log | Files | Refs | README

commit 4b3b15e6fdb9ed47b9e682f4f76c0e32925519b3
parent 86a3c22dadd992ffeb41ea4f4c80c574a4c4c97d
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  3 Dec 2021 23:43:34 -0800

force port 79

Diffstat:
Msrc/main.rs | 23++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,6 +1,5 @@ use fingers; use std::fmt; -use std::net::ToSocketAddrs; use vial::prelude::*; routes! { @@ -82,8 +81,8 @@ fn render_finger(query: &str) -> String { host = params[1]; } let mut response = String::new(); - if !check_valid_ip(host) { - response = "![Invalid host]".to_owned(); + if host.contains(":") && !host.ends_with(":79") { + response = "![Invalid port]".to_owned(); } else { response = fingers::finger(user, host) .timeout(1) @@ -100,24 +99,6 @@ fn render_finger(query: &str) -> String { ) } -// prevent hacking -fn check_valid_ip(host: &str) -> bool { - let mut dest = String::new(); - if !host.contains(":") { - dest = format!("{}:80", host); - } - let addr = dest.to_socket_addrs(); - if let Ok(mut a) = addr { - if let Some(n) = a.next() { - if n.ip().is_loopback() { - return false; - } - } - return true; - } - false -} - // Derived from https://github.com/raphlinus/pulldown-cmark/blob/master/src/escape.rs // Don't use single quotes (') in any of your attributes