Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7203acb
Create pythonapp.yml
Nov 11, 2019
6d85a18
Test
otmah Nov 11, 2019
ce02b56
update
otmah Nov 21, 2019
5f95070
test
otmah Nov 22, 2019
712c5f4
test
otmah Nov 22, 2019
a5b2c99
Merge branch 'master' into github-actions
Dec 25, 2020
6a40bf7
Update pythonapp.yml
Dec 25, 2020
d07373d
Update pythonapp.yml
Dec 25, 2020
888840f
Update pythonapp.yml
Dec 25, 2020
8ef9f05
Update pythonapp.yml
Dec 25, 2020
f5a8159
Update pythonapp.yml
Dec 25, 2020
a7eeeba
Update pythonapp.yml
Dec 25, 2020
c0596a5
Update pythonapp.yml
Dec 25, 2020
9e4e200
Update pythonapp.yml
Dec 25, 2020
7a26a3d
Update pythonapp.yml
Dec 25, 2020
db101c6
Update server_config.py
Dec 25, 2020
4d20c34
Update main.py
Dec 25, 2020
a9846d3
Update pythonapp.yml
Jun 23, 2021
c9cd87a
Update logon.conf
Jun 23, 2021
0825050
Update logon.conf
Jun 23, 2021
18f49fc
Update pythonapp.yml
Jun 23, 2021
f04cea0
Update pythonapp.yml
Jun 23, 2021
42087c9
Update pythonapp.yml
Jun 23, 2021
94e62e2
Update pythonapp.yml
Jun 23, 2021
15cf365
Update pythonapp.yml
Jun 23, 2021
1336bbe
Update logon.conf
Jun 23, 2021
340e939
Update logon.conf
Jun 23, 2021
965540c
Update pythonapp.yml
Jun 23, 2021
507253e
Update pythonapp.yml
Jun 23, 2021
f6259fd
Update pythonapp.yml
Jun 23, 2021
3299b15
Update pythonapp.yml
otmah Jun 24, 2021
716bb04
update launch.json
otmah Jun 25, 2021
618546e
trial and error <_<
otmah Jun 25, 2021
19f0abb
trial and error >_<
otmah Jun 29, 2021
ac6da0a
Update settings.json
Jul 1, 2021
8ef06ad
Merge branch 'github-actions' of https://github.com/Cestra/pyCestra i…
Jul 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python application

on: [push]

jobs:
pyCestaTest:
runs-on: ubuntu-latest

env:
DB_USER: root
DB_PASSWORD: 'root'
DB_HOST: 127.0.0.1

steps:
- name: Creation of the databases
- run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE cestra_logon;' -uroot -proot
mysql -e 'CREATE DATABASE cestra_world;' -uroot -proot
mysql -e 'SHOW DATABASES;' -uroot -proot

- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mysql-connector-python

- name: Server start
run: |
python logon/src/main.py
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
"program": "${workspaceFolder}/logon/src/main.py",
"console": "integratedTerminal"
},
{
"name": "Cestra args test",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/logon/src/main.py",
"console": "integratedTerminal",
"args": ["-m","1","10"]
},
{
"name": "Python: current file",
"type": "python",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.pythonPath": "C:\\Program Files (x86)\\Python38-32\\python.exe",
"python.pythonPath": "C:\\python\\python.exe",
"maven.view": "flat",
"files.exclude": {
"**/.classpath": true,
Expand Down
38 changes: 38 additions & 0 deletions action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'''
pyCestra - Open Source MMO Framework
Copyright (C) 2020 pyCestra Team

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''

import os
import threading
from typing_extensions import runtime

runtime = 30
name = ["logon-Server","world-Server","server-unittest"]

def lthread():
try:
t = threading.Thread(target=logonServer,name=name[0],args=runtime)
t.start()
except threading.ThreadError as e:
print('Login Server could not be created: ' + str(e))

def logonServer():
os.system('python logon/src/main.py')
pass


testthread()
2 changes: 1 addition & 1 deletion logon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ logon_database_ip = 127.0.0.1
logon_database_port = 3306
logon_database_name = cestra_logon
logon_database_user = root
logon_database_pass = fabio312
logon_database_pass = root
logon_database_update_service = 40

[RealmList Configuration]
Expand Down
2 changes: 1 addition & 1 deletion logon/src/core/server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_default_logon_config(self):
'network_realmList_ip': '127.0.0.1',
'network_realmList_port': '451'
}
with open('./logon.conf', 'w') as configfile: # save
with open('./logon.conf', 'w', encoding='utf-8') as configfile: # save
self.config.write(configfile)
return True
except:
Expand Down
3 changes: 2 additions & 1 deletion logon/src/exchange/exchange_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'''

import socket
import sys
import threading

from core.logging_handler import Logging
Expand Down Expand Up @@ -44,13 +45,13 @@ def server(self, ex_ip, ex_port, hostList):
s.bind((ex_ip, ex_port))
except socket.error:
self.log.warning('Exchange Socket - Binding faild')
sys.exit()
s.listen()
self.log.info('Exchange Socket is listening on Port: ' + str(ex_port))
while True:
c, self.addr = s.accept()
self.log.info('Exchange Client connected '+ str(self.addr[0])+ ':'+ str(self.addr[1]))
ExchangeServer().session_created(c, self.addr, hostList)
s.close()

def session_created(self, soecket, addr, hostList):
threadName = 'Exchange-Client '+str(addr[0])+':'+ str(addr[1])
Expand Down
51 changes: 34 additions & 17 deletions logon/src/login/login_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import socket
import threading
import sys

from core.logging_handler import Logging
from login.login_handler import LoginHandler
Expand All @@ -34,33 +35,49 @@ def __init__(self, ip, port, gameClientDic, accountDataDic, hostList, ipBans):
self.hostList = hostList
self.ipBans = ipBans

self.defaultrRun = True

self.start()

def start(self):
threadName = 'Login-Server - ' + str(self.logonPort)
try:
t = threading.Thread(target=self.server,
name=threadName,
args=(self.logoniIP, self.logonPort,
self.gameClientDic, self.accountDataDic,
self.hostList, self.ipBans))
t.start()
self.t = threading.Thread(target=self.server,
name=threadName,
args=(self.defaultrRun,))
self.t.start()
except threading.ThreadError as e:
self.log.warning('Login Server could not be created: ' + str(e))

def server(self, logoniIP, logonPort, gameClientDic, accountDataDic, hostList, ipBans):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def server(self, arg):
do_run = arg
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind((self.logoniIP, self.logonPort))
self.s.bind((self.logoniIP, self.logonPort))
self.s.listen()
self.log.info('Logon Socket is listening on Port: ' + str(self.logonPort))
except socket.error:
print('Login Socket - Binding faild')
s.listen()
self.log.info('Logon Socket is listening on Port: ' + str(self.logonPort))
while True:
c, self.addr = s.accept()
self.log.info('[{}:{}] Client Connected '.format(str(self.addr[0]),str(self.addr[1])))
self.session_created(c, self.addr)
s.close()
self.log.warning('Login Socket - Binding faild')
sys.exit()
while do_run:
self.log.warning("while loop")
try:
c, self.addr = self.s.accept()
self.log.info('[{}:{}] Client Connected '.format(str(self.addr[0]),str(self.addr[1])))
self.session_created(c, self.addr)
except socket.timeout:
self.log.info("[{}:{}] Login Socket - TIMEOUT".format(str(self.addr[0]),str(self.addr[1])))
continue
except OSError:
self.log.info("[{}:{}] Login Socket was killed".format(str(self.addr[0]),str(self.addr[1])))
self.s.close()
self.log.warning("ende des while !!!!!!!!!!!!!!!!")

def stop(self):
self.log.warning("stop - start")
self.t.do_run = False
self.log.warning("1")
sys.exit()

def session_created(self, soecket, addr):
threadName = 'Client-Session '+str(addr[0])+':'+ str(addr[1])
Expand Down
22 changes: 19 additions & 3 deletions logon/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ def main():
# ======================================================
# start message

args = sys.argv[1:]
log = Logging()
console = Console()
console.clear()

if len(args) == 3 and args[0] == '-m':
serverModus = int(args[1])
serverTime = int(args[2])

def wel():
welmsg = [58*'─', '| 0.01 |' + 12*' ' +
'pyCestra - Logon Server'+ 12*' ' + '|', 58*"─"]
Expand Down Expand Up @@ -69,8 +74,12 @@ def wel():
ipbans = dataSource.IpBans().load()
log.info('IP Bans were loaded')

dataSource.DatabaseUpdateService().start(accountDataDic,
config.get_update_time())
if not serverModus == 1:
dataSource.DatabaseUpdateService().start(accountDataDic,
config.get_update_time())
else:
log.info('Database-Update-Service is not active')


# ======================================================
# socket tests
Expand All @@ -79,7 +88,7 @@ def wel():

game_client_dic = {}

LoginServer(config.get_login_ip(),
lo = LoginServer(config.get_login_ip(),
config.get_login_port(),
game_client_dic,
accountDataDic,
Expand All @@ -90,6 +99,13 @@ def wel():
config.get_exchange_port(),
hostList)

if serverModus == 1:
log.warning("This server will automatically shutdown in {} seconds".format(serverTime))
time.sleep(serverTime)
log.warning("SHUTDOWN!")
lo.stop()
sys.exit()

while True:
time.sleep(15)
if game_client_dic:
Expand Down
24 changes: 24 additions & 0 deletions logon/src/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import threading
import time


def doit(arg):
t = threading.currentThread()
x = 1
while getattr(t, "do_run", True):
print ("working on %s" % arg)
print('{}\r'.format(x), end="")
x = x + 1
time.sleep(1)
print("Stopping as you wish.")


def main():
t = threading.Thread(target=doit, args=("task",))
t.start()
time.sleep(5)
t.do_run = False


if __name__ == "__main__":
main()