-
Notifications
You must be signed in to change notification settings - Fork 7
/
Init.py
71 lines (52 loc) · 1.69 KB
/
Init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! python2.7
import sys
sys.dont_write_bytecode = True
import BlazeMain_Client
import BlazeMain_Server
import GosRedirector
import Https
import MySQLdb
import sys
from Utils import garbage
import Utils.Globals as Globals
from twisted.internet import ssl, reactor
from twisted.internet.protocol import Factory, Protocol
from twisted.web import server, resource
def Start():
Globals.serverIP = "192.168.1.40"
#MySQL Data
Globals.dbHost = "127.0.0.1"
Globals.dbUser = "user"
Globals.dbPass = "pass"
Globals.dbDatabase = "db"
CheckMySqlConn()
SSLInfo = ssl.DefaultOpenSSLContextFactory('crt/privkey.pem', 'crt/cacert.pem')
factory = Factory()
factory.protocol = GosRedirector.GOSRedirector
reactor.listenSSL(42127, factory, SSLInfo)
print("[SSL REACTOR] GOSREDIRECTOR STARTED [42127]")
factory = Factory()
factory.protocol = BlazeMain_Client.BLAZEHUB
reactor.listenTCP(10041, factory)
print("[TCP REACTOR] BLAZE CLIENT [10041]")
factory = Factory()
factory.protocol = BlazeMain_Server.BLAZEHUB
reactor.listenTCP(10071, factory)
print("[TCP REACTOR] BLAZE SERVER [10071]")
sites = server.Site(Https.Simple())
reactor.listenSSL(443, sites, SSLInfo)
print("[WEB REACTOR] Https [443]")
reactor.run()
def CheckMySqlConn():
print("[MySQL] Checking server connection...")
try:
db = MySQLdb.connect(Globals.dbHost, Globals.dbUser, Globals.dbPass, Globals.dbDatabase)
cursor = db.cursor()
cursor.execute("SELECT VERSION()")
results = cursor.fetchone()
print("[MySQL] Server connection ok!")
except MySQLdb.Error, e:
print "[MySQL] Server connection failed! Error: %d in connection: %s" % (e.args[0], e.args[1])
sys.exit()
if __name__ == '__main__':
Start()