/
config.go
267 lines (248 loc) · 5.49 KB
/
config.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// Copyright 2021 Juergen Enge, info-age GmbH, Basel. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package indexer
import (
"github.com/je4/utils/v2/pkg/checksum"
"time"
)
type duration struct {
Duration time.Duration
}
func (d *duration) UnmarshalText(text []byte) error {
var err error
d.Duration, err = time.ParseDuration(string(text))
return err
}
type ConfigClamAV struct {
Enabled bool
Timeout duration
ClamScan string
Wsl bool
}
type ConfigSiegfried struct {
//Address string
Enabled bool
SignatureFile string `toml:"signature"`
MimeMap map[string]string
}
type ConfigTika struct {
AddressMeta string
AddressFulltext string
Timeout duration
RegexpMimeFulltext string
RegexpMimeFulltextNot string
RegexpMimeMeta string
RegexpMimeMetaNot string
Online bool
Enabled bool
}
type FFMPEGMime struct {
Video bool
Audio bool
Format string
Mime string
}
type ConfigFFMPEG struct {
FFProbe string
Wsl bool
Timeout duration
Online bool
Enabled bool
Mime []FFMPEGMime
}
type ConfigChecksum struct {
Name string
Digest []checksum.DigestAlgorithm
Enabled bool
}
type ConfigImageMagick struct {
Identify string
Convert string
Wsl bool
Timeout duration
Online bool
Enabled bool
}
type ConfigXMLFormat struct {
Regexp bool
Attributes map[string]string
Pronom string
Mime string
Type string
Subtype string
}
type ConfigXML struct {
Enabled bool
Format map[string]ConfigXMLFormat
}
type ConfigExternalAction struct {
Name,
Address,
Mimetype string
ActionCapabilities []ActionCapability
CallType ExternalActionCalltype
}
type ConfigFileMap struct {
Alias string
Folder string
}
type ConfigSFTP struct {
Knownhosts string
Password string
PrivateKey []string
}
type ConfigNSRL struct {
Enabled bool
Badger string
}
type ConfigMimeWeight struct {
Regexp string
Weight int
}
type IndexerConfig struct {
Enabled bool
LocalCache bool
TempDir string
HeaderTimeout duration
HeaderSize int64
DownloadMime string `toml:"forcedownload"`
MaxDownloadSize int64
Siegfried ConfigSiegfried
Checksum ConfigChecksum
FFMPEG ConfigFFMPEG
ImageMagick ConfigImageMagick
Tika ConfigTika
XML ConfigXML
External []ConfigExternalAction
FileMap []ConfigFileMap
URLRegexp []string
NSRL ConfigNSRL
Clamav ConfigClamAV
MimeRelevance map[string]ConfigMimeWeight
}
func GetDefaultConfig() *IndexerConfig {
var conf = &IndexerConfig{
Enabled: true,
LocalCache: false,
TempDir: "",
Siegfried: ConfigSiegfried{
Enabled: true,
SignatureFile: "internal:/siegfried/default.sig",
MimeMap: map[string]string{
"x-fmt/92": "image/psd",
"fmt/134": "audio/mp3",
"x-fmt/184": "image/x-sun-raster",
"fmt/202": "image/x-nikon-nef",
"fmt/211": "image/x-photo-cd",
"x-fmt/383": "image/fits",
"fmt/405": "image/x-portable-anymap",
"fmt/406": "image/x-portable-graymap",
"fmt/408": "image/x-portable-pixmap",
"fmt/436": "image/x-adobe-dng",
"fmt/437": "image/x-adobe-dng",
"fmt/592": "image/x-canon-cr2",
"fmt/642": "image/x-raw-fuji",
"fmt/662": "image/x-raw-panasonic",
"fmt/668": "image/x-olympus-orf",
"fmt/986": "text/xmp",
"fmt/1001": "image/x-exr",
"fmt/1040": "image/vnd.ms-dds",
"fmt/1781": "image/x-pentax-pef",
},
},
Checksum: ConfigChecksum{
Enabled: true,
Name: "checksum",
Digest: []checksum.DigestAlgorithm{
"sha512",
},
},
FFMPEG: ConfigFFMPEG{
Mime: []FFMPEGMime{
{
Video: false,
Audio: true,
Format: "mov,mp4,m4a,3gp,3g2,mj2",
Mime: "audio/mp4",
},
{
Video: true,
Audio: true,
Format: "mov,mp4,m4a,3gp,3g2,mj2",
Mime: "video/mp4",
},
{
Video: true,
Audio: false,
Format: "mov,mp4,m4a,3gp,3g2,mj2",
Mime: "video/mp4",
},
},
},
ImageMagick: ConfigImageMagick{},
Tika: ConfigTika{},
External: []ConfigExternalAction{},
FileMap: []ConfigFileMap{},
URLRegexp: []string{},
NSRL: ConfigNSRL{},
Clamav: ConfigClamAV{},
MimeRelevance: map[string]ConfigMimeWeight{
"1": {
Regexp: "^application/octet-stream",
Weight: 1,
},
"2": {
Regexp: "^text/plain",
Weight: 3,
},
"3": {
Regexp: "^audio/mpeg",
Weight: 6,
},
"4": {
Regexp: "^video/mpeg",
Weight: 5,
},
"5": {
Regexp: "^application/vnd\\..+",
Weight: 4,
},
"6": {
Regexp: "^application/rtf",
Weight: 4,
},
"7": {
Regexp: "^application/.+",
Weight: 2,
},
"8": {
Regexp: "^text/.+",
Weight: 4,
},
"9": {
Regexp: "^audio/.+",
Weight: 5,
},
"10": {
Regexp: "^video/.+",
Weight: 4,
},
"11": {
Regexp: "^.+/x-.+",
Weight: 80,
},
},
}
return conf
}