Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telnet server to Alpha-Core #1352

Closed
wants to merge 54 commits into from
Closed

Conversation

diff3
Copy link
Contributor

@diff3 diff3 commented Mar 25, 2024

  • Telnet server on port 3443
    Just basic commands, more in the future
    Activate it in config.yml
  • Added a Makefile for docker (linux/unix systems only)
    run make to see a list of commands from shell
  • updated Python to 3.12 and Alpine 3.19
  • Added a way to add modules to WorldManager.py
  • Added a database update script
  • Updated Logger with some new methods for telnet


# Add more module starts here as needed

def startTelnetCommandHandler(self, parent_conn):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure all method names use snake_case naming convention.

utils/Logger.py Outdated
Logger.info(msg, end='\r')
else:
Logger.success(msg)
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Exception can trigger from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure I remove it.

@staticmethod
def _handle_command(command_dict, parent_conn):
if parent_conn:
Logger.set_parent_conn(parent_conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are already doing this in start_telnet method, no? Maybe I'm mistaken but not sure if it's needed in both places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I made that decision because I needed to assign it within each parallell process I wanted to access. I'm sending data two way between telnet processes and the other processes with multiprocessing.Pipe()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check if I could use some other method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I had to watch my code and figure out what I was thinking.

  • I pipe messages between all processes and telnet process. It's two way.
  • The information I send to telnet are log messages. That why I need to stay inside the process. and that's why I got a method in Logger class to set parent_conn (for each object/ process)
  • Every time Logger is called and Logger.parent_conn is set within the process. It will send all output to TelnetServer
  • In Logger I made some changes, so I can change log level to telnet server separately, cos ut was driving me mad having debug output in telnet
  • Telnet server can also send commands, and it's handled by CommandHandler and CommandManager in telnet module.
  • basically it tap into a player session and commit the command, or use the world session.
  • the reason I made another command Manager is because otherwise player will have all output, not telnet, and it also demand more feedback because you don't see there monitor.


def starts(parent_conn=None):
if parent_conn:
Logger.set_parent_conn(parent_conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated / redundant assignment too? Not sure.

main.py Outdated
if launch_world:
world_process = context.Process(target=WorldManager.WorldServerSessionHandler.start)
world_process = context.Process(target=WorldManager.WorldServerSessionHandler.start,args=(world_conn,))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space.

def start(parent_conn=None):

if parent_conn:
Logger.set_parent_conn(parent_conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, redundant / duplicated code? Also extra newline on top.

def start_realm(parent_conn=None):

if parent_conn:
Logger.set_parent_conn(parent_conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other comments.

def start_proxy():
def start_proxy(parent_conn=None):
if parent_conn:
Logger.set_parent_conn(parent_conn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other comments.

Logger.info("MySQL didn't become ready within 2 minutes")
exit(1)

test()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this class being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it was a test I made for main process to halt until DB is up and running. It's not used.

@GrenderG
Copy link
Member

GrenderG commented May 2, 2024

Why the Logger.py file has been deleted?

@diff3
Copy link
Contributor Author

diff3 commented May 2, 2024

not sure, by mistake I believe

@celguar
Copy link

celguar commented May 2, 2024

btw not sure what database-update.sh is not called docker-database-update.sh or something. Is in main folder, and one would assume it's for everyone, not only for docker users

@diff3
Copy link
Contributor Author

diff3 commented May 5, 2024

database-update.sh it's just a standalone script for updating the database

@celguar
Copy link

celguar commented May 5, 2024

So it will work on my windows setup? I don't use docker

@diff3
Copy link
Contributor Author

diff3 commented May 5, 2024

hmm not it's for docker, but I can do a small rewrite so it can work for both

@celguar
Copy link

celguar commented May 5, 2024

etc/docker/sql/build_sql_patches.sh that's where this repo have sql scripts for docker I believd

@celguar
Copy link

celguar commented May 5, 2024

In top directory is quite confusing. And making it work on windows doesn't seem worth the effort as there can be any amount of setups with different mariadb versions etc...

@diff3 diff3 closed this May 24, 2024
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.

None yet

3 participants