You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. Install `mmdbinspect` and add it your PATH (https://github.com/maxmind/mmdbinspect)
27
-
28
-
The following section describes the changes required to build `write-test-data` tool for the `elastic-package` needs.
29
-
30
-
### Required changes to be done in MaxMind-DB repository
31
-
32
-
Before building `write-test-data` tool, it requires to apply some changes in the code
33
-
to allow creating our own `elastic-package` databases.
34
-
35
-
These changes have been tested using the code from [this commit](https://github.com/maxmind/MaxMind-DB/commit/0ec71808b19669e9e1bf5e63a8c83b202d9bd115).
36
-
37
-
Changes to be applied:
38
-
-`pkg/writer/geoip2.go`:
39
-
- Include usage of reserved networks to allow adding documentation ranges:
40
-
```diff
41
-
--- pkg/writer/geoip2.go
42
-
+++ pkg/writer/geoip2.go
43
-
@@ -47,12 +35,13 @@ func (w *Writer) WriteGeoIP2TestDB() error {
44
-
45
-
dbWriter, err := mmdbwriter.New(
46
-
mmdbwriter.Options{
47
-
- DatabaseType: dbType,
48
-
- Description: description,
49
-
- DisableIPv4Aliasing: false,
50
-
- IPVersion: 6,
51
-
- Languages: languages,
52
-
- RecordSize: 28,
53
-
+ DatabaseType: dbType,
54
-
+ Description: description,
55
-
+ DisableIPv4Aliasing: false,
56
-
+ IPVersion: 6,
57
-
+ Languages: languages,
58
-
+ RecordSize: 28,
59
-
+ IncludeReservedNetworks: true,
60
-
},
61
-
)
62
-
if err != nil {
63
-
```
64
-
- Just create GeoLite2 databases:
65
-
```diff
66
-
--- pkg/writer/geoip2.go
67
-
+++ pkg/writer/geoip2.go
68
-
@@ -16,18 +16,6 @@ import (
69
-
// WriteGeoIP2TestDB writes GeoIP2 test mmdb files.
70
-
func (w *Writer) WriteGeoIP2TestDB() error {
71
-
dbTypes := []string{
72
-
- "GeoIP2-Anonymous-IP",
73
-
- "GeoIP2-City",
74
-
- "GeoIP2-Connection-Type",
75
-
- "GeoIP2-Country",
76
-
- "GeoIP2-DensityIncome",
77
-
- "GeoIP2-Domain",
78
-
- "GeoIP2-Enterprise",
79
-
- "GeoIP2-IP-Risk",
80
-
- "GeoIP2-ISP",
81
-
- "GeoIP2-Precision-Enterprise",
82
-
- "GeoIP2-Static-IP-Score",
83
-
- "GeoIP2-User-Count",
84
-
"GeoLite2-ASN",
85
-
"GeoLite2-City",
86
-
"GeoLite2-Country",
87
-
```
88
-
- `cmd/write-test-data/main.go`
89
-
- Just trigger the creation of GeoLite2 databases:
90
-
```diff
91
-
--- cmd/write-test-data/main.go
92
-
+++ cmd/write-test-data/main.go
93
-
@@ -21,46 +21,6 @@ func main() {
94
-
os.Exit(1)
95
-
}
96
-
97
-
- if err := w.WriteIPv4TestDB(); err != nil {
98
-
- fmt.Printf("writing IPv4 test databases: %+v\n", err)
99
-
- os.Exit(1)
100
-
- }
101
-
-
102
-
- if err := w.WriteIPv6TestDB(); err != nil {
103
-
- fmt.Printf("writing IPv6 test databases: %+v\n", err)
104
-
- os.Exit(1)
105
-
- }
106
-
-
107
-
- if err := w.WriteMixedIPTestDB(); err != nil {
108
-
- fmt.Printf("writing IPv6 test databases: %+v\n", err)
109
-
- os.Exit(1)
110
-
- }
111
-
-
112
-
- if err := w.WriteNoIPv4TestDB(); err != nil {
113
-
- fmt.Printf("writing no IPv4 test databases: %+v\n", err)
114
-
- os.Exit(1)
115
-
- }
116
-
-
117
-
- if err := w.WriteNoMapTestDB(); err != nil {
118
-
- fmt.Printf("writing no map test databases: %+v\n", err)
119
-
- os.Exit(1)
120
-
- }
121
-
-
122
-
- if err := w.WriteMetadataPointersTestDB(); err != nil {
123
-
- fmt.Printf("writing metadata pointers test databases: %+v\n", err)
124
-
- os.Exit(1)
125
-
- }
126
-
-
127
-
- if err := w.WriteDecoderTestDB(); err != nil {
128
-
- fmt.Printf("writing decoder test databases: %+v\n", err)
129
-
- os.Exit(1)
130
-
- }
131
-
-
132
-
- if err := w.WriteDeeplyNestedStructuresTestDB(); err != nil {
133
-
- fmt.Printf("writing decoder test databases: %+v\n", err)
134
-
- os.Exit(1)
135
-
- }
136
-
-
137
-
if err := w.WriteGeoIP2TestDB(); err != nil {
138
-
fmt.Printf("writing GeoIP2 test databases: %+v\n", err)
139
-
os.Exit(1)
140
-
```
141
-
142
-
Once applied all these changes, you can build the `write-test-data` tool:
As mentioned above, `elastic-package` requires to add new entries to add data for the
182
-
documentation ranges.
183
-
184
-
If any other changes are required in the GeoIP databases used by elastic-package, those JSON files located at `internal/stack/_static/geoip_sources`
185
-
can be updated and then new `mmdb` files be generated:
39
+
If any other changes are required in the GeoIP databases used by elastic-package, update the JSON files located at `internal/stack/_static/geoip_sources`
40
+
and then generate new `mmdb` files:
186
41
```shell
187
42
cd path/to/repo/elastic-package
188
-
cd internal/stack/_static
189
-
190
-
# 1. Add the required data into the JSON files in `geoip_sources`
191
-
# 2. Generate mmdb databases with the tool built previously
0 commit comments