utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(data []byte) string

BytesToString return string

func CheckExist

func CheckExist(db *sql.DB, debug bool, verbose bool, hash string) (bool, error)

CheckExist : comprobar si el Possible esta en la otra lista

func ConnectDb

func ConnectDb(cfgFile string, debug bool, verbose bool) (*sql.DB, error)

ConnectDb : conect database and return *sql.DB

func CreateDb

func CreateDb(cfgFile string, database string, debug bool, verbose bool) error

CreateDb : Create database hash

func DeleteAlert

func DeleteAlert(db *sql.DB, debug bool, verbose bool, ip string) error

DeleteAlert from the database

func DeleteMonitor

func DeleteMonitor(db *sql.DB, debug bool, verbose bool, hash string) error

DeleteMonitor from the database

func DeletePossibles

func DeletePossibles(db *sql.DB, debug bool, verbose bool)

DeletePossibles table

func DeletePossiblesFalse

func DeletePossiblesFalse(db *sql.DB, debug bool, verbose bool)

DeletePossiblesFalse where possible=false

func DeleteProject

func DeleteProject(db *sql.DB, debug bool, verbose bool, name string) error

DeleteProject from the database

func DownloadPossibles

func DownloadPossibles(db *sql.DB, timeout int, debug bool, verbose bool, projectName string) error

DownloadPossibles Get and download (torrentLib) from possibles where possible true

func DownloadValid

func DownloadValid(db *sql.DB, timeout int, debug bool, verbose bool, projectName string) error

DownloadValid Get and download (torrentLib) from possibles where valid = true

func ExecuteDb

func ExecuteDb(db *sql.DB, debug bool, verbose bool, sqlString string) error

ExecuteDb execeute a SQL query. Dangerous

func GetHash

func GetHash(db *sql.DB, debug bool, verbose bool, i int) (string, error)

GetHash from ID

func GetHashes

func GetHashes(db *sql.DB, debug bool, verbose bool) ([][]byte, error)

GetHashes from database

func GetMonitor

func GetMonitor(db *sql.DB, debug bool, verbose bool, projectName string) ([]string, error)

GetMonitor from the database

func GetPossibles

func GetPossibles(db *sql.DB, debug bool, verbose bool) (int, error)

GetPossibles from DB possibles table

func InitDB

func InitDB(db *sql.DB, debug bool, verbose bool) error

InitDB : init Database

func InsertAlert

func InsertAlert(db *sql.DB, debug bool, verbose bool, ip string, list string, username string, projectName string) error

InsertAlert to the database

func InsertDownload

func InsertDownload(db *sql.DB, debug bool, verbose bool, ip string, port int, hash string, projectName string) error

InsertDownload to the database

func InsertFile

func InsertFile(db *sql.DB, debug bool, verbose bool, filePath string) error

InsertFile to the database

func InsertHash

func InsertHash(db *sql.DB, debug bool, verbose bool, hash string, source string) error

InsertHash to the database

func InsertHashList

func InsertHashList(db *sql.DB, debug bool, verbose bool, hashes []string, source string) error

InsertHashList to the database

func InsertIP

func InsertIP(db *sql.DB, debug bool, verbose bool, ip string, projectName string) error

InsertIP inserts a IP or range in the database db with the proyectName

func InsertMonitor

func InsertMonitor(db *sql.DB, debug bool, verbose bool, hash string, username string, projectName string) error

InsertMonitor inserts a hash in teh database for monitor in daemon mode.

func InsertPossible

func InsertPossible(db *sql.DB, debug bool, verbose bool, num int, hash string, valid bool, projectName string) error

InsertPossible in possibles table

func InsertProject

func InsertProject(db *sql.DB, debug bool, verbose bool, projectName string) error

InsertProject to the database

func MonitorAlert

func MonitorAlert(configfile string, debug bool, verbose bool, projectName string)

MonitorAlert create a listener for the PostgreSQL database for alerts and print them.

func QueryAlert

func QueryAlert(db *sql.DB, debug bool, verbose bool, sql string, ip string, user string) (string, error)

QueryAlert from the database

func QueryCount

func QueryCount(db *sql.DB, debug bool, verbose bool) (string, error)

QueryCount from the database hash table

func QueryHash

func QueryHash(db *sql.DB, debug bool, verbose bool, sqlQuery string, hash string, source string) (string, error)

QueryHash from database

func QueryIP

func QueryIP(db *sql.DB, debug bool, verbose bool, sql string, ip string) (string, error)

QueryIP SELECT from the database ip table

func QueryMonitor

func QueryMonitor(db *sql.DB, debug bool, verbose bool, sqlQuery string, hash string, user string) (string, error)

QueryMonitor SELECT from the database monitor table

func QueryPossibles

func QueryPossibles(db *sql.DB, debug bool, verbose bool, sql string, hash string) (string, error)

QueryPossibles from the database

func QueryProjects

func QueryProjects(db *sql.DB, debug bool, verbose bool, sql string, nombre string) (string, error)

QueryProjects from the database projects table

func RandomID

func RandomID() []byte

RandomID to DHT

func SelectPossiblesWhere

func SelectPossiblesWhere(columnTrue string, db *sql.DB, debug bool, verbose bool, projectName string) error

SelectPossiblesWhere columnTrue=True from the database. Possibles values: download, valid and possible

func SetLen

func SetLen(db *sql.DB, debug bool, verbose bool, num int, hash string) error

SetLen to a hash in possibles table

func SetNamePossibles

func SetNamePossibles(db *sql.DB, debug bool, verbose bool, name string, hash string) error

SetNamePossibles in possibles table

func SetTrueDownload

func SetTrueDownload(db *sql.DB, debug bool, verbose bool, hash string) error

SetTrueDownload a hash from possibles table

func SetTruePossible

func SetTruePossible(db *sql.DB, debug bool, verbose bool, hash string) error

SetTruePossible a hash from possibles table

func SetTrueValid

func SetTrueValid(db *sql.DB, debug bool, verbose bool, hash string) error

SetTrueValid in possibles table

Types

type Config

type Config struct {
	Host     string
	Port     int
	User     string
	Password string
	Dbname   string
}

Config from file for the database

func GetConfig

func GetConfig(configFile string, debug bool, verbose bool) (Config, error)

GetConfig Get the config from the configFile

type Node

type Node struct {
	Ip   string
	Port uint16
}

Node &net.TCPAddr{IP: from.IP, Port: int(port)},

func DecodeNodes

func DecodeNodes(s string) ([]*Node, error)

DecodeNodes from DHT query

func Decodepeer

func Decodepeer(s []string, hash string) ([]*Node, error)

Decodepeer from DHT query

Jump to

Keyboard shortcuts

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