Skip to content

Commit 74556b5

Browse files
authored
Merge pull request #38 from firehol/repo-layout-readme-src-packaging
Refresh README and thin the repository root
2 parents e6dc510 + 56d5ef1 commit 74556b5

44 files changed

Lines changed: 378 additions & 115 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
.libs
33

44
*.o
5+
*.plist
56
*.in
7+
!packaging/iprange.spec.in
68
*~
79
*.1
810

@@ -25,6 +27,7 @@ stamp-h1
2527

2628
iprange
2729
iprange.spec
30+
packaging/iprange.spec
2831

2932
*.tar.gz
3033
*.tar.bz2

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ find_package (Threads)
66
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat-signedness -Werror=format-security")
77

88
set(SOURCE_FILES
9-
config.h
10-
iprange.c ipset.c ipset.h iprange.h ipset_binary.c ipset_binary.h ipset_load.c ipset_load.h ipset_reduce.c ipset_print.c ipset_print.h ipset_optimize.c ipset_optimize.h ipset_reduce.h ipset_diff.c ipset_diff.h ipset_common.c ipset_common.h ipset_exclude.c ipset_exclude.h ipset_merge.c ipset_merge.h ipset_copy.c ipset_copy.h ipset_combine.c ipset_combine.h)
9+
src/iprange.c src/ipset.c src/ipset.h src/iprange.h src/ipset_binary.c src/ipset_binary.h src/ipset_load.c src/ipset_load.h src/ipset_reduce.c src/ipset_print.c src/ipset_print.h src/ipset_optimize.c src/ipset_optimize.h src/ipset_reduce.h src/ipset_diff.c src/ipset_diff.h src/ipset_common.c src/ipset_common.h src/ipset_exclude.c src/ipset_exclude.h src/ipset_merge.c src/ipset_merge.h src/ipset_copy.c src/ipset_copy.h src/ipset_combine.c src/ipset_combine.h)
1110

12-
include_directories(AFTER .)
11+
include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src)
1312
add_definitions("-DHAVE_CONFIG_H")
1413

15-
add_executable(iprange_git ${SOURCE_FILES})
14+
add_executable(iprange_git ${SOURCE_FILES})

Makefile.am

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#
22
# Copyright (C) 2015 Alon Bar-Lev <alon.barlev@gmail.com>
33
#
4-
AUTOMAKE_OPTIONS=foreign dist-xz dist-bzip2 1.10
4+
AUTOMAKE_OPTIONS=foreign dist-xz dist-bzip2 1.10 subdir-objects
55
ACLOCAL_AMFLAGS = -I m4
6+
AM_CPPFLAGS = -I$(srcdir)/src
67

78
MAINTAINERCLEANFILES= \
89
config.log config.status \
@@ -23,55 +24,55 @@ AM_H2MFLAGS = \
2324
iprange_DESCRIPTION = "manage IP ranges"
2425

2526
bin_PROGRAMS = iprange
26-
dist_noinst_DATA = iprange.spec
27+
dist_noinst_DATA = packaging/iprange.spec
2728

2829
if ENABLE_MAN
2930
man_MANS = iprange.1
3031
endif
3132

3233
iprange_SOURCES = \
33-
iprange.c \
34-
iprange.h \
35-
ipset.c \
36-
ipset.h \
37-
ipset_binary.c \
38-
ipset_binary.h \
39-
ipset_combine.c \
40-
ipset_combine.h \
41-
ipset_common.c \
42-
ipset_common.h \
43-
ipset_copy.c \
44-
ipset_copy.h \
45-
ipset_diff.c \
46-
ipset_diff.h \
47-
ipset_exclude.c \
48-
ipset_exclude.h \
49-
ipset_load.c \
50-
ipset_load.h \
51-
ipset_merge.c \
52-
ipset_merge.h \
53-
ipset_optimize.c \
54-
ipset_optimize.h \
55-
ipset_print.c \
56-
ipset_print.h \
57-
ipset_reduce.c \
58-
ipset_reduce.h \
34+
src/iprange.c \
35+
src/iprange.h \
36+
src/ipset.c \
37+
src/ipset.h \
38+
src/ipset_binary.c \
39+
src/ipset_binary.h \
40+
src/ipset_combine.c \
41+
src/ipset_combine.h \
42+
src/ipset_common.c \
43+
src/ipset_common.h \
44+
src/ipset_copy.c \
45+
src/ipset_copy.h \
46+
src/ipset_diff.c \
47+
src/ipset_diff.h \
48+
src/ipset_exclude.c \
49+
src/ipset_exclude.h \
50+
src/ipset_load.c \
51+
src/ipset_load.h \
52+
src/ipset_merge.c \
53+
src/ipset_merge.h \
54+
src/ipset_optimize.c \
55+
src/ipset_optimize.h \
56+
src/ipset_print.c \
57+
src/ipset_print.h \
58+
src/ipset_reduce.c \
59+
src/ipset_reduce.h \
5960
$(NULL)
6061

6162
VPATH_LOCAL_OBJECTS = \
62-
iprange.$(OBJEXT) \
63-
ipset.$(OBJEXT) \
64-
ipset_binary.$(OBJEXT) \
65-
ipset_combine.$(OBJEXT) \
66-
ipset_common.$(OBJEXT) \
67-
ipset_copy.$(OBJEXT) \
68-
ipset_diff.$(OBJEXT) \
69-
ipset_exclude.$(OBJEXT) \
70-
ipset_load.$(OBJEXT) \
71-
ipset_merge.$(OBJEXT) \
72-
ipset_optimize.$(OBJEXT) \
73-
ipset_print.$(OBJEXT) \
74-
ipset_reduce.$(OBJEXT)
63+
src/iprange.$(OBJEXT) \
64+
src/ipset.$(OBJEXT) \
65+
src/ipset_binary.$(OBJEXT) \
66+
src/ipset_combine.$(OBJEXT) \
67+
src/ipset_common.$(OBJEXT) \
68+
src/ipset_copy.$(OBJEXT) \
69+
src/ipset_diff.$(OBJEXT) \
70+
src/ipset_exclude.$(OBJEXT) \
71+
src/ipset_load.$(OBJEXT) \
72+
src/ipset_merge.$(OBJEXT) \
73+
src/ipset_optimize.$(OBJEXT) \
74+
src/ipset_print.$(OBJEXT) \
75+
src/ipset_reduce.$(OBJEXT)
7576

7677
LOCAL_OBJECT_STAMP = local-build-objects.stamp
7778
BUILT_SOURCES = $(LOCAL_OBJECT_STAMP)
@@ -90,7 +91,8 @@ $(VPATH_LOCAL_OBJECTS): $(LOCAL_OBJECT_STAMP)
9091
EXTRA_DIST = \
9192
.gitignore \
9293
README.md \
93-
iprange-9999.ebuild \
94+
packaging/iprange.spec.in \
95+
packaging/iprange-9999.ebuild \
9496
autogen.sh \
9597
run-tests.sh \
9698
run-build-tests.sh \

README.md

Lines changed: 155 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,165 @@
1-
iprange - manage IP ranges
2-
==========================
1+
# iprange
32

4-
Getting help
5-
------------
3+
`iprange` is a fast command-line tool for reading, normalizing, comparing, and exporting IPv4 address sets.
64

7-
~~~~
8-
iprange --help 2>&1 | more
9-
~~~~
5+
It understands single IPs, CIDRs, netmasks, numeric IPs, ranges, and hostnames. You can use it to merge blocklists, compute intersections or exclusions, generate data for `ipset restore`, or compare multiple IP sets as CSV.
106

11-
Installation from tar-file
12-
--------------------------
7+
## What it can read
138

14-
~~~~
15-
./configure && make && make install
16-
~~~~
9+
`iprange` accepts one entry per line and can mix formats in the same input:
1710

11+
- single IPs
12+
- `1.2.3.4`
13+
- CIDRs
14+
- `1.2.3.0/24`
15+
- dotted netmasks
16+
- `1.2.3.0/255.255.255.0`
17+
- abbreviated IPs
18+
- `10.1`
19+
- `10.1.1`
20+
- IP ranges
21+
- `1.2.3.0 - 1.2.3.255`
22+
- ranges where both sides use CIDR or netmask notation
23+
- numeric IPs
24+
- hostnames
1825

19-
Installation from git
20-
---------------------
26+
Important input behavior:
2127

22-
~~~~
28+
- Hostnames are resolved in parallel.
29+
- Comments after `#` or `;` are ignored.
30+
- Parsing uses `inet_aton()`, so octal and hex forms are accepted too.
31+
- Inputs can come from `stdin`, files, file lists, or directory expansion.
32+
33+
## Main modes
34+
35+
- `union` / `merge` / `optimize`
36+
- merge all inputs and print the normalized result
37+
- `common`
38+
- print the intersection of all inputs
39+
- `exclude-next`
40+
- merge the inputs before the option, then remove anything matched by the inputs after it
41+
- `ipset-reduce`
42+
- trade a controlled increase in entries for fewer prefixes
43+
- `compare`
44+
- compare all inputs against all other inputs and print CSV
45+
- `compare-first`
46+
- compare the first input against every other input
47+
- `compare-next`
48+
- compare one group of inputs against the next group
49+
- `count-unique`
50+
- merge all inputs and print CSV counts
51+
- `count-unique-all`
52+
- print one CSV count line per input
53+
54+
## Quick examples
55+
56+
Merge and normalize:
57+
58+
```bash
59+
iprange blocklist-a.txt blocklist-b.txt
60+
```
61+
62+
Find common IPs:
63+
64+
```bash
65+
iprange --common blocklist-a.txt blocklist-b.txt
66+
```
67+
68+
Exclude one set from another:
69+
70+
```bash
71+
iprange allow.txt --exclude-next deny.txt
72+
```
73+
74+
Count unique entries:
75+
76+
```bash
77+
iprange -C blocklist-a.txt blocklist-b.txt
78+
iprange --count-unique-all --header blocklist-a.txt blocklist-b.txt
79+
```
80+
81+
Generate single-IP output:
82+
83+
```bash
84+
iprange -1 hosts.txt
85+
```
86+
87+
Generate binary output for fast round-trips on the same architecture:
88+
89+
```bash
90+
iprange --print-binary blocklist.txt > blocklist.bin
91+
iprange blocklist.bin
92+
```
93+
94+
Generate `ipset restore`-style lines:
95+
96+
```bash
97+
iprange --print-prefix 'add myset ' --print-suffix '' blocklist.txt
98+
```
99+
100+
## Build and install
101+
102+
From a release tarball:
103+
104+
```bash
105+
./configure
106+
make
107+
make install
108+
```
109+
110+
From git:
111+
112+
```bash
23113
./autogen.sh
24-
./configure && make && make install
25-
~~~~
114+
./configure
115+
make
116+
make install
117+
```
118+
119+
If you do not want to build the man page:
120+
121+
```bash
122+
./configure --disable-man
123+
```
124+
125+
## Testing
126+
127+
Project test entry points:
128+
129+
- `./run-tests.sh`
130+
- CLI regression suite
131+
- `./run-build-tests.sh`
132+
- build and layout regressions
133+
- `./run-sanitizer-tests.sh`
134+
- ASAN/UBSAN/TSAN coverage
135+
- `make check`
136+
- normal build-integrated test path
137+
- `make check-sanitizers`
138+
- sanitizer-integrated test path
139+
140+
## Repository layout
141+
142+
- `src/`
143+
- C sources and headers
144+
- `packaging/`
145+
- packaging helpers, spec template, ebuild, and release tooling
146+
- `tests.d/`
147+
- CLI regression tests
148+
- `tests.build.d/`
149+
- build and layout regressions
150+
- `tests.sanitizers.d/`
151+
- sanitizer CLI regressions
152+
- `tests.tsan.d/`
153+
- TSAN regressions
154+
- `tests.unit/`
155+
- unit-style harnesses for internal edge cases
156+
157+
## Getting help
158+
159+
For the full option list:
26160

27-
When working with git, copy the hooks to the cloned folder:
161+
```bash
162+
iprange --help
163+
```
28164

29-
~~~~
30-
cp hooks/* .git/hooks
31-
~~~~
165+
The project wiki content that originally documented the feature set is now folded into this README so the repository landing page explains the tool directly.

0 commit comments

Comments
 (0)