Skip to content

Commit

Permalink
Fix port forwarding sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxbey committed Sep 12, 2017
1 parent a0fe746 commit 6f1bd9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions termius/core/models/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ class PFRule(Model):
'remote_port': Field(int, False, 22),
}
set_name = 'pfrule_set'
crypto_fields = {'label', 'bound_address', 'hostname'}
crypto_fields = {'label', 'hostname'}

binding_getter = {
'L': attrgetter(
'Local Rule': attrgetter(
'bound_address', 'local_port', 'hostname', 'remote_port'
),
'D': attrgetter('bound_address', 'local_port'),
'Dynamic Rule': attrgetter('bound_address', 'local_port'),
}
binding_getter['R'] = binding_getter['L']
binding_getter['Remote Rule'] = binding_getter['Local Rule']

@property
def binding(self):
Expand Down
12 changes: 6 additions & 6 deletions termius/handlers/pf_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def fields(self):
def binding_parsers(self):
"""Return binding parser per type abbreviation."""
return {
'D': BindingParser.dynamic,
'L': BindingParser.local,
'R': BindingParser.remote,
'Dynamic Rule': BindingParser.dynamic,
'Local Rule': BindingParser.local,
'Remote Rule': BindingParser.remote,
}

def extend_parser(self, parser):
Expand All @@ -42,15 +42,15 @@ def extend_parser(self, parser):
)
parser.add_argument(
'--dynamic', dest='pf_type', action='store_const',
const='D', help='dynamic port forwarding'
const='Dynamic Rule', help='dynamic port forwarding'
)
parser.add_argument(
'--remote', dest='pf_type', action='store_const',
const='R', help='remote port forwarding'
const='Remote Rule', help='remote port forwarding'
)
parser.add_argument(
'--local', dest='pf_type', action='store_const',
const='L', help='local port forwarding'
const='Local Rule', help='local port forwarding'
)
parser.add_argument(
'--binding', metavar='BINDINGS',
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/pfrule.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"L"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Local Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ $(get_model_field 'pfrule_set' $pfrule 'bound_address') = "null" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = '2' ]
Expand All @@ -36,7 +36,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"R"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Remote Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ $(get_model_field 'pfrule_set' $pfrule 'bound_address') = "null" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = "2" ]
Expand All @@ -50,7 +50,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"D"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Dynamic Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ $(get_model_field 'pfrule_set' $pfrule 'bound_address') = "null" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = "2222" ]
Expand All @@ -64,7 +64,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"L"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Local Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ $(get_model_field 'pfrule_set' $pfrule 'bound_address') = "\"local\"" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = "2" ]
Expand All @@ -78,7 +78,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"R"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Remote Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ $(get_model_field 'pfrule_set' $pfrule 'bound_address') = "\"localhost\"" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = "2" ]
Expand All @@ -92,7 +92,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"D"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Dynamic Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ "$(get_model_field 'pfrule_set' $pfrule 'bound_address')" = "\"127.0.0.1\"" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = "2222" ]
Expand All @@ -107,7 +107,7 @@ setup() {
[ "$status" -eq 0 ]
[ $(get_models_set_length 'pfrule_set') -eq 1 ]
pfrule=${lines[1]}
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"L"' ]
[ "$(get_model_field 'pfrule_set' $pfrule 'pf_type')" = '"Local Rule"' ]
[ $(get_model_field 'pfrule_set' $pfrule 'host') = $host ]
[ "$(get_model_field 'pfrule_set' $pfrule 'bound_address')" = "\"local\"" ]
[ $(get_model_field 'pfrule_set' $pfrule 'local_port') = "2" ]
Expand Down

0 comments on commit 6f1bd9a

Please sign in to comment.