Objective-C: check firewall status in OSX?

My objective-c application should know if the firewall is running on OSX, so it can tell the user to disable it or create a new rule.

In addition, is it possible to create rules directly from my application so that users do not have to solve network problems?

John

+5
source share
2 answers

I am writing a function that will give you the OSX firewall status :)

-(BOOL)getFirewallStatus{


    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES);

    NSString *path = [paths objectAtIndex:0];

    path = [NSString stringWithFormat:@"%@/%@",path,@"Preferences/com.apple.alf.plist"];

    path = [path stringByReplacingOccurrencesOfString:@"/System"
                                           withString:@""];




    NSDictionary* _dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path];


    // firewall status
    int status = [[_dictionary valueForKey:@"globalstate"] integerValue];

    if (status == 0)
    {
        return NO;
    }

    return  YES;
}
+4
source

(.. Finder), / - - - .

(, ), ​​ . Bonjour/mDNSResponder ( nat'ed). Apple - Objective-C dns_sd.h:

http://developer.apple.com/library/mac/#samplecode/PortMapper/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007879-Intro-DontLinkElementID_2

, TCM. , , ARC ( ).

http://code.google.com/p/tcmportmapper/

UPnP NAT-PMP.

, ( ), ipfw. . Google "ipfw os x". StackOverflow . Brilliant.

, ...

+1

All Articles