Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
8ea9523b
Commit
8ea9523b
authored
Dec 15, 2020
by
frankiejol
Browse files
refactor(networking): show correct allowed domain
parent
1f4ef498
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Ravada/Front.pm
View file @
8ea9523b
...
...
@@ -727,7 +727,9 @@ sub list_bases_network($self, $id_network) {
$sth
->
execute
;
my
$default
=
$sth
->
fetchrow_hashref
();
$sth
->
finish
;
lock_hash
(
%$default
);
warn
"
Warning: all_domains and no_domains both true for default network
"
.
Dumper
(
$default
)
if
$default
->
{
all_domains
}
&&
$default
->
{
no_domains
};
my
$sth_nd
=
$CONNECTOR
->
dbh
->
prepare
("
SELECT id,allowed,anonymous FROM domains_network
"
.
"
WHERE id_domain=? AND id_network=?
"
...
...
@@ -738,15 +740,17 @@ sub list_bases_network($self, $id_network) {
$sth
->
execute
();
my
@bases
;
while
(
my
$row
=
$sth
->
fetchrow_hashref
)
{
$row
->
{
anonymous
}
=
(
$default
->
{
anonymous
}
or
0
);
$sth_nd
->
execute
(
$row
->
{
id
},
$id_network
);
my
(
$id
,
$allowed
,
$anonymous
)
=
$sth_nd
->
fetchrow
;
$row
->
{
anonymous
}
=
$anonymous
if
defined
$anonymous
;
$row
->
{
anonymous
}
=
(
$anonymous
or
0
);
if
(
defined
$allowed
)
{
$row
->
{
allowed
}
=
$allowed
;
}
else
{
$row
->
{
allowed
}
=
1
;
$row
->
{
allowed
}
=
$default
->
{
all_domains
};
$row
->
{
allowed
}
=
0
if
$default
->
{
no_domains
};
}
lock_hash
(
%$row
);
...
...
t/70_networks.t
View file @
8ea9523b
...
...
@@ -247,6 +247,25 @@ sub _id_network {
return
$id
;
}
sub
test_conflict_allowed
{
my
$sth
=
connector
->
dbh
->
prepare
(
"
INSERT INTO networks (name, address, all_domains, no_domains)
"
.
"
VALUES ( ? , ?, ?, ? )
"
);
my
$name
=
'
all
';
$sth
->
execute
(
$name
,
'
91.2.3.4/24
',
1
,
1
);
$sth
=
connector
->
dbh
->
prepare
(
"
SELECT all_domains, no_domains FROM networks WHERE name=?
"
);
$sth
->
execute
(
$name
);
my
(
$all
,
$no
)
=
$sth
->
fetchrow
;
TODO:
{
local
$TODO
=
"
Requires trigger to avoid all_domains=1 and no_domains=1
";
isnt
(
$all
,
$no
);
};
}
########################################################################3
#
#
...
...
@@ -260,6 +279,8 @@ my $domain = $vm->create_domain( name => $domain_name
$domain
->
prepare_base
(
user_admin
);
$domain
->
is_public
(
1
);
test_conflict_allowed
();
my
$net
=
Ravada::
Network
->
new
(
address
=>
'
127.0.0.1/32
');
ok
(
$net
->
allowed
(
$domain
->
id
));
...
...
Write
Preview
Supports
Markdown
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