mirror of https://github.com/tp4a/teleport
temp.
parent
bc4a8f730b
commit
36efcb1989
|
@ -17,12 +17,13 @@ log-level=0
|
||||||
; to $INSTDIR%/data/replay/
|
; to $INSTDIR%/data/replay/
|
||||||
;replay-path=/usr/local/eom/teleport/data/replay
|
;replay-path=/usr/local/eom/teleport/data/replay
|
||||||
|
|
||||||
|
web-server-rpc=http://127.0.0.1:7190/rpc
|
||||||
|
|
||||||
[rpc]
|
[rpc]
|
||||||
; Request by web server. `bind-ip` should be the ip of core server. If
|
; Request by web server. `ip` should be the ip of core server, default to
|
||||||
; web server and core server running at the same machine, it should be
|
; 127.0.0.1 because web server and core server running at the same machine.
|
||||||
; 127.0.0.1
|
;ip=127.0.0.1
|
||||||
bind-ip=127.0.0.1
|
port=52080
|
||||||
bind-port=52080
|
|
||||||
|
|
||||||
[protocol-ssh]
|
[protocol-ssh]
|
||||||
enabled=true
|
enabled=true
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
; codec: utf-8
|
; codec: utf-8
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
|
;ip=0.0.0.0
|
||||||
port=7190
|
port=7190
|
||||||
|
|
||||||
; 'log-file' define the log file location. if not set, default location
|
; 'log-file' define the log file location. if not set, default location
|
||||||
|
@ -14,3 +15,6 @@ port=7190
|
||||||
# LOG_LEVEL_WARN 3 log warning and error message.
|
# LOG_LEVEL_WARN 3 log warning and error message.
|
||||||
# LOG_LEVEL_ERROR 4 log error message only.
|
# LOG_LEVEL_ERROR 4 log error message only.
|
||||||
log-level=0
|
log-level=0
|
||||||
|
|
||||||
|
|
||||||
|
core-server-rpc=http://127.0.0.1:52080/rpc
|
||||||
|
|
|
@ -10,9 +10,22 @@ bool ts_web_rpc_register_core()
|
||||||
{
|
{
|
||||||
Json::FastWriter json_writer;
|
Json::FastWriter json_writer;
|
||||||
Json::Value jreq;
|
Json::Value jreq;
|
||||||
jreq["method"] = "register";
|
jreq["method"] = "register_core";
|
||||||
jreq["param"]["ip"] = g_env.rpc_bind_ip.c_str();
|
//jreq["param"]["ip"] = g_env.rpc_bind_ip.c_str();
|
||||||
jreq["param"]["port"] = g_env.rpc_bind_port;
|
//jreq["param"]["port"] = g_env.rpc_bind_port;
|
||||||
|
jreq["param"]["rpc"] = "http://127.0.0.1:52080/rpc";
|
||||||
|
|
||||||
|
// ExIniFile& ini = g_env.get_ini();
|
||||||
|
// ExIniSection* sec = ini.GetSection(L"common");
|
||||||
|
// if (NULL == sec)
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ex_wstr rpc;
|
||||||
|
// if (!sec->GetStr(L"", L""))
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
|
||||||
ex_astr json_param;
|
ex_astr json_param;
|
||||||
json_param = json_writer.write(jreq);
|
json_param = json_writer.write(jreq);
|
||||||
|
|
|
@ -69,48 +69,34 @@ class ConfigFile(AttrDict):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# def load_core(self, cfg_file):
|
def update_core(self, conf_data):
|
||||||
# if not os.path.exists(cfg_file):
|
try:
|
||||||
# log.e('configuration file does not exists: [{}]\n'.format(cfg_file))
|
self['core'] = AttrDict()
|
||||||
# return False
|
self['core']['ssh'] = AttrDict()
|
||||||
# try:
|
self['core']['ssh']['enable'] = False
|
||||||
# _cfg = configparser.ConfigParser()
|
self['core']['ssh']['port'] = 52189
|
||||||
# _cfg.read(cfg_file)
|
if 'ssh' in conf_data:
|
||||||
# except:
|
self['core']['ssh']['enable'] = conf_data['ssh']['enable']
|
||||||
# log.e('can not load configuration file: [{}]\n'.format(cfg_file))
|
self['core']['ssh']['port'] = conf_data['ssh']['port']
|
||||||
# return False
|
|
||||||
#
|
self['core']['rdp'] = AttrDict()
|
||||||
# self['core'] = AttrDict()
|
self['core']['rdp']['enable'] = False
|
||||||
#
|
self['core']['rdp']['port'] = 52089
|
||||||
# self['core']['rpc'] = AttrDict()
|
if 'rdp' in conf_data:
|
||||||
# self['core']['rpc']['ip'] = '127.0.0.1'
|
self['core']['rdp']['enable'] = conf_data['rdp']['enable']
|
||||||
# self['core']['rpc']['port'] = 52080
|
self['core']['rdp']['port'] = conf_data['rdp']['port']
|
||||||
# if 'rpc' in _cfg:
|
|
||||||
# self['core']['rpc']['ip'] = _cfg['rpc'].get('bind-ip', '127.0.0.1')
|
self['core']['telnet'] = AttrDict()
|
||||||
# self['core']['rpc']['port'] = _cfg['rpc'].getint('bind-port', 52080)
|
self['core']['telnet']['enable'] = False
|
||||||
#
|
self['core']['telnet']['port'] = 52389
|
||||||
# self['core']['ssh'] = AttrDict()
|
if 'telnet' in conf_data:
|
||||||
# self['core']['ssh']['enabled'] = False
|
self['core']['telnet']['enable'] = conf_data['telnet']['enable']
|
||||||
# self['core']['ssh']['port'] = 52189
|
self['core']['telnet']['port'] = conf_data['telnet']['port']
|
||||||
# if 'protocol-ssh' in _cfg:
|
except IndexError:
|
||||||
# self['core']['ssh']['enabled'] = _cfg['protocol-ssh'].getboolean('enabled', False)
|
log.e('invalid core config.\n')
|
||||||
# self['core']['ssh']['port'] = _cfg['protocol-ssh'].getint('bind-port', 52189)
|
return False
|
||||||
#
|
|
||||||
# self['core']['rdp'] = AttrDict()
|
return True
|
||||||
# self['core']['rdp']['enabled'] = False
|
|
||||||
# self['core']['rdp']['port'] = 52089
|
|
||||||
# if 'protocol-rdp' in _cfg:
|
|
||||||
# self['core']['rdp']['enabled'] = _cfg['protocol-rdp'].getboolean('enabled', False)
|
|
||||||
# self['core']['rdp']['port'] = _cfg['protocol-rdp'].getint('bind-port', 52089)
|
|
||||||
#
|
|
||||||
# self['core']['telnet'] = AttrDict()
|
|
||||||
# self['core']['telnet']['enabled'] = False
|
|
||||||
# self['core']['telnet']['port'] = 52389
|
|
||||||
# if 'protocol-telnet' in _cfg:
|
|
||||||
# self['core']['telnet']['enabled'] = _cfg['protocol-telnet'].getboolean('enabled', False)
|
|
||||||
# self['core']['telnet']['port'] = _cfg['protocol-telnet'].getint('bind-port', 52389)
|
|
||||||
#
|
|
||||||
# return True
|
|
||||||
|
|
||||||
|
|
||||||
_g_cfg = ConfigFile()
|
_g_cfg = ConfigFile()
|
||||||
|
|
|
@ -85,18 +85,8 @@ class WebServerCore:
|
||||||
req = urllib.request.Request(url=cfg.core_server_rpc, data=data)
|
req = urllib.request.Request(url=cfg.core_server_rpc, data=data)
|
||||||
rep = urllib.request.urlopen(req, timeout=3)
|
rep = urllib.request.urlopen(req, timeout=3)
|
||||||
body = rep.read().decode()
|
body = rep.read().decode()
|
||||||
print('core-config:', body)
|
|
||||||
# info = response.info()
|
|
||||||
# _zip = info.get('Content-Encoding')
|
|
||||||
# if _zip == 'gzip':
|
|
||||||
# the_page = gzip.decompress(the_page)
|
|
||||||
# else:
|
|
||||||
# pass
|
|
||||||
# the_page = the_page.decode()
|
|
||||||
# print(the_page)
|
|
||||||
# return the_page
|
|
||||||
x = json.loads(body)
|
x = json.loads(body)
|
||||||
cfg.core = x['data']
|
cfg.update_core(x['data'])
|
||||||
except:
|
except:
|
||||||
log.w('can not connect to core server for get config, maybe it not start yet.\n')
|
log.w('can not connect to core server for get config, maybe it not start yet.\n')
|
||||||
|
|
||||||
|
|
|
@ -27,55 +27,30 @@ __all__ = ['async_post_http', 'async_enc']
|
||||||
|
|
||||||
|
|
||||||
@tornado.gen.coroutine
|
@tornado.gen.coroutine
|
||||||
def async_post_http(url, values):
|
def async_post_http(post_data):
|
||||||
|
print('async_post_http:', post_data)
|
||||||
try:
|
try:
|
||||||
v = json.dumps(values)
|
v = json.dumps(post_data)
|
||||||
data = urllib.parse.quote(v).encode('utf-8')
|
data = urllib.parse.quote(v).encode('utf-8')
|
||||||
|
|
||||||
c = tornado.httpclient.AsyncHTTPClient()
|
c = tornado.httpclient.AsyncHTTPClient()
|
||||||
r = yield c.fetch(url, body=data, method='POST')
|
r = yield c.fetch(cfg.core_server_rpc, body=data, method='POST')
|
||||||
|
|
||||||
|
print('async_post_http return:', r.body.decode())
|
||||||
return json.loads(r.body.decode())
|
return json.loads(r.body.decode())
|
||||||
|
|
||||||
# return r.body
|
|
||||||
except:
|
except:
|
||||||
# return {'code': -2, 'message': 'can not fetch {}'.format(url)}
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@tornado.gen.coroutine
|
@tornado.gen.coroutine
|
||||||
def async_enc(data):
|
def async_enc(data):
|
||||||
# # url = cfg.ts_enc_url
|
# ts_server_rpc_ip = cfg.core.rpc.ip
|
||||||
# config_list = set.get_config_list()
|
# ts_server_rpc_port = cfg.core.rpc.port
|
||||||
# rpc_port = 52080
|
|
||||||
# if 'ts_server_rpc_port' in config_list:
|
|
||||||
# rpc_port = int(config_list['ts_server_rpc_port'])
|
|
||||||
# ts_server_rpc_ip = '127.0.0.1'
|
|
||||||
# if 'ts_server_rpc_ip' in config_list:
|
|
||||||
# ts_server_rpc_ip = config_list['ts_server_rpc_ip']
|
|
||||||
#
|
|
||||||
ts_server_rpc_ip = cfg.core.rpc.ip
|
|
||||||
ts_server_rpc_port = cfg.core.rpc.port
|
|
||||||
|
|
||||||
# url = 'http://{}:{}/enc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
# url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
||||||
#
|
|
||||||
# values = dict()
|
|
||||||
# if not isinstance(data, str):
|
|
||||||
# data = "{}".format(data)
|
|
||||||
#
|
|
||||||
# values['p'] = data
|
|
||||||
# return_data = post_http(url, values)
|
|
||||||
# if return_data is None:
|
|
||||||
# return -2, ''
|
|
||||||
#
|
|
||||||
# if return_data is not None:
|
|
||||||
# return_data = json.loads(return_data)
|
|
||||||
# else:
|
|
||||||
# return -3, ''
|
|
||||||
|
|
||||||
url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
|
||||||
req = {'method': 'enc', 'param': {'p': data}}
|
req = {'method': 'enc', 'param': {'p': data}}
|
||||||
_yr = async_post_http(url, req)
|
|
||||||
|
_yr = async_post_http(req)
|
||||||
return_data = yield _yr
|
return_data = yield _yr
|
||||||
if return_data is None:
|
if return_data is None:
|
||||||
return {'code': -2}
|
return {'code': -2}
|
||||||
|
@ -84,20 +59,14 @@ def async_enc(data):
|
||||||
if return_data['code'] != 0:
|
if return_data['code'] != 0:
|
||||||
return {'code': return_data['code']}
|
return {'code': return_data['code']}
|
||||||
|
|
||||||
# ret_code = return_data['code']
|
|
||||||
# if ret_code != 0:
|
|
||||||
# return ret_code, ''
|
|
||||||
if 'data' not in return_data:
|
if 'data' not in return_data:
|
||||||
return {'code': -5}
|
return {'code': -5}
|
||||||
|
|
||||||
# data = return_data['data']
|
|
||||||
if 'c' not in return_data['data']:
|
if 'c' not in return_data['data']:
|
||||||
return {'code': -6}
|
return {'code': -6}
|
||||||
|
|
||||||
return {'code': 0, 'data': return_data['data']['c']}
|
return {'code': 0, 'data': return_data['data']['c']}
|
||||||
|
|
||||||
# return 0, decry_data
|
|
||||||
|
|
||||||
|
|
||||||
_chars = 'ACDEFHJKLMNPQRTVWXY34679'
|
_chars = 'ACDEFHJKLMNPQRTVWXY34679'
|
||||||
|
|
||||||
|
|
|
@ -12,15 +12,23 @@ from eom_app.app.util import gen_captcha
|
||||||
|
|
||||||
class LoginHandler(SwxAppHandler):
|
class LoginHandler(SwxAppHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
ref = self.get_argument('ref', '/')
|
# _ref = self.get_argument('ref', '/')
|
||||||
|
|
||||||
user = self.get_current_user()
|
_user = self.get_current_user()
|
||||||
if user['id'] == 0:
|
if _user['id'] == 0:
|
||||||
user_name = ''
|
user_name = ''
|
||||||
else:
|
else:
|
||||||
user_name = user['name']
|
user_name = _user['name']
|
||||||
|
|
||||||
self.render('auth/login.mako', user_name=user_name, reference=ref, captcha_random=random.random())
|
#self.render('auth/login.mako', user_name=user_name, reference=ref, captcha_random=random.random())
|
||||||
|
|
||||||
|
page_param = {
|
||||||
|
'ref': self.get_argument('ref', '/'),
|
||||||
|
'login_type': 'account',
|
||||||
|
'user_name': user_name
|
||||||
|
}
|
||||||
|
page_param = json.dumps(page_param)
|
||||||
|
self.render('auth/login.mako', page_param=page_param)
|
||||||
|
|
||||||
|
|
||||||
class VerifyUser(SwxJsonpHandler):
|
class VerifyUser(SwxJsonpHandler):
|
||||||
|
|
|
@ -837,12 +837,12 @@ class GetSessionId(SwxAuthJsonHandler):
|
||||||
# ts_server_rpc_port = 52080
|
# ts_server_rpc_port = 52080
|
||||||
# if 'ts_server_rpc_port' in config_list:
|
# if 'ts_server_rpc_port' in config_list:
|
||||||
# ts_server_rpc_port = config_list['ts_server_rpc_port']
|
# ts_server_rpc_port = config_list['ts_server_rpc_port']
|
||||||
ts_server_rpc_ip = cfg.core.rpc.ip
|
# ts_server_rpc_ip = cfg.core.rpc.ip
|
||||||
ts_server_rpc_port = cfg.core.rpc.port
|
# ts_server_rpc_port = cfg.core.rpc.port
|
||||||
|
|
||||||
url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
# url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
||||||
req = {'method': 'request_session', 'param': {'authid': auth_id}}
|
req = {'method': 'request_session', 'param': {'authid': auth_id}}
|
||||||
_yr = async_post_http(url, req)
|
_yr = async_post_http(req)
|
||||||
return_data = yield _yr
|
return_data = yield _yr
|
||||||
if return_data is None:
|
if return_data is None:
|
||||||
return self.write_json(-1)
|
return self.write_json(-1)
|
||||||
|
@ -894,8 +894,8 @@ class AdminGetSessionId(SwxAuthJsonHandler):
|
||||||
tmp_auth_info['account_lock'] = 0
|
tmp_auth_info['account_lock'] = 0
|
||||||
tmp_auth_info['account_name'] = user['name']
|
tmp_auth_info['account_name'] = user['name']
|
||||||
|
|
||||||
ts_server_rpc_ip = cfg.core.rpc.ip
|
# ts_server_rpc_ip = cfg.core.rpc.ip
|
||||||
ts_server_rpc_port = cfg.core.rpc.port
|
# ts_server_rpc_port = cfg.core.rpc.port
|
||||||
|
|
||||||
with tmp_auth_id_lock:
|
with tmp_auth_id_lock:
|
||||||
global tmp_auth_id_base
|
global tmp_auth_id_base
|
||||||
|
@ -904,9 +904,9 @@ class AdminGetSessionId(SwxAuthJsonHandler):
|
||||||
|
|
||||||
web_session().set('tmp-auth-info-{}'.format(auth_id), tmp_auth_info, 10)
|
web_session().set('tmp-auth-info-{}'.format(auth_id), tmp_auth_info, 10)
|
||||||
|
|
||||||
url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
# url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
||||||
req = {'method': 'request_session', 'param': {'authid': auth_id}}
|
req = {'method': 'request_session', 'param': {'authid': auth_id}}
|
||||||
_yr = async_post_http(url, req)
|
_yr = async_post_http(req)
|
||||||
return_data = yield _yr
|
return_data = yield _yr
|
||||||
if return_data is None:
|
if return_data is None:
|
||||||
return self.write_json(-1)
|
return self.write_json(-1)
|
||||||
|
@ -962,17 +962,17 @@ class AdminFastGetSessionId(SwxAdminJsonHandler):
|
||||||
self.write_json(-2)
|
self.write_json(-2)
|
||||||
return
|
return
|
||||||
|
|
||||||
ts_server_rpc_ip = cfg.core.rpc.ip
|
# ts_server_rpc_ip = cfg.core.rpc.ip
|
||||||
ts_server_rpc_port = cfg.core.rpc.port
|
# ts_server_rpc_port = cfg.core.rpc.port
|
||||||
|
|
||||||
if tmp_auth_info['auth_mode'] == 1:
|
if tmp_auth_info['auth_mode'] == 1:
|
||||||
if len(_user_pswd) == 0: # 修改登录用户信息时可能不会修改密码,因此页面上可能不会传来密码,需要从数据库中直接读取
|
if len(_user_pswd) == 0: # 修改登录用户信息时可能不会修改密码,因此页面上可能不会传来密码,需要从数据库中直接读取
|
||||||
h = host.get_host_auth_info(_host_auth_id)
|
h = host.get_host_auth_info(_host_auth_id)
|
||||||
tmp_auth_info['user_auth'] = h['user_auth']
|
tmp_auth_info['user_auth'] = h['user_auth']
|
||||||
else: # 如果页面上修改了密码或者新建账号时设定了密码,那么需要先交给core服务进行加密
|
else: # 如果页面上修改了密码或者新建账号时设定了密码,那么需要先交给core服务进行加密
|
||||||
url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
# url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
||||||
req = {'method': 'enc', 'param': {'p': _user_pswd}}
|
req = {'method': 'enc', 'param': {'p': _user_pswd}}
|
||||||
_yr = async_post_http(url, req)
|
_yr = async_post_http(req)
|
||||||
return_data = yield _yr
|
return_data = yield _yr
|
||||||
if return_data is None:
|
if return_data is None:
|
||||||
return self.write_json(-1)
|
return self.write_json(-1)
|
||||||
|
@ -999,9 +999,9 @@ class AdminFastGetSessionId(SwxAdminJsonHandler):
|
||||||
|
|
||||||
web_session().set('tmp-auth-info-{}'.format(auth_id), tmp_auth_info, 10)
|
web_session().set('tmp-auth-info-{}'.format(auth_id), tmp_auth_info, 10)
|
||||||
|
|
||||||
url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
# url = 'http://{}:{}/rpc'.format(ts_server_rpc_ip, ts_server_rpc_port)
|
||||||
req = {'method': 'request_session', 'param': {'authid': auth_id}}
|
req = {'method': 'request_session', 'param': {'authid': auth_id}}
|
||||||
_yr = async_post_http(url, req)
|
_yr = async_post_http(req)
|
||||||
return_data = yield _yr
|
return_data = yield _yr
|
||||||
if return_data is None:
|
if return_data is None:
|
||||||
return self.write_json(-1)
|
return self.write_json(-1)
|
||||||
|
|
|
@ -35,9 +35,10 @@ class LogHandler(SwxAdminHandler):
|
||||||
user_list = user.get_user_list()
|
user_list = user.get_user_list()
|
||||||
total_size, free_size = get_free_space_bytes(cfg.data_path)
|
total_size, free_size = get_free_space_bytes(cfg.data_path)
|
||||||
|
|
||||||
ts_server = dict()
|
# ts_server = dict()
|
||||||
ts_server['ip'] = cfg.core.rpc.ip
|
# ts_server['ip'] = cfg.core.rpc.ip
|
||||||
ts_server['port'] = cfg.core.rpc.port
|
# ts_server['port'] = cfg.core.rpc.port
|
||||||
|
ts_server = '""'
|
||||||
|
|
||||||
self.render('log/index.mako', user_list=user_list, total_size=total_size, free_size=free_size, ts_server=ts_server)
|
self.render('log/index.mako', user_list=user_list, total_size=total_size, free_size=free_size, ts_server=ts_server)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ import json
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from eom_app.app.session import web_session
|
from eom_app.app.session import web_session
|
||||||
from eom_app.app.configs import app_cfg
|
from eom_app.app.configs import app_cfg
|
||||||
|
from eom_app.app.util import async_post_http
|
||||||
from eom_app.module import host, record
|
from eom_app.module import host, record
|
||||||
|
from eom_common.eomcore.logger import *
|
||||||
|
|
||||||
from .base import SwxJsonHandler
|
from .base import SwxJsonHandler
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ class RpcHandler(SwxJsonHandler):
|
||||||
return self._register_core(_req['param'])
|
return self._register_core(_req['param'])
|
||||||
elif 'exit' == _req['method']:
|
elif 'exit' == _req['method']:
|
||||||
return self._exit()
|
return self._exit()
|
||||||
|
else:
|
||||||
|
log.e('WEB-JSON-RPC got unknown method: `{}`.\n'.format(_req['method']))
|
||||||
|
|
||||||
self.write_json(-1, message='invalid method.')
|
self.write_json(-1, message='invalid method.')
|
||||||
|
|
||||||
|
@ -128,6 +132,23 @@ class RpcHandler(SwxJsonHandler):
|
||||||
# 因为core服务启动了(之前可能非正常终止了),做一下数据库中会话状态的修复操作
|
# 因为core服务启动了(之前可能非正常终止了),做一下数据库中会话状态的修复操作
|
||||||
record.session_fix()
|
record.session_fix()
|
||||||
|
|
||||||
|
if 'rpc' not in param:
|
||||||
|
return self.write_json(-1)
|
||||||
|
cfg.core_server_rpc = param['rpc']
|
||||||
|
|
||||||
|
req = {'method': 'get_config', 'param': []}
|
||||||
|
_yr = async_post_http(req)
|
||||||
|
return_data = yield _yr
|
||||||
|
if return_data is None:
|
||||||
|
return self.write_json(-1)
|
||||||
|
if 'code' not in return_data:
|
||||||
|
return self.write_json(-2)
|
||||||
|
if return_data['code'] != 0:
|
||||||
|
return self.write_json(return_data['code'])
|
||||||
|
|
||||||
|
cfg.update_core(return_data['data'])
|
||||||
|
print(cfg.core)
|
||||||
|
|
||||||
self.write_json(0)
|
self.write_json(0)
|
||||||
|
|
||||||
def _exit(self):
|
def _exit(self):
|
||||||
|
|
|
@ -78,15 +78,17 @@ class IndexHandler(SwxAdminHandler):
|
||||||
#
|
#
|
||||||
# config_list['_ip_list'] = ip_list
|
# config_list['_ip_list'] = ip_list
|
||||||
|
|
||||||
cfg_list = dict()
|
# cfg_list = dict()
|
||||||
cfg_list['ts_server_ssh_port'] = cfg.core.ssh.port
|
# cfg_list['ts_server_ssh_port'] = cfg.core.ssh.port
|
||||||
cfg_list['ts_server_ssh_enabled'] = 1 if cfg.core.ssh.enabled else 0
|
# cfg_list['ts_server_ssh_enabled'] = 1 if cfg.core.ssh.enabled else 0
|
||||||
cfg_list['ts_server_rdp_port'] = cfg.core.rdp.port
|
# cfg_list['ts_server_rdp_port'] = cfg.core.rdp.port
|
||||||
cfg_list['ts_server_rdp_enabled'] = 1 if cfg.core.rdp.enabled else 0
|
# cfg_list['ts_server_rdp_enabled'] = 1 if cfg.core.rdp.enabled else 0
|
||||||
cfg_list['ts_server_telnet_port'] = cfg.core.telnet.port
|
# cfg_list['ts_server_telnet_port'] = cfg.core.telnet.port
|
||||||
cfg_list['ts_server_telnet_enabled'] = 1 if cfg.core.telnet.enabled else 0
|
# cfg_list['ts_server_telnet_enabled'] = 1 if cfg.core.telnet.enabled else 0
|
||||||
|
# self.render('set/index.mako', config_list=cfg_list)
|
||||||
|
|
||||||
self.render('set/index.mako', config_list=cfg_list)
|
page_param = json.dumps({'core_server': cfg.core})
|
||||||
|
self.render('set/index.mako', page_param=page_param)
|
||||||
|
|
||||||
|
|
||||||
def _restart_func():
|
def _restart_func():
|
||||||
|
|
|
@ -37,7 +37,8 @@ def modify_pwd(old_pwd, new_pwd, user_id):
|
||||||
def get_user_list():
|
def get_user_list():
|
||||||
sql_exec = get_db_con()
|
sql_exec = get_db_con()
|
||||||
field_a = ['account_id', 'account_type', 'account_name', 'account_status', 'account_lock', 'account_desc']
|
field_a = ['account_id', 'account_type', 'account_name', 'account_status', 'account_lock', 'account_desc']
|
||||||
string_sql = 'SELECT {} FROM ts_account as a WHERE account_type<100;'.format(','.join(['a.{}'.format(i) for i in field_a]))
|
# string_sql = 'SELECT {} FROM ts_account as a WHERE account_type<100;'.format(','.join(['a.{}'.format(i) for i in field_a]))
|
||||||
|
string_sql = 'SELECT {} FROM ts_account as a;'.format(','.join(['a.{}'.format(i) for i in field_a]))
|
||||||
db_ret = sql_exec.ExecProcQuery(string_sql)
|
db_ret = sql_exec.ExecProcQuery(string_sql)
|
||||||
ret = list()
|
ret = list()
|
||||||
for item in db_ret:
|
for item in db_ret:
|
||||||
|
|
|
@ -9,6 +9,14 @@ var g_login_type = 'account';
|
||||||
|
|
||||||
ywl.on_init = function (cb_stack, cb_args) {
|
ywl.on_init = function (cb_stack, cb_args) {
|
||||||
ywl.login_type = ywl.page_options.login_type;
|
ywl.login_type = ywl.page_options.login_type;
|
||||||
|
g_login_type = ywl.page_options.login_type;
|
||||||
|
|
||||||
|
if(ywl.page_options.user_name.length > 0) {
|
||||||
|
$('#username_account').val(ywl.page_options.user_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#captcha_image').attr('src', '/auth/get-captcha?' + Math.random());
|
||||||
|
|
||||||
ywl.app = ywl.create_app();
|
ywl.app = ywl.create_app();
|
||||||
cb_stack
|
cb_stack
|
||||||
.add(ywl.app.init)
|
.add(ywl.app.init)
|
||||||
|
@ -181,7 +189,7 @@ ywl.create_app = function () {
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.code == 0) {
|
if (data.code == 0) {
|
||||||
// 验证成功
|
// 验证成功
|
||||||
window.location.href = ywl.page_options.reference;
|
window.location.href = ywl.page_options.ref;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hide_op_box();
|
hide_op_box();
|
||||||
|
@ -242,7 +250,7 @@ ywl.create_app = function () {
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.code == 0) {
|
if (data.code == 0) {
|
||||||
// 验证成功
|
// 验证成功
|
||||||
window.location.href = ywl.page_options.reference;
|
window.location.href = ywl.page_options.ref;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hide_op_box();
|
hide_op_box();
|
||||||
|
|
|
@ -11,40 +11,19 @@ ywl.on_init = function (cb_stack, cb_args) {
|
||||||
|
|
||||||
g_assist = ywl.create_assist();
|
g_assist = ywl.create_assist();
|
||||||
|
|
||||||
var config_list = ywl.page_options.config_list;
|
var core_server = ywl.page_options.core_server;
|
||||||
|
console.log(ywl.page_options, core_server);
|
||||||
|
|
||||||
// var ts_server_ip = config_list['ts_server_ip'];
|
$("#current-rdp-port").val(core_server.rdp.port);
|
||||||
// $("#current-ts-server-ip").val(ts_server_ip);
|
$("#current-ssh-port").val(core_server.ssh.port);
|
||||||
|
$("#current-telnet-port").val(core_server.telnet.port);
|
||||||
|
|
||||||
// var ts_server_rpc_ip = config_list['ts_server_rpc_ip'];
|
// $('#select-ip li a').click(function () {
|
||||||
// $("#current-rpc-ip").val(ts_server_rpc_ip);
|
// $("#current-ts-server-ip").val($(this).text());
|
||||||
//
|
// });
|
||||||
// var ts_server_rpc_port = config_list['ts_server_rpc_port'];
|
|
||||||
// $("#current-rpc-port").val(ts_server_rpc_port);
|
|
||||||
|
|
||||||
var ts_server_rdp_port = config_list['ts_server_rdp_port'];
|
|
||||||
$("#current-rdp-port").val(ts_server_rdp_port);
|
|
||||||
|
|
||||||
var ts_server_ssh_port = config_list['ts_server_ssh_port'];
|
|
||||||
$("#current-ssh-port").val(ts_server_ssh_port);
|
|
||||||
|
|
||||||
var ts_server_telnet_port = config_list['ts_server_telnet_port'];
|
|
||||||
$("#current-telnet-port").val(ts_server_telnet_port);
|
|
||||||
|
|
||||||
// var ip_html = [];
|
|
||||||
// for (var i = 0; i < config_list['_ip_list'].length; i++) {
|
|
||||||
// ip_html.push('<li><a href="javascript:;">' + config_list['_ip_list'][i] + '</a></li>');
|
|
||||||
// }
|
|
||||||
// $('#select-ip').html(ip_html.join(''));
|
|
||||||
|
|
||||||
$('#select-ip li a').click(function () {
|
|
||||||
$("#current-ts-server-ip").val($(this).text());
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#btn-check").click(function () {
|
$("#btn-check").click(function () {
|
||||||
var ts_server_ip = $("#current-ts-server-ip").val();
|
var ts_server_ip = $("#current-ts-server-ip").val();
|
||||||
// var ts_server_rpc_ip = $("#current-rpc-ip").val();
|
|
||||||
// var ts_server_rpc_port = $("#current-rpc-port").val();
|
|
||||||
var ts_server_rdp_port = $("#current-rdp-port").val();
|
var ts_server_rdp_port = $("#current-rdp-port").val();
|
||||||
var ts_server_ssh_port = $("#current-ssh-port").val();
|
var ts_server_ssh_port = $("#current-ssh-port").val();
|
||||||
var ts_server_telnet_port = $("#current-telnet-port").val();
|
var ts_server_telnet_port = $("#current-telnet-port").val();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<%!
|
<%!
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
page_title_ = '登录'
|
page_title_ = '登录'
|
||||||
## page_menu_ = ['host']
|
## page_menu_ = ['host']
|
||||||
## page_id_ = 'host'
|
## page_id_ = 'host'
|
||||||
%>
|
%>
|
||||||
<%inherit file="page_base.mako"/>
|
<%inherit file="page_base.mako"/>
|
||||||
|
|
||||||
|
@ -11,107 +11,103 @@
|
||||||
</%block>
|
</%block>
|
||||||
|
|
||||||
<%block name="embed_js" >
|
<%block name="embed_js" >
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
ywl.add_page_options({
|
ywl.add_page_options(${ page_param });
|
||||||
login_type: 'account',
|
</script>
|
||||||
reference: '${ reference }'
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</%block>
|
</%block>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div id="leftside">
|
<div id="leftside">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="auth-box auth-box-lg">
|
<div class="auth-box auth-box-lg">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a id="login-type-account" class="title" href="javascript:void(0);">账号/密码 登录</a>
|
<a id="login-type-account" class="title" href="javascript:void(0);">账号/密码 登录</a>
|
||||||
## <a id="login_type_usbkey" class="title" href="javascript:void(0);" onclick="change_login_type('usbkey');">USB-Key 登录</a>
|
## <a id="login_type_usbkey" class="title" href="javascript:void(0);" onclick="change_login_type('usbkey');">USB-Key 登录</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="input-area-quick" class="quick-area" style="display: none;">
|
<div id="input-area-quick" class="quick-area" style="display: none;">
|
||||||
<div class="quick-yes" style="display: none;">
|
<div class="quick-yes" style="display: none;">
|
||||||
<div class="quick-disc">请点击头像进行快速登录!</div>
|
<div class="quick-disc">请点击头像进行快速登录!</div>
|
||||||
<a id="btn-login-quick" class="quick-account" href="javascript:void(0);">
|
<a id="btn-login-quick" class="quick-account" href="javascript:void(0);">
|
||||||
<span class="quick-image"><i class="fa fa-male fa-fw"></i></span>
|
<span class="quick-image"><i class="fa fa-male fa-fw"></i></span>
|
||||||
<span id="quick-username" class="label label-primary quick-name">User Name</span>
|
<span id="quick-username" class="label label-primary quick-name">User Name</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="quick-no" style="display: none;">
|
<div class="quick-no" style="display: none;">
|
||||||
<div class="quick-disc">未发现已登录账号,无法进行快速登录!</div>
|
<div class="quick-disc">未发现已登录账号,无法进行快速登录!</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="input-area-account" class="inputarea" >
|
<div id="input-area-account" class="inputarea">
|
||||||
<div id="login_account" class="login-account">
|
<div id="login_account" class="login-account">
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<div class="input-group input-group-lg">
|
<div class="input-group input-group-lg">
|
||||||
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
||||||
<input id="username_account" type="text" class="form-control" placeholder="账号:邮箱地址或手机号" data-toggle="popover" data-trigger="manual" data-placement="top" value="${ user_name }">
|
<input id="username_account" type="text" class="form-control" placeholder="账号:邮箱地址或手机号" data-toggle="popover" data-trigger="manual" data-placement="top">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<div class="input-group input-group-lg">
|
<div class="input-group input-group-lg">
|
||||||
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
|
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
|
||||||
<input id="password_account" type="password" class="form-control" placeholder="密码"
|
<input id="password_account" type="password" class="form-control" placeholder="密码"
|
||||||
data-toggle="popover" data-trigger="manual" data-placement="top">
|
data-toggle="popover" data-trigger="manual" data-placement="top">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="login_usbkey" class="login-usbkey" style="display:none;">
|
<div id="login_usbkey" class="login-usbkey" style="display:none;">
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<div class="input-group input-group-lg">
|
<div class="input-group input-group-lg">
|
||||||
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
<span class="input-group-addon"><i class="fa fa-user fa-fw"></i></span>
|
||||||
<input id="username_usbkey" type="text" class="form-control" placeholder="账号,支持邮箱/手机号" value="设备查找中..." disabled>
|
<input id="username_usbkey" type="text" class="form-control" placeholder="账号,支持邮箱/手机号" value="设备查找中..." disabled>
|
||||||
</div>
|
</div>
|
||||||
<p id="usbkey_message" class="op_box op_wait"><i class="fa fa-circle-o-notch fa-spin"></i> 正在查找USB-Key,请稍候...</p>
|
<p id="usbkey_message" class="op_box op_wait"><i class="fa fa-circle-o-notch fa-spin"></i> 正在查找USB-Key,请稍候...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<div class="input-group input-group-lg">
|
<div class="input-group input-group-lg">
|
||||||
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
|
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
|
||||||
<input id="password_usbkey" type="password" class="form-control" placeholder="USB-Key设备密码">
|
<input id="password_usbkey" type="password" class="form-control" placeholder="USB-Key设备密码">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<div class="input-group input-group-lg">
|
<div class="input-group input-group-lg">
|
||||||
<span class="input-group-addon"><i class="fa fa-check-square-o fa-fw"></i></span>
|
<span class="input-group-addon"><i class="fa fa-check-square-o fa-fw"></i></span>
|
||||||
<input id="captcha" type="text" class="form-control" placeholder="验证码"
|
<input id="captcha" type="text" class="form-control" placeholder="验证码"
|
||||||
data-toggle="popover" data-trigger="manual" data-placement="top">
|
data-toggle="popover" data-trigger="manual" data-placement="top">
|
||||||
<span class="input-group-addon"><a href="javascript:;"><img id="captcha_image" src="/auth/get-captcha?{{ captcha_random }}"></a></span>
|
<span class="input-group-addon"><a href="javascript:;"><img id="captcha_image" src=""></a></span>
|
||||||
</div>
|
</div>
|
||||||
<p class="input-addon-desc">验证码,点击图片可更换</p>
|
<p class="input-addon-desc">验证码,点击图片可更换</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label><input type="checkbox" value=""> 记住我,12小时内无需重新登录。</label>
|
<label><input type="checkbox" value=""> 记住我,12小时内无需重新登录。</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inputbox">
|
<div class="inputbox">
|
||||||
<button id="btn-login-account" class="btn btn-primary btn-lg btn-block">登 录</button>
|
<button id="btn-login-account" class="btn btn-primary btn-lg btn-block">登 录</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p id="login_message" class="op_box" style="display:none;"></p>
|
<p id="login_message" class="op_box" style="display:none;"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -153,8 +153,9 @@
|
||||||
|
|
||||||
<%block name="embed_js">
|
<%block name="embed_js">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
ywl.add_page_options({
|
## ywl.add_page_options({
|
||||||
config_list: ${config_list}
|
## config_list: ${config_list}
|
||||||
});
|
## });
|
||||||
|
ywl.add_page_options(${ page_param });
|
||||||
</script>
|
</script>
|
||||||
</%block>
|
</%block>
|
||||||
|
|
Loading…
Reference in New Issue