This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Manipulate status of firewall rule on iPhone/Ipad with Confd command line client

Hi,

In the past I made an iOS app for my wifes iPhone to block/unblock Internet for our kids. This worked with DD-WRT on my access-point.

We now have a ASG home edition as firewall instead of the firewall in DD-WRT.
So I want to make a new iOS App that changes the status of a firewall rule object with cc (confd) by means of a GUI which uses SSH in the background.
I can't seem to figure out the syntax to change the status switch value of a firewall rule object.
Can someone help me with te correct commandline syntax?

Thanks in advance.
Jacco


This thread was automatically locked due to age.
  • What software version do you have?
  • there are several threads that give some tweaks about varous things but there's no official documentation for what you are trying to do..[[:)]]  maybe with those mdw commands you might be able to tinker with it and figure it out..[[:)]]
  • Hi Jacco,
    you can use the following script to toggle the status of a packetfilter rule when you know the confd reference of the rule object:

    #!/usr/bin/perl
    use warnings;
    use strict;

    use Astaro::ConfdPlRPC;
    use Data:[:D]umper;

    my $ref = shift(@ARGV);
    die "usage: $0 \n" unless defined($ref) && $ref =~ /REF_/;
    chomp($ref);
    my $sys = new Astaro::ConfdPlRPC() or die "Login failed.\n";
    $sys->lock();
    my $obj = $sys->get_object($ref);
    die "Unknown object $ref\n" unless $obj;
    print $obj->{data}->{status}." => ".($obj->{data}->{status}?0:1)."\n";
    $obj->{data}->{status} = ($obj->{data}->{status}?0:1);
    die Dumper($sys->err_list()) unless $sys->set_object($obj);
    $sys->commit();
    $sys->disconnect();

    You can find the object reference using the following command:

    cc get_objects packetfilter packetfilter
    This returns for example:

            {
                'autoname' => 1,
                'class' => 'packetfilter',
                'data' => {
                            'action' => 'accept',
                            'comment' => '',
                            'destination' => 'REF_NetworkInternet6',
                            'group' => '',
                            'log' => 0,
                            'name' => 'Any from Astaro RED (Network) to Internet IPv6',
                            'service' => 'REF_ServiceAny',
                            'source' => 'REF_haKxBeHySx',
                            'status' => 1,
                            'time' => ''
                          },
                'hidden' => 0,
                'lock' => '',
                'nodel' => '',
                'ref' => 'REF_mtIBUIPrVJ',
                'type' => 'packetfilter'
              },
    Now you can use the reference from 
     'ref' => 'REF_mtIBUIPrVJ' 
    You call it like this:
    perl pf_status_toggle.pl REF_mtIBUIPrVJ
    Hope that helps.

    Regards,
    Daniel
  • Thanks for your examples Daniel.
    I will give it a try. 

    Thanks Jacco
  • Daniels perl script works great!
    But for my iOS app I don't want to depend on a perl script.
    I want to use cc with arguments but I can't figure out te correct syntax. I have no knowledge of perl to correctly interpret Daniels code. 

    Is there someone that knows the cc syntax to change the status of a packet filter rule?
  • Enable: cc change_object REF_xyz status 1
    Disable: cc change_object REF_xyz status 0
  • Jacco, welcome to the User BB!

    Perhaps you could tell us a little more about what you want to accomplish.  In fact, if you're using the Web Filtering capability, your packet filter rule has no effect; traffic handled by the proxy is not affected by your manual packet filter rules.

    Cheers - Bob
  • Hello Bob,

    I want to give my wife a simple option (an Internet stop button on her iPad) to temporally block Internet for the kids.
    The WebAdmin portal is to complicated and to much work for her.

    I don't have web filtering enabled so that will not be the problem.

    With the examples of Daniel and Mario I will be able to develop an iOS app that will make this possible.

    Kind regards,
    Jacco