diff options
-rw-r--r-- | rsham.go | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -90,10 +90,17 @@ func sshHandleConnection(mode string, nConn net.Conn, config *ssh.ServerConfig) ip := nConn.RemoteAddr().String()[:strings.LastIndex(nConn.RemoteAddr().String(), ":")] sshLog.Info("adding drop rule to iptables for ip", "ip", ip) - cmd := exec.Command("iptables", "-I", "INPUT", "-s", ip, "-j", "DROP") - out, err := cmd.CombinedOutput() - if err != nil { - sshLog.Error("error blocking IP", "ip", ip, "error", err, "command output", out) + + // var cmd *exec.Cmd + if ip[0] == '[' { + sshLog.Error("ipv6 blocking not implemented", "ip", ip) + + } else { + cmd := exec.Command("iptables", "-I", "INPUT", "-s", ip, "-j", "DROP") + out, err := cmd.CombinedOutput() + if err != nil { + sshLog.Error("error blocking IP", "ip", ip, "error", err, "command output", string(out)) + } } nConn.Close() |