whois_me fix, I hope.

This commit is contained in:
Andrey Petrov 2014-12-12 22:09:34 -08:00
parent 705cc9e1be
commit 973a06aa75
2 changed files with 6 additions and 6 deletions

View File

@ -146,9 +146,9 @@ func (c *Client) handleShell(channel ssh.Channel) {
if len(parts) == 2 {
client := c.Server.Who(parts[1])
if client != nil {
version := client.Conn.ClientVersion()
version := RE_STRIP_TEXT.ReplaceAllString(string(client.Conn.ClientVersion()), "")
if len(version) > 100 {
version = []byte("Evil Jerk with a superlong string")
version = "Evil Jerk with a superlong string"
}
c.Msg <- fmt.Sprintf("-> %s is %s via %s", client.Name, client.Fingerprint(), version)
} else {

View File

@ -15,7 +15,7 @@ import (
const MAX_NAME_LENGTH = 32
const HISTORY_LEN = 20
var RE_STRIP_NAME = regexp.MustCompile("[^0-9A-Za-z_]")
var RE_STRIP_TEXT = regexp.MustCompile("[^0-9A-Za-z_]")
type Clients map[string]*Client
@ -113,7 +113,7 @@ func (s *Server) Remove(client *Client) {
func (s *Server) proposeName(name string) (string, error) {
// Assumes caller holds lock.
var err error
name = RE_STRIP_NAME.ReplaceAllString(name, "")
name = RE_STRIP_TEXT.ReplaceAllString(name, "")
if len(name) > MAX_NAME_LENGTH {
name = name[:MAX_NAME_LENGTH]
@ -240,9 +240,9 @@ func (s *Server) Start(laddr string) error {
return
}
version := sshConn.ClientVersion()
version := RE_STRIP_TEXT.ReplaceAllString(string(sshConn.ClientVersion()), "")
if len(version) > 100 {
version = []byte("Evil Jerk with a superlong string")
version = "Evil Jerk with a superlong string"
}
logger.Infof("Connection #%d from: %s, %s, %s", s.count+1, sshConn.RemoteAddr(), sshConn.User(), version)