Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
442d4e72
Unverified
Commit
442d4e72
authored
Jul 02, 2018
by
老广
Committed by
GitHub
Jul 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1492 from jumpserver/feature_telnet
[Feature] 添加功能,支持 telnet server.
parents
6fa0562d
39937975
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
15 deletions
+41
-15
asset.py
apps/assets/forms/asset.py
+2
-2
user.py
apps/assets/forms/user.py
+2
-1
asset.py
apps/assets/models/asset.py
+14
-0
user.py
apps/assets/models/user.py
+2
-0
asset.py
apps/assets/serializers/asset.py
+1
-1
_system_user.html
apps/assets/templates/assets/_system_user.html
+9
-2
asset_create.html
apps/assets/templates/assets/asset_create.html
+6
-5
asset_update.html
apps/assets/templates/assets/asset_update.html
+1
-0
django.mo
apps/i18n/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/i18n/zh/LC_MESSAGES/django.po
+0
-0
api.py
apps/perms/api.py
+4
-4
No files found.
apps/assets/forms/asset.py
View file @
442d4e72
...
...
@@ -16,7 +16,7 @@ class AssetCreateForm(forms.ModelForm):
fields
=
[
'hostname'
,
'ip'
,
'public_ip'
,
'port'
,
'comment'
,
'nodes'
,
'is_active'
,
'admin_user'
,
'labels'
,
'platform'
,
'domain'
,
'domain'
,
'protocol'
,
]
widgets
=
{
...
...
@@ -56,7 +56,7 @@ class AssetUpdateForm(forms.ModelForm):
fields
=
[
'hostname'
,
'ip'
,
'port'
,
'nodes'
,
'is_active'
,
'platform'
,
'public_ip'
,
'number'
,
'comment'
,
'admin_user'
,
'labels'
,
'domain'
,
'domain'
,
'protocol'
,
]
widgets
=
{
'nodes'
:
forms
.
SelectMultiple
(
attrs
=
{
...
...
apps/assets/forms/user.py
View file @
442d4e72
...
...
@@ -94,10 +94,11 @@ class SystemUserForm(PasswordAndKeyAuthForm):
system_user
=
super
()
.
save
()
password
=
self
.
cleaned_data
.
get
(
'password'
,
''
)
or
None
login_mode
=
self
.
cleaned_data
.
get
(
'login_mode'
,
''
)
or
None
protocol
=
self
.
cleaned_data
.
get
(
'protocol'
)
or
None
auto_generate_key
=
self
.
cleaned_data
.
get
(
'auto_generate_key'
,
False
)
private_key
,
public_key
=
super
()
.
gen_keys
()
if
login_mode
==
SystemUser
.
MANUAL_LOGIN
:
if
login_mode
==
SystemUser
.
MANUAL_LOGIN
or
protocol
==
SystemUser
.
TELNET_PROTOCOL
:
system_user
.
auto_push
=
0
system_user
.
save
()
...
...
apps/assets/models/asset.py
View file @
442d4e72
...
...
@@ -57,13 +57,27 @@ class Asset(models.Model):
(
'MacOS'
,
'MacOS'
),
(
'BSD'
,
'BSD'
),
(
'Windows'
,
'Windows'
),
(
'Windows2016'
,
'Windows(2016)'
),
(
'Other'
,
'Other'
),
)
SSH_PROTOCOL
=
'ssh'
RDP_PROTOCOL
=
'rdp'
TELNET_PROTOCOL
=
'telnet'
PROTOCOL_CHOICES
=
(
(
SSH_PROTOCOL
,
'ssh'
),
(
RDP_PROTOCOL
,
'rdp'
),
(
TELNET_PROTOCOL
,
'telnet (beta)'
),
)
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
),
db_index
=
True
)
hostname
=
models
.
CharField
(
max_length
=
128
,
unique
=
True
,
verbose_name
=
_
(
'Hostname'
))
protocol
=
models
.
CharField
(
max_length
=
128
,
default
=
SSH_PROTOCOL
,
choices
=
PROTOCOL_CHOICES
,
verbose_name
=
_
(
'Protocol'
))
port
=
models
.
IntegerField
(
default
=
22
,
verbose_name
=
_
(
'Port'
))
platform
=
models
.
CharField
(
max_length
=
128
,
choices
=
PLATFORM_CHOICES
,
default
=
'Linux'
,
verbose_name
=
_
(
'Platform'
))
...
...
apps/assets/models/user.py
View file @
442d4e72
...
...
@@ -95,9 +95,11 @@ class AdminUser(AssetUser):
class
SystemUser
(
AssetUser
):
SSH_PROTOCOL
=
'ssh'
RDP_PROTOCOL
=
'rdp'
TELNET_PROTOCOL
=
'telnet'
PROTOCOL_CHOICES
=
(
(
SSH_PROTOCOL
,
'ssh'
),
(
RDP_PROTOCOL
,
'rdp'
),
(
TELNET_PROTOCOL
,
'telnet (beta)'
),
)
AUTO_LOGIN
=
'auto'
...
...
apps/assets/serializers/asset.py
View file @
442d4e72
...
...
@@ -43,7 +43,7 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
fields
=
(
"id"
,
"hostname"
,
"ip"
,
"port"
,
"system_users_granted"
,
"is_active"
,
"system_users_join"
,
"os"
,
'domain'
,
"platform"
,
"comment"
"platform"
,
"comment"
,
"protocol"
,
)
@staticmethod
...
...
apps/assets/templates/assets/_system_user.html
View file @
442d4e72
...
...
@@ -104,7 +104,14 @@ function protocolChange() {
$
.
each
(
need_change_field
,
function
(
index
,
value
)
{
$
(
value
).
closest
(
'.form-group'
).
addClass
(
'hidden'
)
});
}
else
{
}
else
if
(
$
(
protocol_id
+
" option:selected"
).
text
()
===
'telnet (beta)'
)
{
$
(
'.auth-fields'
).
removeClass
(
'hidden'
);
$
.
each
(
need_change_field
,
function
(
index
,
value
)
{
$
(
value
).
closest
(
'.form-group'
).
addClass
(
'hidden'
)
});
}
else
{
if
(
$
(
login_mode_id
).
val
()
===
'manual'
){
$
(
sudo_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
);
$
(
shell_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
);
...
...
@@ -133,8 +140,8 @@ function loginModeChange(){
}
else
if
(
$
(
login_mode_id
).
val
()
===
'auto'
){
$
(
'#auth_title_id'
).
removeClass
(
'hidden'
);
protocolChange
();
$
(
password_id
).
closest
(
'.form-group'
).
removeClass
(
'hidden'
)
protocolChange
();
}
}
...
...
apps/assets/templates/assets/asset_create.html
View file @
442d4e72
...
...
@@ -17,6 +17,7 @@
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.protocol layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
{% bootstrap_field form.domain layout="horizontal" %}
...
...
@@ -85,14 +86,14 @@ $(document).ready(function () {
allowClear
:
true
,
templateSelection
:
format
});
$
(
"#id_p
latform
"
).
change
(
function
(){
var
p
latform
=
$
(
"#id_platform
option:selected"
).
text
();
$
(
"#id_p
rotocol
"
).
change
(
function
(){
var
p
rotocol
=
$
(
"#id_protocol
option:selected"
).
text
();
var
port
=
22
;
if
(
p
latform
===
'Windows
'
){
if
(
p
rotocol
===
'rdp
'
){
port
=
3389
;
}
if
(
p
latform
===
'Other
'
){
port
=
null
;
if
(
p
rotocol
===
'telnet (beta)
'
){
port
=
23
;
}
$
(
"#id_port"
).
val
(
port
);
});
...
...
apps/assets/templates/assets/asset_update.html
View file @
442d4e72
...
...
@@ -21,6 +21,7 @@
<h3>
{% trans 'Basic' %}
</h3>
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.ip layout="horizontal" %}
{% bootstrap_field form.protocol layout="horizontal" %}
{% bootstrap_field form.port layout="horizontal" %}
{% bootstrap_field form.platform layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
...
...
apps/i18n/zh/LC_MESSAGES/django.mo
View file @
442d4e72
No preview for this file type
apps/i18n/zh/LC_MESSAGES/django.po
View file @
442d4e72
This diff is collapsed.
Click to expand it.
apps/perms/api.py
View file @
442d4e72
...
...
@@ -73,9 +73,9 @@ class UserGrantedAssetsApi(ListAPIView):
util
=
AssetPermissionUtil
(
user
)
for
k
,
v
in
util
.
get_assets
()
.
items
():
if
k
.
is_unixlike
():
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'ssh'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'ssh'
,
'telnet'
]
]
else
:
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'rdp'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'rdp'
,
'telnet'
]
]
k
.
system_users_granted
=
system_users_granted
queryset
.
append
(
k
)
return
queryset
...
...
@@ -124,9 +124,9 @@ class UserGrantedNodesWithAssetsApi(ListAPIView):
assets
=
_assets
.
keys
()
for
k
,
v
in
_assets
.
items
():
if
k
.
is_unixlike
():
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'ssh'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'ssh'
,
'telnet'
]
]
else
:
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
==
'rdp'
]
system_users_granted
=
[
s
for
s
in
v
if
s
.
protocol
in
[
'rdp'
,
'telnet'
]
]
k
.
system_users_granted
=
system_users_granted
node
.
assets_granted
=
assets
queryset
.
append
(
node
)
...
...
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