diff options
author | 2016-04-10 11:59:16 +0200 | |
---|---|---|
committer | 2016-04-10 11:59:16 +0200 | |
commit | 6b4fe2a2b3ffb4e4832cf347088051781d83d7a3 (patch) | |
tree | 0942248a0c411735bd4d6eed1fd57b8001f9b1d9 | |
parent | 48b968d27e761aca07038f9ddefb51db0a271d00 (diff) |
-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() |