From bec78b4f5c32f54fd693f188eb5f2130b95508e8 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Thu, 28 Feb 2019 00:51:20 +0100 Subject: Bind to IPv6 socket On Linux this will accept connections for both IPv4 and IPv6, if /proc/sys/net/ipv6/bindv6only is not set (which is the default). --- src/tftpd.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tftpd.rs b/src/tftpd.rs index dd3d875..02acb14 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -136,7 +136,7 @@ impl Tftpd { } pub fn handle_client(&mut self, cl: &SocketAddr, buf: &[u8]) -> Result<(), io::Error> { - let socket = UdpSocket::bind("0.0.0.0:0")?; + let socket = UdpSocket::bind("[::]:0")?; socket.connect(cl)?; socket.set_read_timeout(Some(Duration::from_secs(5)))?; @@ -190,7 +190,7 @@ impl Tftpd { } pub fn start(&mut self) { - let socket = match UdpSocket::bind(format!("0.0.0.0:{}", self.conf.port)) { + let socket = match UdpSocket::bind(format!("[::]:{}", self.conf.port)) { Ok(s) => s, Err(err) => { println!("Binding a socket failed: {}", err); -- cgit v1.2.3