2018-02-23 22:05:40 +00:00
|
|
|
from json import load, dump, loads
|
2019-01-26 18:58:21 +00:00
|
|
|
from redis import StrictRedis
|
2018-10-14 13:47:08 +00:00
|
|
|
from string import digits
|
2018-02-23 22:05:40 +00:00
|
|
|
from utils.logging.log import *
|
|
|
|
|
|
|
|
configPath = "conf/"
|
|
|
|
certPath = "cert/"
|
|
|
|
|
|
|
|
filemap = {
|
|
|
|
"config": ["config.json", "configuration"],
|
|
|
|
"keyconf": ["keyword.json", "keyword lists"],
|
2019-01-26 01:57:24 +00:00
|
|
|
"pool": ["pool.json", "network, alias and relay mappings"],
|
2018-02-23 22:05:40 +00:00
|
|
|
"help": ["help.json", "command help"],
|
2018-02-24 12:42:27 +00:00
|
|
|
"counters": ["counters.json", "counters file"],
|
2018-03-04 17:25:57 +00:00
|
|
|
"masterbuf": ["masterbuf.json", "master buffer"],
|
2018-07-27 21:58:37 +00:00
|
|
|
"monitor": ["monitor.json", "monitoring database"],
|
2019-01-20 19:56:54 +00:00
|
|
|
"alias": ["alias.json", "alias details"],
|
|
|
|
"relay": ["relay.json", "relay list"],
|
2019-01-26 01:57:24 +00:00
|
|
|
"network": ["network.json", "network list"],
|
2019-03-18 21:01:28 +00:00
|
|
|
"tokens": ["tokens.json", "authentication tokens"],
|
2018-07-27 21:58:37 +00:00
|
|
|
}
|
2018-02-23 22:05:40 +00:00
|
|
|
|
|
|
|
connections = {}
|
2019-03-18 21:01:28 +00:00
|
|
|
relayConnections = {}
|
2018-02-23 22:05:40 +00:00
|
|
|
IRCPool = {}
|
|
|
|
ReactorPool = {}
|
|
|
|
FactoryPool = {}
|
|
|
|
|
|
|
|
MonitorPool = []
|
|
|
|
|
|
|
|
CommandMap = {}
|
|
|
|
|
2019-07-28 14:07:46 +00:00
|
|
|
runningSample = 0
|
|
|
|
lastMinuteSample = 0
|
|
|
|
|
2018-10-14 13:47:08 +00:00
|
|
|
def nets():
|
|
|
|
if not "pool" in globals():
|
|
|
|
return
|
|
|
|
networks = set()
|
2018-10-21 16:14:50 +00:00
|
|
|
for i in pool.keys():
|
|
|
|
networks.add("".join([x for x in i if not x in digits]))
|
|
|
|
return networks
|
|
|
|
|
|
|
|
def liveNets():
|
|
|
|
networks = set()
|
|
|
|
for i in IRCPool.keys():
|
|
|
|
networks.add("".join([x for x in i if not x in digits]))
|
2018-10-14 13:47:08 +00:00
|
|
|
return networks
|
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def saveConf(var):
|
|
|
|
with open(configPath+filemap[var][0], "w") as f:
|
|
|
|
dump(globals()[var], f, indent=4)
|
|
|
|
return
|
|
|
|
|
|
|
|
def loadConf(var):
|
|
|
|
with open(configPath+filemap[var][0], "r") as f:
|
|
|
|
globals()[var] = load(f)
|
|
|
|
|
|
|
|
def initConf():
|
|
|
|
for i in filemap.keys():
|
|
|
|
loadConf(i)
|
|
|
|
|
|
|
|
def initMain():
|
2018-08-27 19:52:39 +00:00
|
|
|
global r
|
2018-02-23 22:05:40 +00:00
|
|
|
initConf()
|
2019-01-26 18:58:21 +00:00
|
|
|
r = StrictRedis(unix_socket_path=config["RedisSocket"], db=0)
|
2018-08-27 19:52:39 +00:00
|
|
|
|
|
|
|
|