support regex and player name sniff
This commit is contained in:
+4
-2
@@ -191,7 +191,8 @@ func (c *Client) dispatchControl(payload []byte) {
|
||||
pattern, _ := r.String()
|
||||
ip, _ := r.String()
|
||||
port, _ := r.U16()
|
||||
go c.handleControlRequest(cid, pattern, ip, int(port))
|
||||
username, _ := r.String()
|
||||
go c.handleControlRequest(cid, pattern, ip, int(port), username)
|
||||
case CtlPong:
|
||||
// ignore
|
||||
default:
|
||||
@@ -217,12 +218,13 @@ func (c *Client) pingLoop(ctx context.Context, fc *wire.FramedConn) {
|
||||
|
||||
// handleControlRequest reacts to a matched player: allocate a worker stream,
|
||||
// SYN it, and bridge it to the mapped destination.
|
||||
func (c *Client) handleControlRequest(cid []byte, pattern, ip string, port int) {
|
||||
func (c *Client) handleControlRequest(cid []byte, pattern, ip string, port int, username string) {
|
||||
mapping, ok := c.mappings[NormalizeAddress(pattern)]
|
||||
if !ok {
|
||||
log.Printf("control-request for unmapped pattern %q; ignoring", pattern)
|
||||
return
|
||||
}
|
||||
log.Printf("player %s:%d joined as %q via pattern %q -> %s", ip, port, username, pattern, mapping.Destination)
|
||||
wc, sid, err := c.pool.Allocate()
|
||||
if err != nil {
|
||||
log.Printf("worker allocate failed: %v", err)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"pingIntervalMs": 20000,
|
||||
"mappings": [
|
||||
{
|
||||
"pattern": "mc.example.com",
|
||||
"pattern": "mc\\.example\\.com",
|
||||
"destination": "127.0.0.1:25566",
|
||||
"proxyProtocol": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user