From d06a49eb283fcc119de1ea7dd5c6372530ad5a95 Mon Sep 17 00:00:00 2001 From: Akilan Date: Tue, 30 May 2023 18:42:33 +0100 Subject: [PATCH] huge changes that need more doucmenting --- Blockchain Cache Global.go | 2 +- Blockchain User.go | 2 +- Bootstrap.go | 2 +- Command Traverse.go | 2 +- Commands.go | 2 +- Config.go | 2 +- Connection.go | 2 +- DHT Store.go | 2 +- Exit.go | 2 +- File Formats.go | 2 +- Filter.go | 2 +- Kademlia.go | 2 +- Message Send.go | 2 +- Network Detection.go | 2 +- Network IPv4 Broadcast.go | 2 +- Network IPv6 Multicast.go | 4 +-- Network Init.go | 2 +- Network UPnP.go | 2 +- Network.go | 2 +- Networks.go | 2 +- Peer ID.go | 2 +- Peernet.go | 4 +-- Ping.go | 2 +- Transfer Block.go | 2 +- Transfer UDT.go | 2 +- Transfer Virtual Connection.go | 2 +- Warehouse.go | 2 +- blockchain/Block Record File.go | 4 ++- blockchain/Block Record Profile.go | 2 +- blockchain/Block Record.go | 2 +- blockchain/Block.go | 2 +- blockchain/Blockchain.go | 2 +- blockchain/File Tag.go | 4 +-- blockchain/File.go | 2 +- blockchain/Multi.go | 2 +- blockchain/Profile Data.go | 2 +- blockchain/Profile.go | 2 +- blockchain/Test_test.go | 2 +- dht/DHT Lite.go | 2 +- dht/Hash Table.go | 2 +- dht/Information Request.go | 2 +- dht/Node.go | 2 +- dht/Search Client.go | 2 +- merkle/Fragment.go | 2 +- merkle/Merkle Tree.go | 2 +- protocol/Command.go | 2 +- protocol/File Transfer.go | 2 +- protocol/Hash.go | 2 +- protocol/Message Encoding Announcement.go | 2 +- protocol/Message Encoding Get Block.go | 2 +- protocol/Message Encoding Response.go | 2 +- protocol/Message Encoding Transfer.go | 2 +- protocol/Message Encoding Traverse.go | 2 +- protocol/Message Encoding.go | 2 +- protocol/Packet Encoding.go | 2 +- protocol/Packet Lite.go | 2 +- protocol/Sequence.go | 2 +- sanitize/Sanitize.go | 2 +- search/Normalize.go | 2 +- search/Search Index.go | 2 +- search/Search Term.go | 2 +- search/Text 2 Hash.go | 2 +- store/Memory.go | 2 +- store/Pebble.go | 2 +- store/Pogreb.go | 2 +- store/Store.go | 2 +- system/Execute.go | 2 +- system/Read Package.go | 2 +- upnp/UPnP.go | 2 +- warehouse/Merkle.go | 2 +- warehouse/Store.go | 2 +- warehouse/Warehouse.go | 6 ++-- webapi/API.go | 2 +- webapi/Blockchain.go | 2 +- webapi/Download Transfer.go | 2 +- webapi/Download.go | 8 ++++- webapi/File Detection.go | 2 +- webapi/File IO.go | 2 +- webapi/File.go | 43 ++++++++++++++--------- webapi/GeoIP.go | 2 +- webapi/HTTP Range.go | 2 +- webapi/Profile.go | 2 +- webapi/Search Dispatch.go | 2 +- webapi/Search Job.go | 4 +-- webapi/Search.go | 13 +++++-- webapi/Shared Recent.go | 35 ++++++++++++++++-- webapi/Status.go | 2 +- webapi/Warehouse.go | 2 +- 88 files changed, 169 insertions(+), 112 deletions(-) diff --git a/Blockchain Cache Global.go b/Blockchain Cache Global.go index 2b8926a..8eb5acc 100644 --- a/Blockchain Cache Global.go +++ b/Blockchain Cache Global.go @@ -1,5 +1,5 @@ /* -File Name: Blockchain Cache Global.go +File Username: Blockchain Cache Global.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Blockchain User.go b/Blockchain User.go index 81af81b..ae56f13 100644 --- a/Blockchain User.go +++ b/Blockchain User.go @@ -1,5 +1,5 @@ /* -File Name: Blockchain User.go +File Username: Blockchain User.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Bootstrap.go b/Bootstrap.go index 7adebd6..8e13a84 100644 --- a/Bootstrap.go +++ b/Bootstrap.go @@ -1,5 +1,5 @@ /* -File Name: Bootstrap.go +File Username: Bootstrap.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Command Traverse.go b/Command Traverse.go index afc68d7..699f055 100644 --- a/Command Traverse.go +++ b/Command Traverse.go @@ -1,5 +1,5 @@ /* -File Name: Command Traverse.go +File Username: Command Traverse.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Commands.go b/Commands.go index 6edb990..b362a73 100644 --- a/Commands.go +++ b/Commands.go @@ -1,5 +1,5 @@ /* -File Name: Commands.go +File Username: Commands.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Config.go b/Config.go index 0562196..7f7a4bb 100644 --- a/Config.go +++ b/Config.go @@ -1,5 +1,5 @@ /* -File Name: Settings.go +File Username: Settings.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Connection.go b/Connection.go index a7a41da..fd60009 100644 --- a/Connection.go +++ b/Connection.go @@ -1,5 +1,5 @@ /* -File Name: Connection.go +File Username: Connection.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/DHT Store.go b/DHT Store.go index d420772..c2c20c6 100644 --- a/DHT Store.go +++ b/DHT Store.go @@ -1,5 +1,5 @@ /* -File Name: DHT Store.go +File Username: DHT Store.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Exit.go b/Exit.go index ae59168..bd0846a 100644 --- a/Exit.go +++ b/Exit.go @@ -1,5 +1,5 @@ /* -File Name: Exit.go +File Username: Exit.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/File Formats.go b/File Formats.go index 5326aa8..2e5ba52 100644 --- a/File Formats.go +++ b/File Formats.go @@ -1,5 +1,5 @@ /* -File Name: File Formats.go +File Username: File Formats.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Filter.go b/Filter.go index 5a4cf57..93f5819 100644 --- a/Filter.go +++ b/Filter.go @@ -1,5 +1,5 @@ /* -File Name: Filter.go +File Username: Filter.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Kademlia.go b/Kademlia.go index e8a377b..e9f5b25 100644 --- a/Kademlia.go +++ b/Kademlia.go @@ -1,5 +1,5 @@ /* -File Name: Kademlia.go +File Username: Kademlia.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Message Send.go b/Message Send.go index f2e4e19..687c724 100644 --- a/Message Send.go +++ b/Message Send.go @@ -1,5 +1,5 @@ /* -File Name: Message Send.go +File Username: Message Send.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Network Detection.go b/Network Detection.go index 29f52b9..16677d8 100644 --- a/Network Detection.go +++ b/Network Detection.go @@ -1,5 +1,5 @@ /* -File Name: Network Detection.go +File Username: Network Detection.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Network IPv4 Broadcast.go b/Network IPv4 Broadcast.go index cbda142..0e7914e 100644 --- a/Network IPv4 Broadcast.go +++ b/Network IPv4 Broadcast.go @@ -1,5 +1,5 @@ /* -File Name: Network IPv4 Broadcast.go +File Username: Network IPv4 Broadcast.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Network IPv6 Multicast.go b/Network IPv6 Multicast.go index f8f4594..2f7b20e 100644 --- a/Network IPv6 Multicast.go +++ b/Network IPv6 Multicast.go @@ -1,5 +1,5 @@ /* -File Name: Network IPv6 Multicast.go +File Username: Network IPv6 Multicast.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner @@ -63,7 +63,7 @@ func (network *Network) MulticastIPv6Join() (err error) { joinMulticastGroup := func(iface *net.Interface) (err error) { pc := ipv6.NewPacketConn(network.multicastSocket) if err := pc.JoinGroup(iface, &net.UDPAddr{IP: network.multicastIP}); err != nil { - //LogError("MulticastIPv6Join", "join multicast group iface '%s' multicast IP '%s' listen on IP '%s' port '%d': %v\n", iface.Name, network.multicastIP.String(), network.address.IP.String(), ipv6MulticastPort, err) + //LogError("MulticastIPv6Join", "join multicast group iface '%s' multicast IP '%s' listen on IP '%s' port '%d': %v\n", iface.Username, network.multicastIP.String(), network.address.IP.String(), ipv6MulticastPort, err) return err } diff --git a/Network Init.go b/Network Init.go index 739fb42..155f548 100644 --- a/Network Init.go +++ b/Network Init.go @@ -1,5 +1,5 @@ /* -File Name: Network Init.go +File Username: Network Init.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Network UPnP.go b/Network UPnP.go index 5106f41..c2bfa5c 100644 --- a/Network UPnP.go +++ b/Network UPnP.go @@ -1,5 +1,5 @@ /* -File Name: Network UPnP.go +File Username: Network UPnP.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Network.go b/Network.go index a7f078c..c2d7798 100644 --- a/Network.go +++ b/Network.go @@ -1,5 +1,5 @@ /* -File Name: Network.go +File Username: Network.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Networks.go b/Networks.go index 97bff74..8cfd234 100644 --- a/Networks.go +++ b/Networks.go @@ -1,5 +1,5 @@ /* -File Name: Networks.go +File Username: Networks.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Peer ID.go b/Peer ID.go index 680d8c2..8dd8969 100644 --- a/Peer ID.go +++ b/Peer ID.go @@ -1,5 +1,5 @@ /* -File Name: Peer ID.go +File Username: Peer ID.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Peernet.go b/Peernet.go index 796887c..b4b8ed0 100644 --- a/Peernet.go +++ b/Peernet.go @@ -1,5 +1,5 @@ /* -File Name: Peernet.go +File Username: Peernet.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ @@ -19,7 +19,7 @@ import ( ) // Init initializes the client. If the config file does not exist or is empty, a default one will be created. -// The User Agent must be provided in the form "Application Name/1.0". +// The User Agent must be provided in the form "Application Username/1.0". // The returned status is of type ExitX. Anything other than ExitSuccess indicates a fatal failure. func Init(UserAgent string, ConfigFilename string, Filters *Filters, ConfigOut interface{}) (backend *Backend, status int, err error) { if UserAgent == "" { diff --git a/Ping.go b/Ping.go index eb04ded..ac36cec 100644 --- a/Ping.go +++ b/Ping.go @@ -1,5 +1,5 @@ /* -File Name: Ping.go +File Username: Ping.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Transfer Block.go b/Transfer Block.go index 2c05a60..680aa56 100644 --- a/Transfer Block.go +++ b/Transfer Block.go @@ -1,5 +1,5 @@ /* -File Name: Transfer Block.go +File Username: Transfer Block.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/Transfer UDT.go b/Transfer UDT.go index 1d8635d..4cb370f 100644 --- a/Transfer UDT.go +++ b/Transfer UDT.go @@ -1,5 +1,5 @@ /* -File Name: Transfer UDT.go +File Username: Transfer UDT.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Transfer Virtual Connection.go b/Transfer Virtual Connection.go index 766989d..a6a36ff 100644 --- a/Transfer Virtual Connection.go +++ b/Transfer Virtual Connection.go @@ -1,5 +1,5 @@ /* -File Name: Transfer Virtual Connection.go +File Username: Transfer Virtual Connection.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/Warehouse.go b/Warehouse.go index b6b176e..2513d27 100644 --- a/Warehouse.go +++ b/Warehouse.go @@ -1,5 +1,5 @@ /* -File Name: Warehouse.go +File Username: Warehouse.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/blockchain/Block Record File.go b/blockchain/Block Record File.go index 69de041..4985048 100644 --- a/blockchain/Block Record File.go +++ b/blockchain/Block Record File.go @@ -1,5 +1,5 @@ /* -File Name: Block Record File.go +File Username: Block Record File.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner @@ -48,6 +48,8 @@ type BlockRecordFile struct { Size uint64 // Size of the file data NodeID []byte // Node ID, owner of the file Tags []BlockRecordFileTag // Tags provide additional metadata + ProfileImage []byte // ProfileImage of the user who uploaded the file + Username string // Username of the User who uploaded the file } // BlockRecordFileTag provides metadata about the file. diff --git a/blockchain/Block Record Profile.go b/blockchain/Block Record Profile.go index 535bcc8..1ff65ba 100644 --- a/blockchain/Block Record Profile.go +++ b/blockchain/Block Record Profile.go @@ -1,5 +1,5 @@ /* -File Name: Block Record Profile.go +File Username: Block Record Profile.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/blockchain/Block Record.go b/blockchain/Block Record.go index 5a411e6..90c3dfd 100644 --- a/blockchain/Block Record.go +++ b/blockchain/Block Record.go @@ -1,5 +1,5 @@ /* -File Name: Block Record.go +File Username: Block Record.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/blockchain/Block.go b/blockchain/Block.go index 9b546f6..7f4ee29 100644 --- a/blockchain/Block.go +++ b/blockchain/Block.go @@ -1,5 +1,5 @@ /* -File Name: Block.go +File Username: Block.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/blockchain/Blockchain.go b/blockchain/Blockchain.go index f2a7e99..d3052a6 100644 --- a/blockchain/Blockchain.go +++ b/blockchain/Blockchain.go @@ -1,5 +1,5 @@ /* -File Name: Blockchain.go +File Username: Blockchain.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/blockchain/File Tag.go b/blockchain/File Tag.go index 8be13c3..ee414a3 100644 --- a/blockchain/File Tag.go +++ b/blockchain/File Tag.go @@ -1,5 +1,5 @@ /* -File Name: File Tag.go +File Username: File Tag.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner @@ -16,7 +16,7 @@ import ( // List of defined file tags. Virtual tags are generated at runtime and are read-only. They cannot be stored on the blockchain. const ( - TagName = 0 // Name of file. + TagName = 0 // Username of file. TagFolder = 1 // Folder name. TagDescription = 2 // Arbitrary description of the file. May contain hashtags. TagDateShared = 3 // When the file was published on the blockchain. Virtual. diff --git a/blockchain/File.go b/blockchain/File.go index 7e82908..7b95af0 100644 --- a/blockchain/File.go +++ b/blockchain/File.go @@ -1,5 +1,5 @@ /* -File Name: File.go +File Username: File.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/blockchain/Multi.go b/blockchain/Multi.go index 032b3e6..c9012ba 100644 --- a/blockchain/Multi.go +++ b/blockchain/Multi.go @@ -1,5 +1,5 @@ /* -File Name: Multi.go +File Username: Multi.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/blockchain/Profile Data.go b/blockchain/Profile Data.go index 0999824..8d1f5be 100644 --- a/blockchain/Profile Data.go +++ b/blockchain/Profile Data.go @@ -1,5 +1,5 @@ /* -File Name: Profile Data.go +File Username: Profile Data.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/blockchain/Profile.go b/blockchain/Profile.go index 2929434..0ea557d 100644 --- a/blockchain/Profile.go +++ b/blockchain/Profile.go @@ -1,5 +1,5 @@ /* -File Name: Profile.go +File Username: Profile.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/blockchain/Test_test.go b/blockchain/Test_test.go index 4798c58..78c6faa 100644 --- a/blockchain/Test_test.go +++ b/blockchain/Test_test.go @@ -167,7 +167,7 @@ func printFile(file BlockRecordFile) { for _, tag := range file.Tags { switch tag.Type { case TagName: - fmt.Printf(" Name %s\n", tag.Text()) + fmt.Printf(" Username %s\n", tag.Text()) case TagFolder: fmt.Printf(" Folder %s\n", tag.Text()) case TagDescription: diff --git a/dht/DHT Lite.go b/dht/DHT Lite.go index 55b0b32..f46faa8 100644 --- a/dht/DHT Lite.go +++ b/dht/DHT Lite.go @@ -1,5 +1,5 @@ /* -File Name: DHT Lite.go +File Username: DHT Lite.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/dht/Hash Table.go b/dht/Hash Table.go index 67e2564..9fa0b3d 100644 --- a/dht/Hash Table.go +++ b/dht/Hash Table.go @@ -1,5 +1,5 @@ /* -File Name: Hash Table.go +File Username: Hash Table.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/dht/Information Request.go b/dht/Information Request.go index 0e88036..d38a812 100644 --- a/dht/Information Request.go +++ b/dht/Information Request.go @@ -1,5 +1,5 @@ /* -File Name: Information Request.go +File Username: Information Request.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/dht/Node.go b/dht/Node.go index 0510071..67b7d34 100644 --- a/dht/Node.go +++ b/dht/Node.go @@ -1,5 +1,5 @@ /* -File Name: Node.go +File Username: Node.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/dht/Search Client.go b/dht/Search Client.go index 8ebf588..0dec1f8 100644 --- a/dht/Search Client.go +++ b/dht/Search Client.go @@ -1,5 +1,5 @@ /* -File Name: Search Client.go +File Username: Search Client.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/merkle/Fragment.go b/merkle/Fragment.go index ca57b96..daae8df 100644 --- a/merkle/Fragment.go +++ b/merkle/Fragment.go @@ -1,5 +1,5 @@ /* -File Name: Fragment.go +File Username: Fragment.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/merkle/Merkle Tree.go b/merkle/Merkle Tree.go index b657e9c..6be5989 100644 --- a/merkle/Merkle Tree.go +++ b/merkle/Merkle Tree.go @@ -1,5 +1,5 @@ /* -File Name: Merkle Tree.go +File Username: Merkle Tree.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Command.go b/protocol/Command.go index a721386..15aa4c8 100644 --- a/protocol/Command.go +++ b/protocol/Command.go @@ -1,5 +1,5 @@ /* -File Name: Command.go +File Username: Command.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/protocol/File Transfer.go b/protocol/File Transfer.go index 6e9aed7..c21f542 100644 --- a/protocol/File Transfer.go +++ b/protocol/File Transfer.go @@ -1,5 +1,5 @@ /* -File Name: File Transfer.go +File Username: File Transfer.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Hash.go b/protocol/Hash.go index 4360c81..a2b34d2 100644 --- a/protocol/Hash.go +++ b/protocol/Hash.go @@ -1,5 +1,5 @@ /* -File Name: Hash.go +File Username: Hash.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/protocol/Message Encoding Announcement.go b/protocol/Message Encoding Announcement.go index 70a3daf..7e7b48d 100644 --- a/protocol/Message Encoding Announcement.go +++ b/protocol/Message Encoding Announcement.go @@ -1,5 +1,5 @@ /* -File Name: Message Encoding Announcement.go +File Username: Message Encoding Announcement.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/protocol/Message Encoding Get Block.go b/protocol/Message Encoding Get Block.go index 0d91553..895f891 100644 --- a/protocol/Message Encoding Get Block.go +++ b/protocol/Message Encoding Get Block.go @@ -1,5 +1,5 @@ /* -File Name: Message Encoding Get Block.go +File Username: Message Encoding Get Block.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Message Encoding Response.go b/protocol/Message Encoding Response.go index b4211dc..2ead7e6 100644 --- a/protocol/Message Encoding Response.go +++ b/protocol/Message Encoding Response.go @@ -1,5 +1,5 @@ /* -File Name: Message Encoding Response.go +File Username: Message Encoding Response.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/protocol/Message Encoding Transfer.go b/protocol/Message Encoding Transfer.go index 4e6f8c0..1c8e664 100644 --- a/protocol/Message Encoding Transfer.go +++ b/protocol/Message Encoding Transfer.go @@ -1,5 +1,5 @@ /* -File Name: Message Encoding Transfer.go +File Username: Message Encoding Transfer.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Message Encoding Traverse.go b/protocol/Message Encoding Traverse.go index 513c917..2ead025 100644 --- a/protocol/Message Encoding Traverse.go +++ b/protocol/Message Encoding Traverse.go @@ -1,5 +1,5 @@ /* -File Name: Message Encoding Traverse.go +File Username: Message Encoding Traverse.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/protocol/Message Encoding.go b/protocol/Message Encoding.go index 8e306ee..ad617ab 100644 --- a/protocol/Message Encoding.go +++ b/protocol/Message Encoding.go @@ -1,5 +1,5 @@ /* -File Name: Message Encoding.go +File Username: Message Encoding.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Packet Encoding.go b/protocol/Packet Encoding.go index 5e3214c..8a77b76 100644 --- a/protocol/Packet Encoding.go +++ b/protocol/Packet Encoding.go @@ -1,5 +1,5 @@ /* -File Name: Packet Encoding.go +File Username: Packet Encoding.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Packet Lite.go b/protocol/Packet Lite.go index 31eb1a5..bc1a168 100644 --- a/protocol/Packet Lite.go +++ b/protocol/Packet Lite.go @@ -1,5 +1,5 @@ /* -File Name: Packet Lite.go +File Username: Packet Lite.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/protocol/Sequence.go b/protocol/Sequence.go index fe6c557..3a39f85 100644 --- a/protocol/Sequence.go +++ b/protocol/Sequence.go @@ -1,5 +1,5 @@ /* -File Name: Sequence.go +File Username: Sequence.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/sanitize/Sanitize.go b/sanitize/Sanitize.go index 6c8899c..3f1c7ff 100644 --- a/sanitize/Sanitize.go +++ b/sanitize/Sanitize.go @@ -1,5 +1,5 @@ /* -File Name: Sanitize.go +File Username: Sanitize.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/search/Normalize.go b/search/Normalize.go index 3fb1cd2..a5aa2d4 100644 --- a/search/Normalize.go +++ b/search/Normalize.go @@ -1,5 +1,5 @@ /* -File Name: Normalizing.go +File name: Normalizing.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/search/Search Index.go b/search/Search Index.go index 107e4fa..0c340f9 100644 --- a/search/Search Index.go +++ b/search/Search Index.go @@ -1,5 +1,5 @@ /* -File Name: Search Index.go +File name: Search Index.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/search/Search Term.go b/search/Search Term.go index a0f6885..158d2f5 100644 --- a/search/Search Term.go +++ b/search/Search Term.go @@ -1,5 +1,5 @@ /* -File Name: Search Term.go +File name: Search Term.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/search/Text 2 Hash.go b/search/Text 2 Hash.go index 5343b3e..b9a7ead 100644 --- a/search/Text 2 Hash.go +++ b/search/Text 2 Hash.go @@ -1,5 +1,5 @@ /* -File Name: Text 2 Hash.go +File name: Text 2 Hash.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/store/Memory.go b/store/Memory.go index 5e987f9..0c06003 100644 --- a/store/Memory.go +++ b/store/Memory.go @@ -1,5 +1,5 @@ /* -File Name: Memory.go +File name: Memory.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/store/Pebble.go b/store/Pebble.go index dd2c088..284bf88 100644 --- a/store/Pebble.go +++ b/store/Pebble.go @@ -1,5 +1,5 @@ /* -File Name: Pebble.go +File name: Pebble.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/store/Pogreb.go b/store/Pogreb.go index 5d10ea1..940b32c 100644 --- a/store/Pogreb.go +++ b/store/Pogreb.go @@ -1,5 +1,5 @@ /* -File Name: Pogreb.go +File Username: Pogreb.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/store/Store.go b/store/Store.go index 4e9a47d..63bea7e 100644 --- a/store/Store.go +++ b/store/Store.go @@ -1,5 +1,5 @@ /* -File Name: Store.go +File Username: Store.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner diff --git a/system/Execute.go b/system/Execute.go index 03c4f8a..a8d5277 100644 --- a/system/Execute.go +++ b/system/Execute.go @@ -1,5 +1,5 @@ /* -File Name: Execute.go +File Username: Execute.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/system/Read Package.go b/system/Read Package.go index f430adb..44be12a 100644 --- a/system/Read Package.go +++ b/system/Read Package.go @@ -1,5 +1,5 @@ /* -File Name: Read Package.go +File Username: Read Package.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/upnp/UPnP.go b/upnp/UPnP.go index dbcd0d5..9a5b49b 100644 --- a/upnp/UPnP.go +++ b/upnp/UPnP.go @@ -1,5 +1,5 @@ /* -File Name: UPnP.go +File Username: UPnP.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/warehouse/Merkle.go b/warehouse/Merkle.go index ac552dd..8dc7be3 100644 --- a/warehouse/Merkle.go +++ b/warehouse/Merkle.go @@ -1,5 +1,5 @@ /* -File Name: Merkle.go +File Username: Merkle.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/warehouse/Store.go b/warehouse/Store.go index e23770d..9cbfd26 100644 --- a/warehouse/Store.go +++ b/warehouse/Store.go @@ -1,5 +1,5 @@ /* -File Name: Store.go +File Username: Store.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/warehouse/Warehouse.go b/warehouse/Warehouse.go index a0479a6..f2ae65b 100644 --- a/warehouse/Warehouse.go +++ b/warehouse/Warehouse.go @@ -1,5 +1,5 @@ /* -File Name: Warehouse.go +File Username: Warehouse.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ @@ -93,7 +93,7 @@ func (wh *Warehouse) IterateFiles(Callback func(Hash []byte, Size int64) (Contin name1 := file.Name() _, err = hex.DecodeString(name1) - // we are only looking for directories. Name has to be "XXXX" hex chars only. + // we are only looking for directories. Username has to be "XXXX" hex chars only. if !file.IsDir() || len(name1) != 4 || err != nil { continue } @@ -108,7 +108,7 @@ func (wh *Warehouse) IterateFiles(Callback func(Hash []byte, Size int64) (Contin name2 := file2.Name() _, err = hex.DecodeString(name2) - // we are only looking for directories. Name has to be "XXXX" hex chars only. + // we are only looking for directories. Username has to be "XXXX" hex chars only. if !file2.IsDir() || len(name2) != 4 || err != nil { continue } diff --git a/webapi/API.go b/webapi/API.go index 03c63f7..1e553d9 100644 --- a/webapi/API.go +++ b/webapi/API.go @@ -1,5 +1,5 @@ /* -File Name: API.go +File Username: API.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/Blockchain.go b/webapi/Blockchain.go index ac7db19..a017ac1 100644 --- a/webapi/Blockchain.go +++ b/webapi/Blockchain.go @@ -1,5 +1,5 @@ /* -File Name: Blockchain.go +File Username: Blockchain.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/Download Transfer.go b/webapi/Download Transfer.go index be41124..7ab7c58 100644 --- a/webapi/Download Transfer.go +++ b/webapi/Download Transfer.go @@ -1,5 +1,5 @@ /* -File Name: Download Transfer.go +File Username: Download Transfer.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner diff --git a/webapi/Download.go b/webapi/Download.go index 9e90209..a4cf890 100644 --- a/webapi/Download.go +++ b/webapi/Download.go @@ -1,5 +1,5 @@ /* -File Name: Download.go +File Username: Download.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ @@ -78,6 +78,8 @@ func (api *WebapiInstance) apiDownloadStart(w http.ResponseWriter, r *http.Reque info := &downloadInfo{backend: api.Backend, api: api, id: uuid.New(), created: time.Now(), hash: hash, nodeID: nodeID} + api.Backend.LogError("Download.DownloadStart", "output %v", downloadInfo{backend: api.Backend, api: api, id: uuid.New(), created: time.Now(), hash: hash, nodeID: nodeID}) + // create the file immediately if info.initDiskFile(filePath) != nil { EncodeJSON(api.Backend, w, r, apiResponseDownloadStatus{APIStatus: DownloadResponseFileInvalid}) @@ -90,6 +92,8 @@ func (api *WebapiInstance) apiDownloadStart(w http.ResponseWriter, r *http.Reque // start the download! go info.Start() + api.Backend.LogError("Download.DownloadStart", "output %v", apiResponseDownloadStatus{APIStatus: DownloadResponseSuccess, ID: info.id, DownloadStatus: DownloadWaitMetadata}) + EncodeJSON(api.Backend, w, r, apiResponseDownloadStatus{APIStatus: DownloadResponseSuccess, ID: info.id, DownloadStatus: DownloadWaitMetadata}) } @@ -132,6 +136,8 @@ func (api *WebapiInstance) apiDownloadStatus(w http.ResponseWriter, r *http.Requ info.RUnlock() + api.Backend.LogError("Download.DownloadStatus", "output %v", response) + EncodeJSON(api.Backend, w, r, response) } diff --git a/webapi/File Detection.go b/webapi/File Detection.go index 789064c..640164f 100644 --- a/webapi/File Detection.go +++ b/webapi/File Detection.go @@ -1,5 +1,5 @@ /* -File Name: File Detection.go +File: File Detection.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/File IO.go b/webapi/File IO.go index 48e4763..15657d0 100644 --- a/webapi/File IO.go +++ b/webapi/File IO.go @@ -1,5 +1,5 @@ /* -File Name: File IO.go +File Username: File IO.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/File.go b/webapi/File.go index 37918ab..9b8181a 100644 --- a/webapi/File.go +++ b/webapi/File.go @@ -1,5 +1,5 @@ /* -File Name: File.go +File Username: File.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ @@ -8,6 +8,7 @@ package webapi import ( "net/http" + "strconv" "time" "github.com/PeernetOfficial/core" @@ -31,24 +32,25 @@ type apiFileMetadata struct { // apiFile is the metadata of a file published on the blockchain type apiFile struct { - ID uuid.UUID `json:"id"` // Unique ID. - Hash []byte `json:"hash"` // Blake3 hash of the file data - Type uint8 `json:"type"` // File Type. For example audio or document. See TypeX. - Format uint16 `json:"format"` // File Format. This is more granular, for example PDF or Word file. See FormatX. - Size uint64 `json:"size"` // Size of the file - Folder string `json:"folder"` // Folder, optional - Name string `json:"name"` // Name of the file - Description string `json:"description"` // Description. This is expected to be multiline and contain hashtags! - Date time.Time `json:"date"` // Date shared - NodeID []byte `json:"nodeid"` // Node ID, owner of the file. Read only. - Metadata []apiFileMetadata `json:"metadata"` // Additional metadata. - Profile apiBlockRecordProfile + ID uuid.UUID `json:"id"` // Unique ID. + Hash []byte `json:"hash"` // Blake3 hash of the file data + Type uint8 `json:"type"` // File Type. For example audio or document. See TypeX. + Format uint16 `json:"format"` // File Format. This is more granular, for example PDF or Word file. See FormatX. + Size uint64 `json:"size"` // Size of the file + Folder string `json:"folder"` // Folder, optional + Name string `json:"name"` // Name of the file + Description string `json:"description"` // Description. This is expected to be multiline and contain hashtags! + Date time.Time `json:"date"` // Date shared + NodeID []byte `json:"nodeid"` // Node ID, owner of the file. Read only. + Metadata []apiFileMetadata `json:"metadata"` // Additional metadata. + ProfilePicture []byte `json:"profilepicture"` // The Profile Picture of the user who uploaded the file + Username string `json:"username"` // Username of the user who uploaded the file } // --- conversion from core to API data --- func blockRecordFileToAPI(input blockchain.BlockRecordFile) (output apiFile) { - output = apiFile{ID: input.ID, Hash: input.Hash, NodeID: input.NodeID, Type: input.Type, Format: input.Format, Size: input.Size, Metadata: []apiFileMetadata{}} + output = apiFile{ID: input.ID, Hash: input.Hash, NodeID: input.NodeID, Type: input.Type, Format: input.Format, Size: input.Size, ProfilePicture: input.ProfileImage, Username: input.Username, Metadata: []apiFileMetadata{}} for _, tag := range input.Tags { switch tag.Type { @@ -193,16 +195,25 @@ func (api *WebapiInstance) apiBlockchainFileAdd(w http.ResponseWriter, r *http.R /* apiBlockchainFileList lists all files stored on the blockchain. -Request: GET /blockchain/file/list +Request: GET /blockchain/file/list?fileFormat= Response: 200 with JSON structure apiBlockAddFiles */ func (api *WebapiInstance) apiBlockchainFileList(w http.ResponseWriter, r *http.Request) { files, status := api.Backend.UserBlockchain.ListFiles() + r.ParseForm() + // filter based on file type + fileType, err := strconv.Atoi(r.Form.Get("fileFormat")) + var result apiBlockAddFiles for _, file := range files { - result.Files = append(result.Files, blockRecordFileToAPI(file)) + apiFile := blockRecordFileToAPI(file) + if apiFile.Format == uint16(fileType) { + result.Files = append(result.Files, apiFile) + } else if err != nil { + result.Files = append(result.Files, apiFile) + } } result.Status = status diff --git a/webapi/GeoIP.go b/webapi/GeoIP.go index 3e19b94..03be9b3 100644 --- a/webapi/GeoIP.go +++ b/webapi/GeoIP.go @@ -1,5 +1,5 @@ /* -File Name: GeoIP.go +File Username: GeoIP.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner diff --git a/webapi/HTTP Range.go b/webapi/HTTP Range.go index cb8985f..bb5b1a2 100644 --- a/webapi/HTTP Range.go +++ b/webapi/HTTP Range.go @@ -1,5 +1,5 @@ /* -File Name: HTTP Range.go +File Username: HTTP Range.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/Profile.go b/webapi/Profile.go index 683b696..8598380 100644 --- a/webapi/Profile.go +++ b/webapi/Profile.go @@ -1,5 +1,5 @@ /* -File Name: Profile.go +File Username: Profile.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/Search Dispatch.go b/webapi/Search Dispatch.go index a971446..76d473f 100644 --- a/webapi/Search Dispatch.go +++ b/webapi/Search Dispatch.go @@ -1,5 +1,5 @@ /* -File Name: Search Dispatch.go +File Username: Search Dispatch.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/Search Job.go b/webapi/Search Job.go index 1f24435..4dfd091 100644 --- a/webapi/Search Job.go +++ b/webapi/Search Job.go @@ -1,5 +1,5 @@ /* -File Name: Search Job.go +File Username: Search Job.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ @@ -257,7 +257,7 @@ func (job *SearchJob) isFileFiltered(file *apiFile) bool { return true } -// SortFiles sorts a list of files. It returns a sorted list. 0 = no sorting, 1 = Relevance ASC, 2 = Relevance DESC, 3 = Date ASC, 4 = Date DESC, 5 = Name ASC, 6 = Name DESC +// SortFiles sorts a list of files. It returns a sorted list. 0 = no sorting, 1 = Relevance ASC, 2 = Relevance DESC, 3 = Date ASC, 4 = Date DESC, 5 = Username ASC, 6 = Username DESC func SortFiles(files []*apiFile, Sort int) (sorted []*apiFile) { switch Sort { case SortRelevanceAsc: diff --git a/webapi/Search.go b/webapi/Search.go index d25f2b2..440a8fa 100644 --- a/webapi/Search.go +++ b/webapi/Search.go @@ -1,5 +1,5 @@ /* -File Name: Search.go +File Username: Search.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner @@ -353,7 +353,7 @@ func (api *WebapiInstance) apiSearchStatistic(w http.ResponseWriter, r *http.Req apiExplore returns recently shared files in Peernet. Results are returned in real-time. The file type is an optional filter. See TypeX. Special type -2 = Binary, Compressed, Container, Executable. This special type includes everything except Documents, Video, Audio, Ebooks, Picture, Text. -Request: GET /explore?limit=[max records]&type=[file type]&offset=[offset] +Request: GET /explore?limit=[max records]&type=[file type]&offset=[offset]&node=[nodeID] Result: 200 with JSON structure SearchResult. Check the field status. */ func (api *WebapiInstance) apiExplore(w http.ResponseWriter, r *http.Request) { @@ -369,7 +369,14 @@ func (api *WebapiInstance) apiExplore(w http.ResponseWriter, r *http.Request) { fileType = -1 } - result := api.ExploreHelper(fileType, limit, offset, []byte{}, false) + var result *SearchResult + + NodeId, valid := DecodeBlake3Hash(r.Form.Get("node")) + if valid { + result = api.ExploreHelper(fileType, limit, offset, NodeId, true) + } else { + result = api.ExploreHelper(fileType, limit, offset, []byte{}, false) + } EncodeJSON(api.Backend, w, r, result) } diff --git a/webapi/Shared Recent.go b/webapi/Shared Recent.go index d7d6eb5..1e72ce6 100644 --- a/webapi/Shared Recent.go +++ b/webapi/Shared Recent.go @@ -1,5 +1,5 @@ /* -File Name: Shared Recent.go +File Username: Shared Recent.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ @@ -18,7 +18,6 @@ func (api *WebapiInstance) queryRecentShared(backend *core.Backend, fileType int if limitPeer == 0 { limitPeer = 1 } - // Assign peer list as an empty array var peerList []*core.PeerInfo @@ -45,10 +44,37 @@ func (api *WebapiInstance) queryRecentShared(backend *core.Backend, fileType int var filesFromPeer uint64 + var ProfileImage []byte + var Name string + + ProfileNameFound := false + ProfilePictureFound := false + + // First iteration of the entire blockchain to search for the profile + // image and Username of the user + for blockN1 := peer.BlockchainHeight - 1; blockN1 > 0; blockN1-- { + blockDecoded, _, found, _ := backend.ReadBlock(peer.PublicKey, peer.BlockchainVersion, blockN1) + if !found { + continue + } + // Adding profile image and Username to the output + for raw := range blockDecoded.Block.RecordsRaw { + if blockDecoded.Block.RecordsRaw[raw].Type == blockchain.ProfilePicture && !ProfilePictureFound { + ProfileImage = blockDecoded.Block.RecordsRaw[raw].Data + ProfilePictureFound = true + } + if blockDecoded.Block.RecordsRaw[raw].Type == blockchain.ProfileName && !ProfileNameFound { + Name = string(blockDecoded.Block.RecordsRaw[raw].Data[:]) + ProfileNameFound = true + } + } + } + // decode blocks from top down blockLoop: for blockN := peer.BlockchainHeight - 1; blockN > 0; blockN-- { blockDecoded, _, found, _ := backend.ReadBlock(peer.PublicKey, peer.BlockchainVersion, blockN) + if !found { continue } @@ -62,6 +88,11 @@ func (api *WebapiInstance) queryRecentShared(backend *core.Backend, fileType int file.Tags = append(file.Tags, blockchain.TagFromText(blockchain.TagSharedByGeoIP, sharedByGeoIP)) } + // Add profile image + file.ProfileImage = ProfileImage + // Add profile name + file.Username = Name + // found a new file! append. if filesFromPeer < limitPeer { filesFromPeer++ diff --git a/webapi/Status.go b/webapi/Status.go index e63735a..37cbdc5 100644 --- a/webapi/Status.go +++ b/webapi/Status.go @@ -1,5 +1,5 @@ /* -File Name: Status.go +File Username: Status.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */ diff --git a/webapi/Warehouse.go b/webapi/Warehouse.go index f7c4e05..42e7f8c 100644 --- a/webapi/Warehouse.go +++ b/webapi/Warehouse.go @@ -1,5 +1,5 @@ /* -File Name: Warehouse.go +File Username: Warehouse.go Copyright: 2021 Peernet Foundation s.r.o. Author: Peter Kleissner */