fix: snmpv3 in ipv6
This commit is contained in:
@@ -379,7 +379,7 @@ func handleSSHConnection(conn net.Conn, serverConfig *ssh.ServerConfig) {
|
||||
if sshCC > int(conf.Sshd.MaxConnNum) {
|
||||
sshMu.Unlock()
|
||||
log.Error("Maximum number of connections exceeded")
|
||||
//conn.Write([]byte("Reach max connections"))
|
||||
channel.Write([]byte(fmt.Sprintf("Connection limit reached (limit=%d). Try again later.\r\n", conf.Sshd.MaxConnNum)))
|
||||
conn.Close()
|
||||
continue
|
||||
}
|
||||
@@ -446,15 +446,19 @@ func handleSSHShell(sshConn *ssh.ServerConn, channel ssh.Channel) {
|
||||
Version: global.Version,
|
||||
Output: mmlp.DefaultFormatType,
|
||||
MmlHome: conf.Sshd.MmlHome,
|
||||
Limit: 50,
|
||||
Limit: conf.Sshd.MaxConnNum,
|
||||
User: sshConn.User(),
|
||||
SessionToken: fmt.Sprintf("%x", sshConn.SessionID()),
|
||||
HttpUri: conf.OMC.HttpUri,
|
||||
UserAgent: config.GetDefaultUserAgent(),
|
||||
TagNE: conf.Sshd.TagNE,
|
||||
}
|
||||
|
||||
term := term.NewTerminal(channel, fmt.Sprintf("[%s@%s]> ", omcMmlVar.User, omcMmlVar.TagNE))
|
||||
msg := fmt.Sprintf("\r\nWelcome to the %s server!\r\n", strings.ToUpper(omcMmlVar.TagNE))
|
||||
term.Write([]byte(msg))
|
||||
msg = fmt.Sprintf("Last login: %s from %s \r\n\r\n", time.Now().Format(time.RFC1123), sshConn.RemoteAddr())
|
||||
term.Write([]byte(msg))
|
||||
|
||||
// 启动交互式shell会话
|
||||
for {
|
||||
line, err := term.ReadLine()
|
||||
@@ -472,6 +476,13 @@ func handleSSHShell(sshConn *ssh.ServerConn, channel ssh.Channel) {
|
||||
}
|
||||
var response string
|
||||
switch cmdline {
|
||||
case "hello":
|
||||
term.Write([]byte("Hello, world!\r\n"))
|
||||
goto continueLoop
|
||||
case "time":
|
||||
response = fmt.Sprintf("Current time: %s\r\n", time.Now().Format(time.RFC1123))
|
||||
term.Write([]byte(response))
|
||||
goto continueLoop
|
||||
case "exit", "quit":
|
||||
goto exitLoop
|
||||
case "":
|
||||
|
||||
Reference in New Issue
Block a user