add: sshsvc support telnet server
This commit is contained in:
@@ -144,7 +144,14 @@ func handleAuth(authType, userName, password string) bool {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
case "radius":
|
||||
exist, err := dborm.XEngDB().Table("OMC_PUB.sysUser").Where("userName=? AND password=md5(?)", userName, password).Exist()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return exist
|
||||
case "omc":
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -236,7 +243,7 @@ func handleTelnetConnection(conn net.Conn) {
|
||||
if handleAuth(conf.TelnetServer.AuthType, user, pass) {
|
||||
writer.WriteString("\nAuthentication successful!\n")
|
||||
writer.Flush()
|
||||
handleCommands(user, reader, writer)
|
||||
handleCommands(user, conf.TelnetServer.TagNE, reader, writer)
|
||||
} else {
|
||||
writer.WriteString("\nAuthentication failed!\n")
|
||||
writer.Flush()
|
||||
@@ -244,8 +251,8 @@ func handleTelnetConnection(conn net.Conn) {
|
||||
}
|
||||
|
||||
// 处理命令输入
|
||||
func handleCommands(user string, reader *bufio.Reader, writer *bufio.Writer) {
|
||||
header := fmt.Sprintf("[%s@omc]> ", user)
|
||||
func handleCommands(user, tag string, reader *bufio.Reader, writer *bufio.Writer) {
|
||||
header := fmt.Sprintf("[%s@%s]> ", user, tag)
|
||||
for {
|
||||
command, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
@@ -368,7 +375,7 @@ func handleSSHShell(sshConn *ssh.ServerConn, channel ssh.Channel) {
|
||||
// 检查通道是否支持终端
|
||||
|
||||
omcMmlVar := &mmlp.MmlVar{
|
||||
Version: "16.1.1",
|
||||
Version: global.Version,
|
||||
Output: mmlp.DefaultFormatType,
|
||||
MmlHome: conf.Sshd.MmlHome,
|
||||
Limit: 50,
|
||||
@@ -376,9 +383,10 @@ func handleSSHShell(sshConn *ssh.ServerConn, channel ssh.Channel) {
|
||||
SessionToken: fmt.Sprintf("%x", sshConn.SessionID()),
|
||||
HttpUri: conf.OMC.HttpUri,
|
||||
UserAgent: config.GetDefaultUserAgent(),
|
||||
TagNE: conf.Sshd.TagNE,
|
||||
}
|
||||
|
||||
term := term.NewTerminal(channel, fmt.Sprintf("[%s@omc]> ", omcMmlVar.User))
|
||||
term := term.NewTerminal(channel, fmt.Sprintf("[%s@%s]> ", omcMmlVar.User, omcMmlVar.TagNE))
|
||||
// 启动交互式shell会话
|
||||
for {
|
||||
line, err := term.ReadLine()
|
||||
|
||||
Reference in New Issue
Block a user