indexer

package
v0.0.0-...-a82d748 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Copyright 2020 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.

Copyright 2020 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.

Copyright 2020 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.

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.

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.

Copyright 2020 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.

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.

Copyright 2020 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 Copyright 2020 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.

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.

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.

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.

Index

Constants

View Source
const (
	ACTFILE  ActionCapability = 1 << iota // needs local file
	ACTHTTP                               // capable of HTTP
	ACTHTTPS                              // capable of HTTPS
	ACTHEAD                               // can deal with file head

	ACTWEB      = ACTHTTPS | ACTHTTP
	ACTALLPROTO = ACTFILE | ACTHTTP | ACTHTTPS
	ACTALL      = ACTALLPROTO | ACTHEAD
	ACTFILEHEAD = ACTFILE | ACTHEAD
	ACTFILEFULL = ACTFILE & ^ACTHEAD
)
View Source
const NSRL_File = "SHA-1-"
View Source
const NSRL_MFG = "MFgCode-"
View Source
const NSRL_OS = "OpSystemCode-"
View Source
const NSRL_PROD = "ProductCode-"

Variables

View Source
var ACTAction map[string]ActionCapability = map[string]ActionCapability{
	"ACTFILE":  ACTFILE,
	"ACTHTTP":  ACTHTTP,
	"ACTHTTPS": ACTHTTPS,
	"ACTHEAD":  ACTHEAD,
}
View Source
var ACTString map[ActionCapability]string = map[ActionCapability]string{
	ACTFILE:  "ACTFILE",
	ACTHTTP:  "ACTHTTP",
	ACTHTTPS: "ACTHTTPS",
	ACTHEAD:  "ACTHEAD",
}
View Source
var EACTAction map[string]ExternalActionCalltype = map[string]ExternalActionCalltype{
	"EACTURL":      EACTURL,
	"EACTJSONPOST": EACTJSONPOST,
}
View Source
var EACTString map[ExternalActionCalltype]string = map[ExternalActionCalltype]string{
	EACTURL:      "EACTURL",
	EACTJSONPOST: "EACTJSONPOST",
}
View Source
var ErrMimeNotApplicable = errors.New("mime type not applicable for action")

Functions

func ClearMime

func ClearMime(mimetype string) string

func CreateLogger

func CreateLogger(module string, logfile string, loglevel string) (log *logging.Logger, lf *os.File)

func FileExists

func FileExists(filename string) bool

func Max

func Max(a, b int64) int64

Types

type Action

type Action interface {
	Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)
	GetName() string
	GetCaps() ActionCapability
}

func NewActionExternal

func NewActionExternal(
	name, address string,
	capability ActionCapability,
	callType ExternalActionCalltype,
	mimetype string,
	server *Server) Action

func NewActionFFProbe

func NewActionFFProbe(ffprobe string, wsl bool, timeout time.Duration, online bool, mime []FFMPEGMime, server *Server) Action

func NewActionIdentify

func NewActionIdentify(identify, convert string, wsl bool, timeout time.Duration, online bool, server *Server) Action

func NewActionNSRL

func NewActionNSRL(nsrldb *badger.DB, server *Server) Action

func NewActionSiegfried

func NewActionSiegfried(signatureFile string, mimeMap map[string]string, server *Server) Action

func NewActionTika

func NewActionTika(uri string, timeout time.Duration, regexpMime string, online bool, server *Server) Action

type ActionCapability

type ActionCapability uint

func (*ActionCapability) UnmarshalText

func (a *ActionCapability) UnmarshalText(text []byte) error

for toml decoding

type ActionExternal

type ActionExternal struct {
	// contains filtered or unexported fields
}

func (*ActionExternal) Do

func (as *ActionExternal) Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)

func (*ActionExternal) GetCaps

func (as *ActionExternal) GetCaps() ActionCapability

func (*ActionExternal) GetName

func (as *ActionExternal) GetName() string

type ActionFFProbe

type ActionFFProbe struct {
	// contains filtered or unexported fields
}

func (*ActionFFProbe) Do

func (as *ActionFFProbe) Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)

func (*ActionFFProbe) GetCaps

func (as *ActionFFProbe) GetCaps() ActionCapability

func (*ActionFFProbe) GetName

func (as *ActionFFProbe) GetName() string

type ActionIdentify

type ActionIdentify struct {
	// contains filtered or unexported fields
}

func (*ActionIdentify) Do

func (ai *ActionIdentify) Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)

func (*ActionIdentify) GetCaps

func (ai *ActionIdentify) GetCaps() ActionCapability

func (*ActionIdentify) GetName

func (ai *ActionIdentify) GetName() string

type ActionNSRL

type ActionNSRL struct {
	// contains filtered or unexported fields
}

func (*ActionNSRL) Do

func (aNSRL *ActionNSRL) Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)

func (*ActionNSRL) GetCaps

func (aNSRL *ActionNSRL) GetCaps() ActionCapability

func (*ActionNSRL) GetName

func (aNSRL *ActionNSRL) GetName() string

type ActionNSRLMeta

type ActionNSRLMeta struct {
	File    map[string]string
	FileMfG map[string]string
	OS      map[string]string
	OSMfg   map[string]string
	Prod    map[string]string
	ProdMfg map[string]string
}

type ActionParam

type ActionParam struct {
	Url           string            `json:"url"`
	Actions       []string          `json:"actions,omitempty"`
	ForceDownload string            `json:"forcedownload,omitempty"`
	HeaderSize    int64             `json:"headersize,omitempty"`
	Checksums     map[string]string `json:"checksums,omitempty"`
}

type ActionSiegfried

type ActionSiegfried struct {
	// contains filtered or unexported fields
}

func (*ActionSiegfried) Do

func (as *ActionSiegfried) Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)

func (*ActionSiegfried) GetCaps

func (as *ActionSiegfried) GetCaps() ActionCapability

func (*ActionSiegfried) GetName

func (as *ActionSiegfried) GetName() string

type ActionTika

type ActionTika struct {
	// contains filtered or unexported fields
}

func (*ActionTika) Do

func (at *ActionTika) Do(uri *url.URL, mimetype *string, width *uint, height *uint, duration *time.Duration, checksums map[string]string) (interface{}, error)

func (*ActionTika) GetCaps

func (at *ActionTika) GetCaps() ActionCapability

func (*ActionTika) GetName

func (at *ActionTika) GetName() string

type ExternalActionCalltype

type ExternalActionCalltype uint
const (
	EACTURL      ExternalActionCalltype = 1 << iota // url with placehoder for full path
	EACTJSONPOST                                    // send json struct via post
)

func (*ExternalActionCalltype) UnmarshalText

func (a *ExternalActionCalltype) UnmarshalText(text []byte) error

for toml decoding

type FFMPEGMime

type FFMPEGMime struct {
	Video  bool
	Audio  bool
	Format string
	Mime   string
}

type FileMapper

type FileMapper struct {
	// contains filtered or unexported fields
}

func NewFileMapper

func NewFileMapper(mapping map[string]string) *FileMapper

func (*FileMapper) Get

func (fm *FileMapper) Get(uri *url.URL) (string, error)

type MimeWeight

type MimeWeight struct {
	// contains filtered or unexported fields
}

type MimeWeightString

type MimeWeightString struct {
	Regexp string
	Weight int
}

type SFTP

type SFTP struct {
	// contains filtered or unexported fields
}

func NewSFTP

func NewSFTP(PrivateKey []string, Password, KnownHosts string, log *logging.Logger) (*SFTP, error)

func (*SFTP) Get

func (s *SFTP) Get(uri url.URL, w io.Writer) (int64, error)

func (*SFTP) GetConnection

func (s *SFTP) GetConnection(address, user string) (*SSHConnection, error)

func (*SFTP) GetFile

func (s *SFTP) GetFile(uri url.URL, user string, target string) (int64, error)

func (*SFTP) Put

func (s *SFTP) Put(uri url.URL, user string, r io.Reader) (int64, error)

func (*SFTP) PutFile

func (s *SFTP) PutFile(uri url.URL, user string, source string) (int64, error)

type SSHConnection

type SSHConnection struct {
	// contains filtered or unexported fields
}

func NewSSHConnection

func NewSSHConnection(address, user string, config *ssh.ClientConfig, log *logging.Logger) (*SSHConnection, error)

func (*SSHConnection) Close

func (sc *SSHConnection) Close()

func (*SSHConnection) Connect

func (sc *SSHConnection) Connect() error

func (*SSHConnection) GetSFTPClient

func (sc *SSHConnection) GetSFTPClient() (*sftp.Client, error)

func (*SSHConnection) ReadFile

func (sc *SSHConnection) ReadFile(path string, w io.Writer) (int64, error)

func (*SSHConnection) WriteFile

func (sc *SSHConnection) WriteFile(path string, r io.Reader) (int64, error)

type SSHConnectionPool

type SSHConnectionPool struct {
	// contains filtered or unexported fields
}

func NewSSHConnectionPool

func NewSSHConnectionPool(log *logging.Logger) *SSHConnectionPool

func (*SSHConnectionPool) GetConnection

func (cp *SSHConnectionPool) GetConnection(address, user string, config *ssh.ClientConfig) (*SSHConnection, error)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	headerTimeout time.Duration,
	headerSize int64,
	downloadMime string,
	maxDownloadSize int64,
	mimeRelevance map[int]MimeWeightString,
	jwtSecret string,
	jwtAlg []string,
	insecureCert bool,
	log *logging.Logger,
	accesslog io.Writer,
	errorTemplate string,
	tempDir string,
	fm *FileMapper,
	sftp *SFTP,
) (*Server, error)

func (*Server) AddAction

func (s *Server) AddAction(a Action)

func (*Server) DoPanic

func (s *Server) DoPanic(writer http.ResponseWriter, status int, message string) (err error)

func (*Server) DoPanicf

func (s *Server) DoPanicf(writer http.ResponseWriter, status int, message string, a ...interface{}) (err error)

func (*Server) HandleDefault

func (s *Server) HandleDefault(w http.ResponseWriter, r *http.Request)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr, cert, key string) error

func (*Server) MimeRelevance

func (s *Server) MimeRelevance(mimetype string) (relevance int)

holistic function to give some mimetypes a relevance

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL