Skip to content

feat: make HTTP listen on the same IP as OTS#4958

Merged
ArturKnopik merged 5 commits intootland:masterfrom
gesior:feat-make-http-listen-on-the-same-IP-as-OTS
Jul 10, 2025
Merged

feat: make HTTP listen on the same IP as OTS#4958
ArturKnopik merged 5 commits intootland:masterfrom
gesior:feat-make-http-listen-on-the-same-IP-as-OTS

Conversation

@gesior
Copy link
Contributor

@gesior gesior commented Jul 4, 2025

This PR makes it possible to host OTS inside docker with working HTTP server.
After changes from this commit (and #4957 ), you can run local server inside docker with server IP set to 127.0.0.1 in config.lua.
It also fixes problem described in #4945

Example docker-compose.yaml:

services:
  server:
    build:
      context: .
    restart: on-failure
    deploy:
      restart_policy:
        condition: any
        delay: 1s
    volumes:
      - .:/srv
    environment:
      MYSQL_HOST: mariadb
      MYSQL_USER: root
      MYSQL_PASSWORD: root
      MYSQL_DATABASE: tfs
    ports:
      - "7171:7171"
      - "7172:7172"
      - "8080:8080"

  mariadb:
    image: mariadb:latest
    container_name: mariadb-compose
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: tfs
    volumes:
      - ./schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
      - ./docker/data.sql:/docker-entrypoint-initdb.d/02-data.sql
    ports:
      - "3306:3306"

docker/data.sql file to create account tfs@tfs with password tfs and character GOD:

-- e-mail: tfs@tfs password: tfs
INSERT INTO `accounts` (`id`, `name`, `password`, `secret`, `type`, `premium_ends_at`, `email`, `creation`) VALUES ('1', 'tfs', 'e65018eee3ab1e3ecdfc67a91a2aa327434ab5b5', NULL, '6', '0', 'tfs@tfs', '0');
INSERT INTO `players` (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `lookmount`, `lookmounthead`, `lookmountbody`, `lookmountlegs`, `lookmountfeet`, `currentmount`, `randomizemount`, `direction`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `lastlogout`, `blessings`, `onlinetime`, `deletion`, `balance`, `offlinetraining_time`, `offlinetraining_skill`, `stamina`, `skill_fist`, `skill_fist_tries`, `skill_club`, `skill_club_tries`, `skill_sword`, `skill_sword_tries`, `skill_axe`, `skill_axe_tries`, `skill_dist`, `skill_dist_tries`, `skill_shielding`, `skill_shielding_tries`, `skill_fishing`, `skill_fishing_tries`) VALUES ('1', 'GOD', '6', '1', '1', '0', '150', '150', '0', '0', '0', '0', '0', '136', '0', '0', '0', '0', '0', '0', '0', '0', '2', '0', '0', '0', '0', '0', '1', '0', '0', '0', NULL, '400', '0', '0', 0x30, '1', '0', '0', '0', '0', '0', '0', '0', '43200', '-1', '2520', '10', '0', '10', '0', '10', '0', '10', '0', '10', '0', '10', '0', '10', '0');

@gesior gesior mentioned this pull request Jul 5, 2025
3 tasks
@ranisalt
Copy link
Member

ranisalt commented Jul 6, 2025

@Shawak can you confirm this solves the initial issue with Docker?

@Shawak
Copy link
Contributor

Shawak commented Jul 6, 2025

I didnt test it but it should since the game server now binds on ip address any (not sure if it only works for ipv6 ipv4 tho)

@gesior
Copy link
Contributor Author

gesior commented Jul 6, 2025

(not sure if it only works for ipv6 tho)

Tested on Windows (.exe) and using Docker with Linux container, in both cases bind to ip::address_v6::any() worked with login to 127.0.0.1. It's the same code all other ports use (7171/7172).

@ArturKnopik ArturKnopik merged commit 1e040a3 into otland:master Jul 10, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants