Merge branch 'trunk' into macosBuild
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
commit
3386afd3b5
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.openprivacy.ca/cwtch.im/libcwtch-go
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cwtch.im/cwtch v0.13.1
|
cwtch.im/cwtch v0.13.2
|
||||||
git.openprivacy.ca/cwtch.im/server v1.3.2
|
git.openprivacy.ca/cwtch.im/server v1.3.2
|
||||||
git.openprivacy.ca/openprivacy/connectivity v1.5.0
|
git.openprivacy.ca/openprivacy/connectivity v1.5.0
|
||||||
git.openprivacy.ca/openprivacy/log v1.0.3
|
git.openprivacy.ca/openprivacy/log v1.0.3
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -4,6 +4,8 @@ cwtch.im/cwtch v0.13.0 h1:9WhLG9czfyRceZnHSqfTAq0vfmDC/E20mziJb9+Skrg=
|
||||||
cwtch.im/cwtch v0.13.0/go.mod h1:QpTkQK7MqNt0dQK9/pBk5VpkvFhy6xuoxJIn401B8fM=
|
cwtch.im/cwtch v0.13.0/go.mod h1:QpTkQK7MqNt0dQK9/pBk5VpkvFhy6xuoxJIn401B8fM=
|
||||||
cwtch.im/cwtch v0.13.1 h1:k7CDr16ZLZ+uaRtic2Joooc8TzkO7BkgWXs8r9ilqDY=
|
cwtch.im/cwtch v0.13.1 h1:k7CDr16ZLZ+uaRtic2Joooc8TzkO7BkgWXs8r9ilqDY=
|
||||||
cwtch.im/cwtch v0.13.1/go.mod h1:QpTkQK7MqNt0dQK9/pBk5VpkvFhy6xuoxJIn401B8fM=
|
cwtch.im/cwtch v0.13.1/go.mod h1:QpTkQK7MqNt0dQK9/pBk5VpkvFhy6xuoxJIn401B8fM=
|
||||||
|
cwtch.im/cwtch v0.13.2 h1:qbKTQOUryvJpTzIf5iT49x6iAmeNxiz0doNb5phYVEQ=
|
||||||
|
cwtch.im/cwtch v0.13.2/go.mod h1:QpTkQK7MqNt0dQK9/pBk5VpkvFhy6xuoxJIn401B8fM=
|
||||||
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
|
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
|
||||||
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||||
git.openprivacy.ca/cwtch.im/server v1.3.1 h1:Kt4TnlGxGPk1KTjvs1cXtnFWDx+hYqu8w+2eIaqt+F4=
|
git.openprivacy.ca/cwtch.im/server v1.3.1 h1:Kt4TnlGxGPk1KTjvs1cXtnFWDx+hYqu8w+2eIaqt+F4=
|
||||||
|
|
36
lib.go
36
lib.go
|
@ -208,6 +208,7 @@ func _startCwtch(appDir string, torPath string) {
|
||||||
event.ProtocolEngineStopped,
|
event.ProtocolEngineStopped,
|
||||||
event.RetryServerRequest,
|
event.RetryServerRequest,
|
||||||
event.ManifestReceived,
|
event.ManifestReceived,
|
||||||
|
event.FileDownloaded,
|
||||||
}
|
}
|
||||||
settings := utils.ReadGlobalSettings()
|
settings := utils.ReadGlobalSettings()
|
||||||
settingsJson, _ := json.Marshal(settings)
|
settingsJson, _ := json.Marshal(settings)
|
||||||
|
@ -759,13 +760,45 @@ func c_CheckDownloadStatus(profilePtr *C.char, profileLen C.int, fileKeyPtr *C.c
|
||||||
|
|
||||||
func CheckDownloadStatus(profileOnion, fileKey string) {
|
func CheckDownloadStatus(profileOnion, fileKey string) {
|
||||||
profile := application.GetPeer(profileOnion)
|
profile := application.GetPeer(profileOnion)
|
||||||
if path, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fileKey); exists {
|
path, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey))
|
||||||
|
if _, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.complete", fileKey)); exists {
|
||||||
eventHandler.Push(event.NewEvent(event.FileDownloaded, map[event.Field]string{
|
eventHandler.Push(event.NewEvent(event.FileDownloaded, map[event.Field]string{
|
||||||
ProfileOnion: profileOnion,
|
ProfileOnion: profileOnion,
|
||||||
event.FileKey: fileKey,
|
event.FileKey: fileKey,
|
||||||
event.FilePath: path,
|
event.FilePath: path,
|
||||||
event.TempFile: "",
|
event.TempFile: "",
|
||||||
}))
|
}))
|
||||||
|
} else {
|
||||||
|
log.Infof("CheckDownloadStatus found .path but not .complete")
|
||||||
|
eventHandler.Push(event.NewEvent(event.FileDownloadProgressUpdate, map[event.Field]string{
|
||||||
|
ProfileOnion: profileOnion,
|
||||||
|
event.FileKey: fileKey,
|
||||||
|
event.Progress: "-1",
|
||||||
|
event.FileSizeInChunks: "-1",
|
||||||
|
event.FilePath: path,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//export c_VerifyOrResumeDownload
|
||||||
|
func c_VerifyOrResumeDownload(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, filekey_ptr *C.char, filekey_len C.int) {
|
||||||
|
profile := C.GoStringN(profile_ptr, profile_len)
|
||||||
|
handle := C.GoStringN(handle_ptr, handle_len)
|
||||||
|
filekey := C.GoStringN(filekey_ptr, filekey_len)
|
||||||
|
VerifyOrResumeDownload(profile, handle, filekey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func VerifyOrResumeDownload(profileOnion, handle, fileKey string) {
|
||||||
|
profile := application.GetPeer(profileOnion)
|
||||||
|
if manifestFilePath, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%v.manifest", fileKey)); exists {
|
||||||
|
if downloadfilepath, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.path", fileKey)); exists {
|
||||||
|
log.Infof("resuming %s", fileKey)
|
||||||
|
DownloadFile(profileOnion, handle, downloadfilepath, manifestFilePath, fileKey)
|
||||||
|
} else {
|
||||||
|
log.Errorf("found manifest path but not download path for %s", fileKey)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Errorf("no stored manifest path found for %s", fileKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1091,7 +1124,6 @@ func LaunchServer(onion string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//export c_StopServer
|
//export c_StopServer
|
||||||
func c_StopServer(onionPtr *C.char, onionLen C.int) {
|
func c_StopServer(onionPtr *C.char, onionLen C.int) {
|
||||||
StopServer(C.GoStringN(onionPtr, onionLen))
|
StopServer(C.GoStringN(onionPtr, onionLen))
|
||||||
|
|
Reference in New Issue