Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
M
micro-remote
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tarak.li
micro-remote
Commits
d6fe0f6d
Commit
d6fe0f6d
authored
Mar 19, 2020
by
tarak.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提测版本
parent
37c3a38b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
5 deletions
+54
-5
app_bootstrap.py
server/www/teleport/app_bootstrap.py
+38
-1
page_single_base.mako
server/www/teleport/view/page_single_base.mako
+1
-1
configs.py
server/www/teleport/webroot/app/base/configs.py
+12
-1
__init__.py
server/www/teleport/webroot/app/controller/__init__.py
+3
-2
plugin.py
server/www/teleport/webroot/app/controller/plugin.py
+0
-0
No files found.
server/www/teleport/app_bootstrap.py
View file @
d6fe0f6d
# -*- coding: utf-8 -*-
import
os
import
socket
import
sys
sys
.
path
.
append
(
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)),
'webroot'
))
def
current_ip
():
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
connect
((
"8.8.8.8"
,
80
))
ip
=
s
.
getsockname
()[
0
]
s
.
close
()
return
ip
class
Consul
(
object
):
def
__init__
(
self
,
url
):
self
.
_url
=
url
@property
def
url
(
self
):
return
"{}/v1/agent/service/register"
.
format
(
self
.
_url
)
def
register_device
(
self
,
name
,
addr
,
port
:
int
):
data
=
{
"ID"
:
"{}"
.
format
(
name
),
"Name"
:
name
,
"Address"
:
addr
,
"Port"
:
int
(
port
),
}
header
=
{
"Authorization"
:
"Basic bWljcm8tY29uc3VsLWFnZW50OjEyMzQ1Ng=="
}
from
app.base.logger
import
log
log
.
i
(
self
.
url
)
log
.
i
(
data
)
import
requests
resp
=
requests
.
put
(
self
.
url
,
headers
=
header
,
json
=
data
)
log
.
i
(
'register_device
%
s
%
s'
,
resp
.
status_code
,
resp
.
text
)
return
resp
.
status_code
==
200
def
main
():
from
app.app_env
import
PATH_APP_ROOT
,
PATH_DATA
from
app.base.webapp
import
tp_web_app
_web_app
=
tp_web_app
()
if
not
_web_app
.
init
(
PATH_APP_ROOT
,
PATH_DATA
):
return
1
# from app.base.configs import tp_cfg
# cfg = tp_cfg()
# consul_host = cfg.plugin.consul
# Consul(consul_host).register_device('micro-remote', current_ip(), 7190)
return
_web_app
.
run
()
...
...
server/www/teleport/view/page_single_base.mako
View file @
d6fe0f6d
...
...
@@ -13,7 +13,7 @@
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
content=
"yes"
name=
"apple-mobile-web-app-capable"
>
<meta
content=
"black-translucent"
name=
"apple-mobile-web-app-status-bar-style"
>
<title>
${self.attr.page_title_}::
TELEPORT
</title>
<title>
${self.attr.page_title_}::
micro-remote
</title>
<link
rel=
"shortcut icon"
href=
"${ static_url('favicon.png') }"
>
<link
href=
"${ static_url('plugins/bootstrap/css/bootstrap.min.css') }"
rel=
"stylesheet"
type=
"text/css"
/>
...
...
server/www/teleport/webroot/app/base/configs.py
View file @
d6fe0f6d
...
...
@@ -316,7 +316,8 @@ class AppConfig(BaseAppConfig):
return
[
{
'common'
:
[
'ip'
,
'port'
,
'log-file'
,
'log-level'
,
'debug-mode'
,
'core-server-rpc'
]},
{
'database'
:
[
'type'
,
'sqlite-file'
,
'mysql-host'
,
'mysql-port'
,
'mysql-db'
,
'mysql-prefix'
,
'mysql-user'
,
'mysql-password'
]}
'mysql-password'
]},
{
"plugin"
:
[
"core_host"
,
"consul"
]}
]
def
_on_load
(
self
,
cfg_parser
):
...
...
@@ -389,6 +390,16 @@ class AppConfig(BaseAppConfig):
if
_tmp_str
is
not
None
:
self
.
set_kv
(
'database::mysql-password'
,
_tmp_str
)
_sec
=
cfg_parser
[
'plugin'
]
_tmp_str
=
_sec
.
get
(
'core_host'
,
None
)
if
_tmp_str
is
not
None
:
self
.
set_kv
(
'plugin::core_host'
,
_tmp_str
)
_tmp_str
=
_sec
.
get
(
'consul'
,
None
)
if
_tmp_str
is
not
None
:
self
.
set_kv
(
'plugin::consul'
,
_tmp_str
)
_log_file
,
ok
=
self
.
get_str
(
'common::log-file'
)
if
ok
and
_log_file
:
self
.
log_path
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
_log_file
))
...
...
server/www/teleport/webroot/app/controller/__init__.py
View file @
d6fe0f6d
...
...
@@ -292,9 +292,10 @@ controllers = [
# 绑定支付宝账户
(
r'/plugin/bind_pay_account'
,
plugin
.
BindPayAccountHandler
),
# 账户状态
(
r'/plugin/account_status'
,
plugin
.
AccountStatusHandler
),
(
r'/
micro_remote/
plugin/account_status'
,
plugin
.
AccountStatusHandler
),
# 账户账户密码获取
(
r'/plugin/account_info'
,
plugin
.
AccountInfoHandler
),
(
r'/micro_remote/plugin/account_info'
,
plugin
.
AccountInfoHandler
),
# websocket for real-time information
# ws-client call 'http://ip:7190/ws/action/'
...
...
server/www/teleport/webroot/app/controller/plugin.py
View file @
d6fe0f6d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment