Commit 04ca8553 by Solo Group

update forwarder

1 parent db249bb3
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (iso8583-web)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/iso8583-web.iml" filepath="$PROJECT_DIR$/.idea/iso8583-web.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -14,7 +14,7 @@ pyramid.default_locale_name = id
pyramid.includes =
pyramid_debugtoolbar
sqlalchemy.url = postgresql://user:pass@localhost/dbname
sqlalchemy.url = postgresql://aagusti:a@localhost/iso8583
timezone = Asia/Jakarta
localization = id_ID.UTF-8
......
......@@ -38,7 +38,7 @@ format = %(asctime)s %(levelname)s %(message)s
[host_bjb]
ip = 127.0.0.1
port = 10002
listen = false
listen = true
streamer = bjb_with_suffix
[host_mitracomm]
......
......@@ -60,6 +60,8 @@ def main(global_config, **settings):
config.include('pyramid_tm')
config.include('pyramid_beaker')
config.include('pyramid_chameleon')
# added by agus gustiana
config.include('pyramid_rpc.jsonrpc')
authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=group_finder, hashalg='sha512')
......
......@@ -50,6 +50,7 @@ def get_int(conf, section, option, default):
MSG_DUPLICATE = 'IP {ip} port {port} ganda. Perbaiki konfigurasi.'
def validate_ip_port(ip_port):
if ip_port in ip_conf:
cfg = ip_conf[ip_port]
......@@ -76,10 +77,23 @@ def get_streamer_class(name):
def read_conf(conf_file):
conf = ConfigParser()
conf.read(conf_file)
# Load Config Modules
modules = dict()
for section in conf.sections():
# if section.find('module_') < 0:
# continue
if section != "module":
continue
for key, value in conf.items(section):
modules[key] = value
# Load Config Host
for section in conf.sections():
if section == 'web':
web['port'] = conf.getint(section, 'port')
continue
if section.find('host_') < 0:
continue
try:
......@@ -88,11 +102,11 @@ def read_conf(conf_file):
active = True
if not active:
continue
cfg = dict()
ip = conf.get(section, 'ip')
port = conf.getint(section, 'port')
ip_port = join_ip_port(ip, port)
validate_ip_port(ip_port)
cfg = dict()
cfg['ip'] = ip
cfg['port'] = port
cfg['name'] = name = section.split('_')[1]
......@@ -100,6 +114,7 @@ def read_conf(conf_file):
cfg['streamer_cls'] = get_streamer_class(cfg['streamer'])
cfg['module'] = get_str(conf, section, 'module', 'opensipkd.iso8583.network')
cfg['module_obj'] = get_module_object(cfg['module'])
cfg['module_conf'] = modules
cfg['ip'] = conf.get(section, 'ip')
cfg['port'] = conf.getint(section, 'port')
cfg['listen'] = get_boolean(conf, section, 'listen', True)
......@@ -110,4 +125,5 @@ def read_conf(conf_file):
listen_ports.append(port)
if ip not in allowed_ips:
allowed_ips.append(ip)
# print(cfg)
ip_conf[ip_port] = name_conf[name] = dict(cfg)
......@@ -16,3 +16,4 @@ group-add,/group/add
group-edit,/group/{id}
group-delete,/group/{id}/delete
log
rpc
\ No newline at end of file
......@@ -298,8 +298,11 @@ class Parser(Log):
def run(self):
from_iso = self.connection.job.raw_to_iso(self.raw)
print("RUN from_iso", from_iso)
self.log_decode(from_iso)
iso = self.connection.job.process(from_iso)
print("RUN iso", iso)
if iso:
self.log_encode(iso)
raw = iso.getRawIso()
......@@ -348,10 +351,15 @@ def log_web_error(s):
def conn_by_name(name):
# Tambahan Exceptions
if name not in name_conf:
raise ValueError("host %s not found" %name)
conf = name_conf[name]
found_conn = None
for ip_port, conn in conn_mgr:
ip, port = ip_port.split(':')
print("DEBUG>>", ip, port, conf['ip'])
if conf['ip'] != ip:
continue
port = int(port)
......@@ -408,6 +416,7 @@ def web_job(conn, iso):
if ip_port not in web_response:
continue
result = web_response[ip_port]
print("Win Job", result)
if stan in result:
iso = result[stan]
del result[stan]
......@@ -442,9 +451,11 @@ def echo(request, p):
@jsonrpc_method(endpoint='rpc')
def inquiry(request, p):
log_web_receive(request, 'inquiry', p)
conn = validate_rpc(p)
iso = conn.job.inquiry(p)
return web_job(conn, iso)
result = web_job(conn, iso)
return result
@jsonrpc_method(endpoint='rpc')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!