-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHBPBlockManager.h
More file actions
40 lines (31 loc) · 1.36 KB
/
HBPBlockManager.h
File metadata and controls
40 lines (31 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// HBPBlockManager.h
// Manages the pf block file and the block ledger.
//
// • addBlocksForIPs:syslogTag: — appends new IPs to the block file and
// ledger, sends a remote syslog message for each one, and returns the
// count of newly added entries.
//
// • expireOldBlocks — reads the ledger, removes entries that
// are older than config.blockHours, atomically rewrites both files, and
// returns the count of removed entries.
//
// • reloadPFTable — runs pfctl to load the updated block file
// into the live pf table.
#import <Foundation/Foundation.h>
#import "HBPConfiguration.h"
NS_ASSUME_NONNULL_BEGIN
@interface HBPBlockManager : NSObject
- (instancetype)initWithConfiguration:(HBPConfiguration *)config;
/// Append any IP in @a ips that is not already in the block file.
/// Each new block is logged to the remote syslog server.
/// @return Number of IPs newly added to the block file.
- (NSInteger)addBlocksForIPs:(NSArray<NSString *> *)ips
syslogTag:(NSString *)tag;
/// Remove ledger entries whose age exceeds config.blockHours, rewrite both
/// the ledger and block files atomically, and log each removal.
/// @return Number of blocks that were removed.
- (NSInteger)expireOldBlocks;
/// Reload the live pf table from the block file via pfctl.
- (void)reloadPFTable;
@end
NS_ASSUME_NONNULL_END