forked from External/ergo
fix kick
add HTTP auth add an ipc command to nuke a user
This commit is contained in:
parent
979188cf2a
commit
13e1315ad9
3 changed files with 34 additions and 1 deletions
10
irc/cef.go
10
irc/cef.go
|
|
@ -116,6 +116,16 @@ func handleConnection(conn net.Conn, instance *CefConnection) {
|
|||
}
|
||||
}
|
||||
break
|
||||
case "FULLYREMOVE":
|
||||
user := instance.server.clients.Get(line[1])
|
||||
if user != nil {
|
||||
user.destroy(nil)
|
||||
err := instance.server.accounts.Unregister(user.Account(), true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
println("Unknown cef message: ", line[0])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1459,7 +1459,7 @@ func (channel *Channel) Quit(client *Client) {
|
|||
client.server.channels.Cleanup(channel)
|
||||
}
|
||||
client.removeChannel(channel)
|
||||
client.server.cefManager.KickBroadcast(channel.name, client.Username())
|
||||
client.server.cefManager.KickBroadcast(channel.name, client.Nick())
|
||||
}
|
||||
|
||||
func (channel *Channel) Kick(client *Client, target *Client, comment string, rb *ResponseBuffer, hasPrivs bool) {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ package irc
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -21,7 +24,27 @@ type scriptResponse struct {
|
|||
err error
|
||||
}
|
||||
|
||||
func RunHttp(command string, args []string, input []byte, timeout time.Duration) (output []byte, err error) {
|
||||
client := http.Client{
|
||||
Timeout: timeout,
|
||||
}
|
||||
post, err := client.Post(command, "application/json", bytes.NewBuffer(input))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer post.Body.Close()
|
||||
output, err = io.ReadAll(post.Body)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func RunScript(command string, args []string, input []byte, timeout, killTimeout time.Duration) (output []byte, err error) {
|
||||
if strings.HasPrefix(command, "http") {
|
||||
return RunHttp(command, args, input, timeout)
|
||||
}
|
||||
cmd := exec.Command(command, args...)
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue