From 18d2c6351db696058262e39c0354e85179349b81 Mon Sep 17 00:00:00 2001 From: Hubix9 <11819738+Hubix9@users.noreply.github.com> Date: Fri, 5 Feb 2021 17:32:01 +0100 Subject: [PATCH] Add whitelist/blacklist support for relay --- relay.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/relay.go b/relay.go index 4630620a..c5d140bd 100644 --- a/relay.go +++ b/relay.go @@ -203,6 +203,13 @@ func (h *relayHandler) Handle(conn net.Conn) { if udp { network = "udp" } + if !Can(network, raddr, h.options.Whitelist, h.options.Blacklist) { + resp.Status = relay.StatusForbidden + resp.WriteTo(conn) + log.Logf("[relay] %s -> %s : relay to %s is forbidden", + conn.RemoteAddr(), conn.LocalAddr(), raddr) + return + } ctx := context.TODO() var cc net.Conn