mirror of
https://github.com/onyx-and-iris/q3rcon.git
synced 2025-04-19 20:43:51 +01:00
Compare commits
No commits in common. "dd1d530d4423504c72c798d5742d4c1ebda95159" and "a7702c80509e7fe7d99998f7fb79336404fedfe6" have entirely different histories.
dd1d530d44
...
a7702c8050
13
README.md
13
README.md
@ -54,9 +54,7 @@ func main() {
|
|||||||
|
|
||||||
#### `WithLoginTimeout(timeout time.Duration)`
|
#### `WithLoginTimeout(timeout time.Duration)`
|
||||||
|
|
||||||
If the server was just started or is currently performing a long operation like map rotating then it's possible to receive empty rcon responses. In which case you'll want to retry login. Use this functional option to set the max timeout for logins, it defaults to 5 seconds.
|
If the server was just started or is currently performing a long operation like map rotating then it's possible to receive empty rcon responses. In which case you'll want to retry login. Use this functional option to set the max timeout for logins, it defaults to 5 seconds. For example:
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```go
|
```go
|
||||||
rcon, err := q3rcon.New(
|
rcon, err := q3rcon.New(
|
||||||
@ -66,7 +64,7 @@ rcon, err := q3rcon.New(
|
|||||||
|
|
||||||
#### `WithDefaultTimeout(timeout time.Duration)`
|
#### `WithDefaultTimeout(timeout time.Duration)`
|
||||||
|
|
||||||
You may want to change the default timeout if some of your responses are getting mixed together (stability can depend on connection to the server). For example, over localhost I can leave the default at 20ms, when connecting remotely I normally increase this to 50ms.
|
You may want to change the default timeout if some of your responses are getting mixed together (stability can depend on connection to the server). For example, on LAN I can leave the default at 20ms, when connecting remotely I normally increase this to 50ms.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
@ -117,15 +115,10 @@ If interactive mode is enabled, any arguments sent on the command line will be i
|
|||||||
|
|
||||||
## Your own implementation
|
## Your own implementation
|
||||||
|
|
||||||
The included CLI is a generic implementation, while it can be used out of the box you may find that some requests result in fragmented responses. The solution is to implement your own version, adjusting the timings with the functional options as detailed above. I could have increased the default timeouts but that would add unnecessary delay for most requests, so I decided to leave those details to the users of the package.
|
I've separated the q3rcon package from the CLI precisely so that you can write your own implementation, since I don't know the target game or it's commands. For example, in my case I've added terminal colouring and reformatted some of the command responses.
|
||||||
|
|
||||||
Since you can include the q3rcon package into your own package you can easily make your own modifications, for example, I added [colour to the terminal][status] and [reformatted some of the responses][mapname].
|
|
||||||
|
|
||||||
## Logging
|
## Logging
|
||||||
|
|
||||||
Log level may be set by passing the `-l` flag with a number from 0 up to 6 where
|
Log level may be set by passing the `-l` flag with a number from 0 up to 6 where
|
||||||
|
|
||||||
0 = Panic, 1 = Fatal, 2 = Error, 3 = Warning, 4 = Info, 5 = Debug, 6 = Trace
|
0 = Panic, 1 = Fatal, 2 = Error, 3 = Warning, 4 = Info, 5 = Debug, 6 = Trace
|
||||||
|
|
||||||
[status]: ./img/status.png
|
|
||||||
[mapname]: ./img/mapname.png
|
|
||||||
|
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -17,12 +16,6 @@ import (
|
|||||||
|
|
||||||
var interactive bool
|
var interactive bool
|
||||||
|
|
||||||
func exit(err error) {
|
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
|
||||||
flag.Usage()
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
host string
|
host string
|
||||||
@ -64,11 +57,6 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(flag.Args()) == 0 {
|
|
||||||
err = errors.New("no rcon commands passed")
|
|
||||||
exit(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, arg := range flag.Args() {
|
for _, arg := range flag.Args() {
|
||||||
resp, err := rcon.Send(arg)
|
resp, err := rcon.Send(arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -80,7 +68,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func connectRcon(host string, port int, password string) (*q3rcon.Rcon, error) {
|
func connectRcon(host string, port int, password string) (*q3rcon.Rcon, error) {
|
||||||
rcon, err := q3rcon.New(host, port, password)
|
rcon, err := q3rcon.New(
|
||||||
|
host, port, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
BIN
img/mapname.png
BIN
img/mapname.png
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB |
BIN
img/status.png
BIN
img/status.png
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
Loading…
x
Reference in New Issue
Block a user