Prepared mode handling; removed debug output of cmd lines for security reasons

This commit is contained in:
Andreas Neue 2016-07-25 12:07:02 +02:00
parent f844505c17
commit c27ccdf0e9
2 changed files with 31 additions and 5 deletions

View File

@ -190,7 +190,6 @@ func (cl *RemoteClient) writeLine(format string, a ...interface{}) {
} }
func (cl *RemoteClient) handleCmd(s string) { func (cl *RemoteClient) handleCmd(s string) {
xlog.Debug("handleCmd: [%s] '%s'", cl.name, s)
msg := irc.Parse(s) msg := irc.Parse(s)
msg.Cmd = strings.ToUpper(msg.Cmd) msg.Cmd = strings.ToUpper(msg.Cmd)
if cl.name != "" { if cl.name != "" {

View File

@ -40,7 +40,7 @@ type Server struct {
chUsers map[string]map[string]string chUsers map[string]map[string]string
chTopics map[string]string chTopics map[string]string
chModes map[string]map[string]bool
config *conf.ConfigFile config *conf.ConfigFile
configPath string configPath string
@ -62,6 +62,7 @@ func NewServer(configPath, software, version string) *Server {
sv.clients = make(map[string]Client) sv.clients = make(map[string]Client)
sv.chUsers = make(map[string]map[string]string) sv.chUsers = make(map[string]map[string]string)
sv.chTopics = make(map[string]string) sv.chTopics = make(map[string]string)
sv.chModes = make(map[string]map[string]bool)
sv.configPath = configPath sv.configPath = configPath
sv.loadConfig() sv.loadConfig()
@ -325,6 +326,7 @@ func handleCmdJoin(sv *Server, msg *irc.Message) {
if _, exists := sv.chUsers[chid]; !exists { if _, exists := sv.chUsers[chid]; !exists {
sv.chUsers[chid] = make(map[string]string) sv.chUsers[chid] = make(map[string]string)
sv.chTopics[chid] = "" sv.chTopics[chid] = ""
sv.chModes[chid] = make(map[string]map[string]bool)
} }
if _, exists := sv.chUsers[chid][clid]; exists { if _, exists := sv.chUsers[chid][clid]; exists {
return return
@ -354,7 +356,32 @@ func handleCmdQuit(sv *Server, msg *irc.Message) {
} }
func handleCmdMode(sv *Server, msg *irc.Message) { func handleCmdMode(sv *Server, msg *irc.Message) {
if strings.HasPrefix(msg.Args[0], "#") {
chid := strings.ToLower(msg.Args[0])
if _, exists := chUsers[chid]; !exists {
return
}
if _, exists = msg.Args[1]; !exists {
return
}
modeFlag := strings.ToLower(msg.Args[1])
if _, exists = msg.Args[2]; !exists {
modeTar := ""
} else {
modeTar := strings.ToLower(msg.Args[2])
}
switch modeFlag {
case "+o":
case "-o":
case "+h":
case "-h":
case "+b":
case "-b":
case "+v":
case "-v":
}
sv.sendMsg(msg)
}
} }
func handleCmdTopic(sv *Server, msg *irc.Message) { func handleCmdTopic(sv *Server, msg *irc.Message) {