This repository was archived by the owner on Jun 22, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
5
- __version__ = '0.0.64 '
5
+ __version__ = '0.0.65 '
Original file line number Diff line number Diff line change 5
5
import random
6
6
from hashlib import md5
7
7
import re
8
+ from collections import OrderedDict
8
9
9
10
from .utils import ssh_key_string_to_obj , get_logger
10
11
@@ -101,22 +102,22 @@ def system_users_name_list(self):
101
102
return '[' + ', ' .join ([s .name for s in self .system_users_granted ]) + ']'
102
103
103
104
@property
104
- def protocols_name (self ):
105
- names = []
106
- for protocol in self .protocols :
107
- _name , port = protocol .split ('/' )
108
- names .append (_name )
109
- return names
105
+ def protocols_as_dict (self ):
106
+ d = OrderedDict ()
107
+ for i in self .protocols :
108
+ if '/' not in i :
109
+ continue
110
+ name , port = i .split ('/' )[:2 ]
111
+ if not all ([name , port ]):
112
+ continue
113
+ d [name ] = int (port )
114
+ return d
110
115
111
116
def has_protocol (self , name ):
112
- return name in self .protocols_name
117
+ return name in self .protocols_as_dict
113
118
114
119
def get_port_by_name (self , name ):
115
- for protocol in self .protocols :
116
- _name , port = protocol .split ('/' )
117
- if _name .lower () == name :
118
- return port
119
- return None
120
+ return self .protocols_as_dict .get (name , 22 )
120
121
121
122
@property
122
123
def ssh_port (self ):
You can’t perform that action at this time.
0 commit comments