mirror of
				https://github.com/onyx-and-iris/q3rcon.git
				synced 2025-11-03 23:11:48 +00:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					b224f2dc43 | ||
| 
						 | 
					c4b587ee65 | ||
| 
						 | 
					8f252951ff | ||
| 35ffa55fb9 | |||
| 
						 | 
					19f5ec4a76 | ||
| 
						 | 
					5173f32fde | 
							
								
								
									
										13
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								CHANGELOG.md
									
									
									
									
									
								
							@ -11,6 +11,19 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-   [x]
 | 
					-   [x]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# [0.3.0] - 2025-04-05
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Changed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-   `-loglevel` flag is now of type string. It accepts any one of trace, debug, info, warn, error, fatal or panic.
 | 
				
			||||||
 | 
					    -   It defaults to warn.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# [0.2.0] - 2025-02-03
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Added
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-   If neither the interactive flag is passed or any command line arguments then a *rcon status* command will be run.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# [0.1.0] - 2024-11-29
 | 
					# [0.1.0] - 2024-11-29
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Changed
 | 
					### Changed
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										25
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								README.md
									
									
									
									
									
								
							@ -109,7 +109,7 @@ Arguments following the flags will be sent as rcon commands. You may send multip
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Pass `interactive (-i shorthand)` flag to enable interactive mode, for example:
 | 
					Pass `interactive (-i shorthand)` flag to enable interactive mode, for example:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```bash
 | 
				
			||||||
q3rcon -h=localhost -p=30000 -r="rconpassword" -i
 | 
					q3rcon -h=localhost -p=30000 -r="rconpassword" -i
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -123,16 +123,31 @@ Since you can include the q3rcon package into your own package you can easily ma
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Logging
 | 
					## Logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Log level may be set by passing the `-l` flag with a number from 0 up to 6 where
 | 
					The `-loglevel` flag allows you to control the verbosity of the application's logging output. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
0 = Panic, 1 = Fatal, 2 = Error, 3 = Warning, 4 = Info, 5 = Debug, 6 = Trace
 | 
					Acceptable values for this flag are:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[status]: ./img/status.png
 | 
					- `trace`
 | 
				
			||||||
[mapname]: ./img/mapname.png
 | 
					- `debug`
 | 
				
			||||||
 | 
					- `info`
 | 
				
			||||||
 | 
					- `warn`
 | 
				
			||||||
 | 
					- `error`
 | 
				
			||||||
 | 
					- `fatal`
 | 
				
			||||||
 | 
					- `panic`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					For example, to set the log level to `debug`, you can use:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					q3rcon -p=28960 -r="rconpassword" -loglevel=debug -i
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The default log level is `warn` if the flag is not specified.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Further Notes
 | 
					## Further Notes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This rcon client is fully compatible with the [Q3 Rcon Proxy][q3rcon-proxy] package.
 | 
					This rcon client is fully compatible with the [Q3 Rcon Proxy][q3rcon-proxy] package.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[status]: ./img/status.png
 | 
				
			||||||
 | 
					[mapname]: ./img/mapname.png
 | 
				
			||||||
[q3rcon-proxy]: https://github.com/onyx-and-iris/q3rcon-proxy/tree/dev
 | 
					[q3rcon-proxy]: https://github.com/onyx-and-iris/q3rcon-proxy/tree/dev
 | 
				
			||||||
@ -6,7 +6,6 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"slices"
 | 
					 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/onyx-and-iris/q3rcon"
 | 
						"github.com/onyx-and-iris/q3rcon"
 | 
				
			||||||
@ -25,7 +24,7 @@ func main() {
 | 
				
			|||||||
		port        int
 | 
							port        int
 | 
				
			||||||
		rconpass    string
 | 
							rconpass    string
 | 
				
			||||||
		interactive bool
 | 
							interactive bool
 | 
				
			||||||
		loglevel    int
 | 
							loglevel    string
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.StringVar(&host, "host", "localhost", "hostname of the gameserver")
 | 
						flag.StringVar(&host, "host", "localhost", "hostname of the gameserver")
 | 
				
			||||||
@ -38,13 +37,16 @@ func main() {
 | 
				
			|||||||
	flag.BoolVar(&interactive, "interactive", false, "run in interactive mode")
 | 
						flag.BoolVar(&interactive, "interactive", false, "run in interactive mode")
 | 
				
			||||||
	flag.BoolVar(&interactive, "i", false, "run in interactive mode")
 | 
						flag.BoolVar(&interactive, "i", false, "run in interactive mode")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.IntVar(&loglevel, "loglevel", int(log.WarnLevel), "log level")
 | 
						flag.StringVar(&loglevel, "loglevel", "warn", "log level")
 | 
				
			||||||
	flag.IntVar(&loglevel, "l", int(log.WarnLevel), "log level (shorthand)")
 | 
						flag.StringVar(&loglevel, "l", "warn", "log level (shorthand)")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if slices.Contains(log.AllLevels, log.Level(loglevel)) {
 | 
						level, err := log.ParseLevel(loglevel)
 | 
				
			||||||
		log.SetLevel(log.Level(loglevel))
 | 
						if err != nil {
 | 
				
			||||||
 | 
							exitOnError(fmt.Errorf("invalid log level: %s", loglevel))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						log.SetLevel(level)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if port < 1024 || port > 65535 {
 | 
						if port < 1024 || port > 65535 {
 | 
				
			||||||
		exitOnError(fmt.Errorf("invalid port value, got: (%d) expected: in range 1024-65535", port))
 | 
							exitOnError(fmt.Errorf("invalid port value, got: (%d) expected: in range 1024-65535", port))
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@ -4,4 +4,4 @@ go 1.23.0
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require github.com/sirupsen/logrus v1.9.3
 | 
					require github.com/sirupsen/logrus v1.9.3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require golang.org/x/sys v0.25.0 // indirect
 | 
					require golang.org/x/sys v0.34.0 // indirect
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							@ -9,8 +9,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
 | 
				
			|||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 | 
					github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
 | 
				
			||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
					github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
 | 
					golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
 | 
				
			||||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 | 
					golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
 | 
				
			||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
					gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
				
			||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
 | 
					gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
 | 
				
			||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
					gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,8 @@ package packet
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						log "github.com/sirupsen/logrus"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const bufSz = 512
 | 
					const bufSz = 512
 | 
				
			||||||
@ -29,5 +31,6 @@ func (r Request) Encode(cmd string) []byte {
 | 
				
			|||||||
	r.buf.Reset()
 | 
						r.buf.Reset()
 | 
				
			||||||
	r.buf.Write(r.Header())
 | 
						r.buf.Write(r.Header())
 | 
				
			||||||
	r.buf.WriteString(fmt.Sprintf(" %s %s", r.password, cmd))
 | 
						r.buf.WriteString(fmt.Sprintf(" %s %s", r.password, cmd))
 | 
				
			||||||
 | 
						log.Tracef("Encoded request: %s", r.buf.String())
 | 
				
			||||||
	return r.buf.Bytes()
 | 
						return r.buf.Bytes()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user