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
|
|
@ -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