1
0
Fork 0
forked from External/ergo
add HTTP auth
add an ipc command to nuke a user
This commit is contained in:
CEF Server 2024-07-29 03:30:44 +00:00
parent 979188cf2a
commit 13e1315ad9
3 changed files with 34 additions and 1 deletions

View file

@ -116,6 +116,16 @@ func handleConnection(conn net.Conn, instance *CefConnection) {
} }
} }
break 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: default:
println("Unknown cef message: ", line[0]) println("Unknown cef message: ", line[0])
} }

View file

@ -1459,7 +1459,7 @@ func (channel *Channel) Quit(client *Client) {
client.server.channels.Cleanup(channel) client.server.channels.Cleanup(channel)
} }
client.removeChannel(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) { func (channel *Channel) Kick(client *Client, target *Client, comment string, rb *ResponseBuffer, hasPrivs bool) {

View file

@ -5,8 +5,11 @@ package irc
import ( import (
"bufio" "bufio"
"bytes"
"io" "io"
"net/http"
"os/exec" "os/exec"
"strings"
"syscall" "syscall"
"time" "time"
) )
@ -21,7 +24,27 @@ type scriptResponse struct {
err error 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) { 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...) cmd := exec.Command(command, args...)
stdin, err := cmd.StdinPipe() stdin, err := cmd.StdinPipe()
if err != nil { if err != nil {