File Sharing MVP #384

Merged
sarah merged 52 commits from filesharing into master 2021-09-30 00:57:14 +00:00
2 changed files with 0 additions and 41 deletions
Showing only changes of commit c3376e9d3a - Show all commits

View File

@ -7,10 +7,8 @@ import (
"cwtch.im/cwtch/protocol/groups"
model3 "cwtch.im/cwtch/protocol/model"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"git.openprivacy.ca/cwtch.im/tapir"
"git.openprivacy.ca/cwtch.im/tapir/applications"
"git.openprivacy.ca/cwtch.im/tapir/networks/tor"
@ -21,7 +19,6 @@ import (
"github.com/gtank/ristretto255"
"golang.org/x/crypto/ed25519"
"strconv"
"strings"
"sync"
"time"
)
@ -214,31 +211,6 @@ func (e *engine) eventHandler() {
}
}
func (e *engine) fetchManifest(handle string, fileKey string, manifestSize uint64) {
// Store a blank manifest
e.manifests.Store(fileKey, strings.Repeat("\"", int(manifestSize*files.DefaultChunkSize)))
conn, err := e.service.WaitForCapabilityOrClose(handle, cwtchCapability)
if err == nil {
peerApp, ok := (conn.App()).(*PeerApp)
if ok {
peerApp.FetchManifestChunks(fileKey)
}
}
}
func (e *engine) sendManifestChunk(handle string, fileKey string, id uint64, chunk []byte) {
conn, err := e.service.WaitForCapabilityOrClose(handle, cwtchCapability)
if err == nil {
peerApp, ok := (conn.App()).(*PeerApp)
if ok {
peerApp.SendMessage(PeerMessage{
Context: event.ContextSendManifest,
ID: fmt.Sprintf("%s.%d", fileKey, id),
Data: chunk,
})
}
}
}
func (e *engine) isBlocked(onion string) bool {
authorization, known := e.authorizations.Load(onion)

View File

@ -117,17 +117,4 @@ func (pa *PeerApp) SendMessage(message model2.PeerMessage) {
}
serialized, _ := json.Marshal(message)
pa.connection.Send(serialized)
}
func (pa *PeerApp) FetchManifestChunks(key string) {
message := PeerMessage{
Context: event.ContextRequestManifest,
ID: key,
Data: []byte{},
}
serialized, _ := json.Marshal(message)
pa.connection.Send(serialized)
}