mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2026-04-20 05:53:32 +00:00
Compare commits
5 Commits
0.1.0
...
88c90f1447
| Author | SHA1 | Date | |
|---|---|---|---|
| 88c90f1447 | |||
| 561b1ca654 | |||
| a3219e63c2 | |||
| ceb87e14fd | |||
| 2b7af34457 |
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -9,7 +9,7 @@
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "${workspaceFolder}/cmd/q3rcon_proxy/main.go",
|
||||
"program": "${workspaceFolder}/cmd/q3rcon-proxy/main.go",
|
||||
"env": {
|
||||
"Q3RCON_PROXY": "28961:28960",
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
||||
|
||||
## [0.1.0] - 2024-01-27
|
||||
|
||||
- ignore any packets whose header does match a q3 rcon/query packet.
|
||||
- only forward packets if the header matches q3 rcon/query.
|
||||
|
||||
## [0.0.1] - 2024-01-27
|
||||
|
||||
|
||||
14
Dockerfile
14
Dockerfile
@@ -1,12 +1,14 @@
|
||||
FROM golang:alpine
|
||||
FROM golang:1.21
|
||||
|
||||
WORKDIR /dist
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY . .
|
||||
|
||||
# build binary and place into /usr/local/bin
|
||||
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && go mod verify
|
||||
RUN go build -v -o /usr/local/bin/q3rcon-proxy ./cmd/q3rcon-proxy
|
||||
|
||||
# build binary and place into /usr/local/bin/
|
||||
COPY . .
|
||||
RUN go build -v -o /usr/local/bin/q3rcon-proxy ./cmd/q3rcon-proxy/
|
||||
|
||||
# Command to run when starting the container
|
||||
ENTRYPOINT [ "q3rcon-proxy" ]
|
||||
@@ -12,13 +12,13 @@ for example:
|
||||
export Q3RCON_PROXY="20000:28960;20001:28961;20002:28962"
|
||||
```
|
||||
|
||||
This would run 3 proxy servers listening on ports `20000`, `20001` and `20002` that redirect rcon requests to game servers on ports `28960`, `28961` and `28962` respectively.
|
||||
This would configure q3rcon-proxy to run 3 proxy servers listening on ports `20000`, `20001` and `20002` that redirect rcon requests to game servers on ports `28960`, `28961` and `28962` respectively.
|
||||
|
||||
Then just run the binary which you can compile yourself, download from `Releases` or use the included Dockerfile.
|
||||
|
||||
### Why
|
||||
|
||||
Avoid sending plaintext rcon requests (that include the password) to public ports. Instead send them to whitelisted ports.
|
||||
|
||||
Gives you the option to disable remote rcon entirely and have the server accept requests only from localhost.
|
||||
Avoid sending plaintext rcon commands to the public game server port. In general I would advise anyone using rcon remotely to use a secured connection but perhaps you've passed rcon to a clan friend who doesn't know about secured connections. Now you can instruct them to use rcon only through a whitelisted port.
|
||||
|
||||
### Special Thanks
|
||||
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
package udpproxy
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSendAndReceive(t *testing.T) {
|
||||
go runLilProxy()
|
||||
go runUDPServer()
|
||||
|
||||
paddr, err := net.ResolveUDPAddr("udp", "localhost:9000")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
conn, err := net.DialUDP("udp", nil, paddr)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
buf := make([]byte, 2048)
|
||||
_, _, err = conn.ReadFromUDP(buf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Printf("response received: %s", string(buf))
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
time.Sleep(1 * time.Second)
|
||||
_, err = conn.Write([]byte("hi\n"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runLilProxy() {
|
||||
port := ":9000"
|
||||
target := "localhost:9001"
|
||||
|
||||
c, err := New(port, target)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Fatal(c.ListenAndServe())
|
||||
}
|
||||
|
||||
func runUDPServer() {
|
||||
taddr, err := net.ResolveUDPAddr("udp", ":9001")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
conn, err := net.ListenUDP("udp", taddr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for {
|
||||
buf := make([]byte, 2048)
|
||||
_, caddr, err := conn.ReadFromUDP(buf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Printf("request received: %s", string(buf))
|
||||
|
||||
_, err = conn.WriteToUDP([]byte("bye\n"), caddr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user