haveachin / infrared

An ultra lightweight minecraft reverse proxy and idle placeholder
https://infrared.dev
GNU Affero General Public License v3.0
722 stars 60 forks source link

SRV records may not be routed correctly. #172

Open viasnake opened 1 year ago

viasnake commented 1 year ago

Describe the bug When using SRV records, the domain of the target is referenced. As a result, routing does not work correctly.

To Reproduce OS: Ubuntu 22.04.2 LTS (ARM) Infrared Version: ghcr.io/haveachin/infrared:2.0.0-alpha.13 Docker compose:

version: '3'

services:
  infrared:
    image: ghcr.io/haveachin/infrared:2.0.0-alpha.13
    volumes:
      - ./infrared:/infrared
    ports:
      - target: 25565
        published: 25565
        protocol: tcp
        mode: host
    environment:
      INFRARED_CONFIG_PATH: "/configs"
    deploy:
      mode: global

Infrared Config: server.yml

java:
  gateways:
    default:
      listeners:
        default:
          bind: :25565
  servers:
    server1:
      gateways:
        - default
      domains:
        - "mc1.example.com"
      address: 192.0.2.1:25565
      sendProxyProtocol: true
    server2:
      gateways:
        - default
      domains:
        - "servers.example.com"
      address: 192.0.2.2:25565
      sendProxyProtocol: true
    server3:
      gateways:
        - default
      domains:
        - "*"
      address: 192.0.2.3:25565
      sendProxyProtocol: true

How do you trigger the bug/issue?:

  1. After a basic set-up of Infrared, set up the Infrared config.
  2. DNS configuration. Shown below is the case for example.com.
    
    ;; A Records
    servers.example.com.    1   IN  A   203.0.113.1
    servers.example.com.    1   IN  A   203.0.113.2
    servers.example.com.    1   IN  A   203.0.113.3
    servers.example.com.    1   IN  A   203.0.113.4

;; SRV Records _minecraft._tcp.mc1.example.com. 1 IN SRV 1 100 25565 servers.example.com.


3. Connect to the Minecraft server at `mc1.example.com`. You will then be connected to `192.0.2.2:25565`.

**Expected behavior**
If you connect on `mc1.example.com`, you will be routed to `192.0.2.1:25565`.

**Additional context**
I have only checked this with the Java Edition; it is possible that the Bedrock Editon may behave similarly, but since the Bedrock Edition does not allow the use of SRV records, I don't think this will be an issue.
haveachin commented 1 year ago

Great issue description. I'll look into it as soon as I have the time.

yoblex commented 1 year ago

solved the problem?

haveachin commented 1 year ago

Not yet, I'm trying to fit in some time to catch up with the backlog of tickets as soon as I have the time. I would also really appreciate some more active maintainers, but I'll probably need to write some more documentation until someone is brave enough to touch the code 😕