Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
luna
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
ops
luna
Commits
41b446cb
Unverified
Commit
41b446cb
authored
Jan 29, 2019
by
老广
Committed by
GitHub
Jan 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #57 from jumpserver/dev
Dev
parents
0b74facc
c2e693c7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
148 deletions
+75
-148
mock.py
mock.py
+53
-140
proxy.conf.json
proxy.conf.json
+2
-6
asset-tree.component.ts
src/app/elements/asset-tree/asset-tree.component.ts
+17
-1
cleftbar.component.ts
src/app/pages/control/cleftbar/cleftbar.component.ts
+2
-0
control.component.html
src/app/pages/control/control.component.html
+1
-1
No files found.
mock.py
View file @
41b446cb
#!/usr/bin/env python3
# coding: utf-8
import
eventlet
...
...
@@ -41,138 +40,61 @@ app = Flask(__name__, template_folder='dist')
socketio
=
None
nodes
=
[{
'id'
:
'6353b2d3-54f1-4354-bede-fe8d8eebfe0c'
,
'key'
:
'4'
,
'name'
:
'开发部'
,
'value'
:
'开发部'
,
'parent'
:
'6353b2d3-54f1-4354-bede-fe8d8eebfe0c'
,
'assets_granted'
:
[{
'id'
:
'9e911ac3-7231-441b-9123-e1945e93c0b0'
,
'hostname'
:
'Test-48'
,
'ip'
:
'172.15.1.48'
,
'port'
:
22
,
'system_users_granted'
:
[{
'id'
:
'859274bb-dc6e-4890-87dc-eefddf0ea8c1'
,
'name'
:
'111'
,
'username'
:
'1'
,
'priority'
:
20
,
'protocol'
:
'ssh'
,
'comment'
:
''
,
'login_mode'
:
'auto'
}],
'is_active'
:
True
,
'system_users_join'
:
'1'
,
'os'
:
None
,
nodes
=
[{
'iconSkin'
:
''
,
'id'
:
'0'
,
'isParent'
:
True
,
'meta'
:
{
'node'
:
{
'id'
:
'08a2ba4c-238a-4e01-9f07-eb82b8e3377b'
,
'key'
:
'0'
,
'name'
:
'ROOT'
,
'value'
:
'ROOT'
},
'type'
:
'node'
},
'name'
:
'ROOT (2)'
,
'open'
:
True
,
'pId'
:
''
,
'title'
:
'ROOT (2)'
},
{
'iconSkin'
:
'linux'
,
'id'
:
'f4d3b256-c19b-4472-9a53-b9f48e51f311'
,
'isParent'
:
False
,
'meta'
:
{
'asset'
:
{
'comment'
:
''
,
'domain'
:
None
,
'platform'
:
'Linux'
,
'comment'
:
''
,
'protocol'
:
'ssh'
,
'org_id'
:
'e338bd97-bdb1-47b1-95f7-4994776488b5'
,
'org_name'
:
'开发部'
}],
'assets_amount'
:
1
,
'org_id'
:
'e338bd97-bdb1-47b1-95f7-4994776488b5'
},
{
'id'
:
'cd3c1d48-4bf0-43e1-bca1-0817a1295e22'
,
'key'
:
'5:23:0:1'
,
'name'
:
'新节点 2'
,
'value'
:
'新节点 2'
,
'parent'
:
'a3852030-eeb5-4c0f-ba57-32cce42c8333'
,
'assets_granted'
:
[{
'id'
:
'9590ebfa-5720-461d-835f-fecfe6245c67'
,
'hostname'
:
'Test-48'
,
'ip'
:
'172.15.1.48'
,
'port'
:
22
,
'system_users_granted'
:
[{
'id'
:
'e2b1900f-b0e6-4813-b90a-7216d670a1cd'
,
'name'
:
'test_SSH'
,
'username'
:
'test'
,
'priority'
:
10
,
'protocol'
:
'ssh'
,
'comment'
:
''
,
'login_mode'
:
'auto'
}],
'hostname'
:
'centos'
,
'id'
:
'f4d3b256-c19b-4472-9a53-b9f48e51f311'
,
'ip'
:
'192.168.244.142'
,
'is_active'
:
True
,
'system_users_join'
:
'test'
,
'os'
:
None
,
'domain'
:
None
,
'platform'
:
'Linux'
,
'comment'
:
''
,
'protocol'
:
'ssh'
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
,
'org_name'
:
'测试部'
}],
'assets_amount'
:
1
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
},
{
'id'
:
'a3852030-eeb5-4c0f-ba57-32cce42c8333'
,
'key'
:
'5:23:0'
,
'name'
:
'新节点 1'
,
'value'
:
'新节点 1'
,
'parent'
:
'39c0f461-e9c2-4ef5-926d-3308ae9c43d8'
,
'assets_granted'
:
[],
'assets_amount'
:
0
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
},
{
'id'
:
'39c0f461-e9c2-4ef5-926d-3308ae9c43d8'
,
'key'
:
'5:23'
,
'name'
:
'hbase'
,
'value'
:
'hbase'
,
'parent'
:
'd49f0fb2-ad3e-4f13-835f-12c13329f3be'
,
'assets_granted'
:
[],
'assets_amount'
:
0
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
},
{
'id'
:
'd49f0fb2-ad3e-4f13-835f-12c13329f3be'
,
'key'
:
'5'
,
'name'
:
'测试部'
,
'value'
:
'测试部'
,
'parent'
:
'd49f0fb2-ad3e-4f13-835f-12c13329f3be'
,
'assets_granted'
:
[],
'assets_amount'
:
0
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
},
{
'id'
:
'c10cb68a-816d-4030-9a7b-e9a22a83818a'
,
'key'
:
'5:12'
,
'name'
:
'测试资产666'
,
'value'
:
'测试资产666'
,
'parent'
:
'd49f0fb2-ad3e-4f13-835f-12c13329f3be'
,
'assets_granted'
:
[{
'id'
:
'9590ebfa-5720-461d-835f-fecfe6245c67'
,
'hostname'
:
'Test-48'
,
'ip'
:
'172.15.1.48'
,
'port'
:
22
,
'system_users_granted'
:
[{
'id'
:
'e2b1900f-b0e6-4813-b90a-7216d670a1cd'
,
'name'
:
'test_SSH'
,
'username'
:
'test'
,
'priority'
:
10
,
'protocol'
:
'ssh'
,
'comment'
:
''
,
'login_mode'
:
'auto'
}],
'is_active'
:
True
,
'system_users_join'
:
'test'
,
'os'
:
None
,
'protocol'
:
'ssh'
},
'system_users'
:
[{
'comment'
:
''
,
'id'
:
'2fb10ed2-db03-4c69-9fc1-aacbb2a9cc75'
,
'login_mode'
:
'auto'
,
'name'
:
'web'
,
'priority'
:
20
,
'protocol'
:
'ssh'
,
'username'
:
'web'
}],
'type'
:
'asset'
},
'name'
:
'centos'
,
'open'
:
False
,
'pId'
:
'0'
,
'title'
:
'192.168.244.142'
},
{
'iconSkin'
:
'windows'
,
'id'
:
'741127ed-1e51-46c0-8d3d-f8a7d215b70d'
,
'isParent'
:
False
,
'meta'
:
{
'asset'
:
{
'comment'
:
''
,
'domain'
:
None
,
'platform'
:
'Linux'
,
'comment'
:
''
,
'protocol'
:
'ssh'
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
,
'org_name'
:
'测试部'
}],
'assets_amount'
:
1
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
},
{
'id'
:
'c57099a1-f1fc-48d2-9d0c-611ed65560b2'
,
'key'
:
'5:3'
,
'name'
:
'测试资产265465'
,
'value'
:
'测试资产265465'
,
'parent'
:
'd49f0fb2-ad3e-4f13-835f-12c13329f3be'
,
'assets_granted'
:
[{
'id'
:
'965e86b1-b09a-4c1e-8b6c-784803fdeeaf'
,
'hostname'
:
'Test01-22'
,
'ip'
:
'172.15.2.22'
,
'port'
:
22
,
'system_users_granted'
:
[{
'id'
:
'e2b1900f-b0e6-4813-b90a-7216d670a1cd'
,
'name'
:
'test_SSH'
,
'username'
:
'test'
,
'priority'
:
10
,
'protocol'
:
'ssh'
,
'comment'
:
''
,
'login_mode'
:
'auto'
}],
'hostname'
:
'windows'
,
'id'
:
'741127ed-1e51-46c0-8d3d-f8a7d215b70d'
,
'ip'
:
'192.168.244.142'
,
'is_active'
:
True
,
'
system_users_join'
:
'test
'
,
'
os'
:
None
,
'
domain'
:
None
,
'platform'
:
'Linux'
,
'comment'
:
''
,
'protocol'
:
'ssh
'
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
,
'org_name'
:
'测试部'
}]
,
'
assets_amount'
:
1
,
'org_id'
:
'8eb2637c-e14f-41f1-b1b1-00a2dfa20248'
}]
'
platform'
:
'Windows
'
,
'
port'
:
3389
,
'
protocol'
:
'rdp'
}
,
'system_users'
:
[]
,
'type'
:
'asset'
}
,
'name'
:
'windows
'
,
'open'
:
False
,
'pId'
:
'0'
,
'
title'
:
'192.168.244.142'
}]
class
ProxyServer
:
def
__init__
(
self
,
client
,
asset
,
system_user
):
...
...
@@ -195,6 +117,7 @@ class ProxyServer:
break
self
.
server
.
send
(
data
)
elif
self
.
client
.
change_size_evt
in
r
:
self
.
client
.
change_size_evt
.
recv
(
1
)
self
.
resize_win_size
()
def
resize_win_size
(
self
):
...
...
@@ -206,7 +129,7 @@ class ProxyServer:
def
ssh_with_password
(
self
,
width
=
80
,
height
=
24
):
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
connect
(
"192.168.244.1
77"
,
22
,
"root"
,
"redhat123
"
)
ssh
.
connect
(
"192.168.244.1
42"
,
22
,
"root"
,
"redhat
"
)
chan
=
ssh
.
invoke_shell
(
term
=
'xterm'
,
width
=
width
,
height
=
height
)
return
chan
...
...
@@ -271,10 +194,9 @@ def send_js(path):
return
send_from_directory
(
'dist'
,
path
)
@app.route
(
'/api/perms/v1/user/nodes-assets/'
)
@app.route
(
'/api/perms/v1/user/nodes-assets/
tree/
'
)
def
asset_groups_assets
():
# node = json.loads(nodes)
return
jsonify
([])
return
jsonify
(
nodes
)
@app.route
(
'/api/terminal/v1/sessions/test/replay/'
)
...
...
@@ -297,15 +219,6 @@ def get_session_replay(pk):
})
@app.route
(
'/api/perms/v1/user/nodes/children/'
)
def
get_nodes_children
():
data1
=
nodes
if
request
.
args
.
get
(
'id'
):
return
jsonify
(
data2
)
else
:
return
jsonify
(
data1
)
@app.route
(
'/luna/i18n/<i18n>'
)
def
i18n
(
i18n
):
return
send_file
(
'./i18n/'
+
i18n
)
...
...
proxy.conf.json
View file @
41b446cb
{
"/api/perms/v1/user/nodes/children/"
:
{
"target"
:
"http://127.0.0.1:8080"
,
"secure"
:
false
},
"/api"
:
{
"target"
:
"http://127.0.0.1:
8080
"
,
"target"
:
"http://127.0.0.1:
5001
"
,
"secure"
:
false
},
"/luna/i18n"
:
{
...
...
@@ -12,7 +8,7 @@
"secure"
:
false
},
"/socket.io/"
:
{
"target"
:
"http://127.0.0.1:500
0
"
,
"target"
:
"http://127.0.0.1:500
1
"
,
"secure"
:
false
,
"ws"
:
true
},
...
...
src/app/elements/asset-tree/asset-tree.component.ts
View file @
41b446cb
...
...
@@ -4,6 +4,7 @@ import {AppService, LogService} from '../../app.service';
import
{
MAT_DIALOG_DATA
,
MatDialog
,
MatDialogRef
}
from
'@angular/material'
;
import
{
FormControl
,
Validators
}
from
'@angular/forms'
;
import
{
BehaviorSubject
}
from
'rxjs/BehaviorSubject'
;
import
{
Router
,
ActivatedRoute
,
Params
}
from
'@angular/router'
;
declare
var
$
:
any
;
...
...
@@ -54,7 +55,9 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
constructor
(
private
_appService
:
AppService
,
public
_dialog
:
MatDialog
,
public
_logger
:
LogService
)
{
public
_logger
:
LogService
,
private
activatedRoute
:
ActivatedRoute
,
)
{
this
.
searchEvt$
=
new
BehaviorSubject
<
string
>
(
this
.
query
);
}
...
...
@@ -69,6 +72,7 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
.
subscribe
((
n
)
=>
{
this
.
filter
();
});
}
ngOnChanges
(
changes
:
SimpleChanges
)
{
...
...
@@ -83,6 +87,18 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
draw
()
{
$
.
fn
.
zTree
.
init
(
$
(
'#ztree'
),
this
.
setting
,
this
.
Data
);
this
.
zTree
=
$
.
fn
.
zTree
.
getZTreeObj
(
'ztree'
);
this
.
activatedRoute
.
queryParams
.
subscribe
(
params
=>
{
const
login_to
=
params
[
'login_to'
];
if
(
login_to
)
{
this
.
Data
.
forEach
(
t
=>
{
if
(
login_to
===
t
.
id
&&
t
.
isParent
===
false
)
{
this
.
Connect
(
t
);
return
;
}
});
}
});
}
showRMenu
(
left
,
top
)
{
...
...
src/app/pages/control/cleftbar/cleftbar.component.ts
View file @
41b446cb
...
...
@@ -76,6 +76,7 @@ export class CleftbarComponent implements OnInit {
}
});
});
window
.
dispatchEvent
(
new
Event
(
'resize'
));
}
static
Show
()
{
...
...
@@ -91,6 +92,7 @@ export class CleftbarComponent implements OnInit {
}
});
});
window
.
dispatchEvent
(
new
Event
(
'resize'
));
}
constructor
(
private
_appService
:
AppService
,
...
...
src/app/pages/control/control.component.html
View file @
41b446cb
...
...
@@ -3,7 +3,7 @@
<pages-control-cleftbar></pages-control-cleftbar>
</div>
<div
fxFlex=
"0"
ngxSplitHandle
[
style
.
display
]="
activeViewIsRdp
()
?
'
none
'
:
'
block
'"
(
mouseup
)="
dragSplitBtn
($
event
)"
></div>
<div
fxFlex=
"1 1 80%
"
ngxSplitArea
class=
"content"
>
<div
[
fxFlex
]="
DataStore
.
leftbarshow
?
'
1
1
80
%'
:
'
1
1
100
%'
"
ngxSplitArea
class=
"content"
>
<pages-control-control></pages-control-control>
</div>
</div>
...
...
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