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 \ 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 \ 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 \ 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 \ No newline at end of file
...@@ -14,7 +14,7 @@ pyramid.default_locale_name = id ...@@ -14,7 +14,7 @@ pyramid.default_locale_name = id
pyramid.includes = pyramid.includes =
pyramid_debugtoolbar pyramid_debugtoolbar
sqlalchemy.url = postgresql://user:pass@localhost/dbname sqlalchemy.url = postgresql://aagusti:a@localhost/iso8583
timezone = Asia/Jakarta timezone = Asia/Jakarta
localization = id_ID.UTF-8 localization = id_ID.UTF-8
......
...@@ -38,7 +38,7 @@ format = %(asctime)s %(levelname)s %(message)s ...@@ -38,7 +38,7 @@ format = %(asctime)s %(levelname)s %(message)s
[host_bjb] [host_bjb]
ip = 127.0.0.1 ip = 127.0.0.1
port = 10002 port = 10002
listen = false listen = true
streamer = bjb_with_suffix streamer = bjb_with_suffix
[host_mitracomm] [host_mitracomm]
......
...@@ -60,6 +60,8 @@ def main(global_config, **settings): ...@@ -60,6 +60,8 @@ def main(global_config, **settings):
config.include('pyramid_tm') config.include('pyramid_tm')
config.include('pyramid_beaker') config.include('pyramid_beaker')
config.include('pyramid_chameleon') config.include('pyramid_chameleon')
# added by agus gustiana
config.include('pyramid_rpc.jsonrpc')
authn_policy = AuthTktAuthenticationPolicy( authn_policy = AuthTktAuthenticationPolicy(
'sosecret', callback=group_finder, hashalg='sha512') 'sosecret', callback=group_finder, hashalg='sha512')
......
...@@ -50,6 +50,7 @@ def get_int(conf, section, option, default): ...@@ -50,6 +50,7 @@ def get_int(conf, section, option, default):
MSG_DUPLICATE = 'IP {ip} port {port} ganda. Perbaiki konfigurasi.' MSG_DUPLICATE = 'IP {ip} port {port} ganda. Perbaiki konfigurasi.'
def validate_ip_port(ip_port): def validate_ip_port(ip_port):
if ip_port in ip_conf: if ip_port in ip_conf:
cfg = ip_conf[ip_port] cfg = ip_conf[ip_port]
...@@ -76,10 +77,23 @@ def get_streamer_class(name): ...@@ -76,10 +77,23 @@ def get_streamer_class(name):
def read_conf(conf_file): def read_conf(conf_file):
conf = ConfigParser() conf = ConfigParser()
conf.read(conf_file) 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(): for section in conf.sections():
if section == 'web': if section == 'web':
web['port'] = conf.getint(section, 'port') web['port'] = conf.getint(section, 'port')
continue continue
if section.find('host_') < 0: if section.find('host_') < 0:
continue continue
try: try:
...@@ -88,11 +102,11 @@ def read_conf(conf_file): ...@@ -88,11 +102,11 @@ def read_conf(conf_file):
active = True active = True
if not active: if not active:
continue continue
cfg = dict()
ip = conf.get(section, 'ip') ip = conf.get(section, 'ip')
port = conf.getint(section, 'port') port = conf.getint(section, 'port')
ip_port = join_ip_port(ip, port) ip_port = join_ip_port(ip, port)
validate_ip_port(ip_port) validate_ip_port(ip_port)
cfg = dict()
cfg['ip'] = ip cfg['ip'] = ip
cfg['port'] = port cfg['port'] = port
cfg['name'] = name = section.split('_')[1] cfg['name'] = name = section.split('_')[1]
...@@ -100,6 +114,7 @@ def read_conf(conf_file): ...@@ -100,6 +114,7 @@ def read_conf(conf_file):
cfg['streamer_cls'] = get_streamer_class(cfg['streamer']) cfg['streamer_cls'] = get_streamer_class(cfg['streamer'])
cfg['module'] = get_str(conf, section, 'module', 'opensipkd.iso8583.network') cfg['module'] = get_str(conf, section, 'module', 'opensipkd.iso8583.network')
cfg['module_obj'] = get_module_object(cfg['module']) cfg['module_obj'] = get_module_object(cfg['module'])
cfg['module_conf'] = modules
cfg['ip'] = conf.get(section, 'ip') cfg['ip'] = conf.get(section, 'ip')
cfg['port'] = conf.getint(section, 'port') cfg['port'] = conf.getint(section, 'port')
cfg['listen'] = get_boolean(conf, section, 'listen', True) cfg['listen'] = get_boolean(conf, section, 'listen', True)
...@@ -110,4 +125,5 @@ def read_conf(conf_file): ...@@ -110,4 +125,5 @@ def read_conf(conf_file):
listen_ports.append(port) listen_ports.append(port)
if ip not in allowed_ips: if ip not in allowed_ips:
allowed_ips.append(ip) allowed_ips.append(ip)
# print(cfg)
ip_conf[ip_port] = name_conf[name] = dict(cfg) ip_conf[ip_port] = name_conf[name] = dict(cfg)
...@@ -16,3 +16,4 @@ group-add,/group/add ...@@ -16,3 +16,4 @@ group-add,/group/add
group-edit,/group/{id} group-edit,/group/{id}
group-delete,/group/{id}/delete group-delete,/group/{id}/delete
log log
rpc
\ No newline at end of file \ No newline at end of file
...@@ -298,8 +298,11 @@ class Parser(Log): ...@@ -298,8 +298,11 @@ class Parser(Log):
def run(self): def run(self):
from_iso = self.connection.job.raw_to_iso(self.raw) from_iso = self.connection.job.raw_to_iso(self.raw)
print("RUN from_iso", from_iso)
self.log_decode(from_iso) self.log_decode(from_iso)
iso = self.connection.job.process(from_iso) iso = self.connection.job.process(from_iso)
print("RUN iso", iso)
if iso: if iso:
self.log_encode(iso) self.log_encode(iso)
raw = iso.getRawIso() raw = iso.getRawIso()
...@@ -348,10 +351,15 @@ def log_web_error(s): ...@@ -348,10 +351,15 @@ def log_web_error(s):
def conn_by_name(name): def conn_by_name(name):
# Tambahan Exceptions
if name not in name_conf:
raise ValueError("host %s not found" %name)
conf = name_conf[name] conf = name_conf[name]
found_conn = None found_conn = None
for ip_port, conn in conn_mgr: for ip_port, conn in conn_mgr:
ip, port = ip_port.split(':') ip, port = ip_port.split(':')
print("DEBUG>>", ip, port, conf['ip'])
if conf['ip'] != ip: if conf['ip'] != ip:
continue continue
port = int(port) port = int(port)
...@@ -408,6 +416,7 @@ def web_job(conn, iso): ...@@ -408,6 +416,7 @@ def web_job(conn, iso):
if ip_port not in web_response: if ip_port not in web_response:
continue continue
result = web_response[ip_port] result = web_response[ip_port]
print("Win Job", result)
if stan in result: if stan in result:
iso = result[stan] iso = result[stan]
del result[stan] del result[stan]
...@@ -442,9 +451,11 @@ def echo(request, p): ...@@ -442,9 +451,11 @@ def echo(request, p):
@jsonrpc_method(endpoint='rpc') @jsonrpc_method(endpoint='rpc')
def inquiry(request, p): def inquiry(request, p):
log_web_receive(request, 'inquiry', p)
conn = validate_rpc(p) conn = validate_rpc(p)
iso = conn.job.inquiry(p) iso = conn.job.inquiry(p)
return web_job(conn, iso) result = web_job(conn, iso)
return result
@jsonrpc_method(endpoint='rpc') @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!