Compare commits
14 Commits
source-tra
...
connection
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84cee0aa43 | ||
|
|
162844787f | ||
|
|
d8a2b59055 | ||
|
|
67a0939de4 | ||
|
|
37ca922a2c | ||
|
|
1d6781819b | ||
|
|
64d45da94a | ||
|
|
59c84d8a5e | ||
|
|
8b55021a4b | ||
|
|
8bd3ebfaf5 | ||
|
|
526ec45da3 | ||
|
|
deb7c0b4b0 | ||
|
|
e85a0c7b2c | ||
|
|
7b021a47eb |
@@ -35,7 +35,7 @@ class Cli {
|
|||||||
|
|
||||||
Core core
|
Core core
|
||||||
try {
|
try {
|
||||||
core = new Core(props, home, "0.2.6")
|
core = new Core(props, home, "0.2.9")
|
||||||
} catch (Exception bad) {
|
} catch (Exception bad) {
|
||||||
bad.printStackTrace(System.out)
|
bad.printStackTrace(System.out)
|
||||||
println "Failed to initialize core, exiting"
|
println "Failed to initialize core, exiting"
|
||||||
@@ -73,7 +73,7 @@ class Cli {
|
|||||||
|
|
||||||
Timer timer = new Timer("status-printer", true)
|
Timer timer = new Timer("status-printer", true)
|
||||||
timer.schedule({
|
timer.schedule({
|
||||||
println "Connections $connectionsListener.connections Uploads $uploadsListener.uploads Shared $sharedListener.shared"
|
println String.valueOf(new Date()) + " Connections $connectionsListener.connections Uploads $uploadsListener.uploads Shared $sharedListener.shared"
|
||||||
} as TimerTask, 60000, 60000)
|
} as TimerTask, 60000, 60000)
|
||||||
|
|
||||||
def latch = new CountDownLatch(1)
|
def latch = new CountDownLatch(1)
|
||||||
@@ -119,11 +119,11 @@ class Cli {
|
|||||||
volatile int uploads
|
volatile int uploads
|
||||||
public void onUploadEvent(UploadEvent e) {
|
public void onUploadEvent(UploadEvent e) {
|
||||||
uploads++
|
uploads++
|
||||||
println "Starting upload of ${e.uploader.file.getName()} to ${e.uploader.request.downloader.getHumanReadableName()}"
|
println String.valueOf(new Date()) + " Starting upload of ${e.uploader.file.getName()} to ${e.uploader.request.downloader.getHumanReadableName()}"
|
||||||
}
|
}
|
||||||
public void onUploadFinishedEvent(UploadFinishedEvent e) {
|
public void onUploadFinishedEvent(UploadFinishedEvent e) {
|
||||||
uploads--
|
uploads--
|
||||||
println "Finished upload of ${e.uploader.file.getName()} to ${e.uploader.request.downloader.getHumanReadableName()}"
|
println String.valueOf(new Date()) + " Finished upload of ${e.uploader.file.getName()} to ${e.uploader.request.downloader.getHumanReadableName()}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class CliDownloader {
|
|||||||
|
|
||||||
Core core
|
Core core
|
||||||
try {
|
try {
|
||||||
core = new Core(props, home, "0.2.6")
|
core = new Core(props, home, "0.2.9")
|
||||||
} catch (Exception bad) {
|
} catch (Exception bad) {
|
||||||
bad.printStackTrace(System.out)
|
bad.printStackTrace(System.out)
|
||||||
println "Failed to initialize core, exiting"
|
println "Failed to initialize core, exiting"
|
||||||
|
|||||||
23
cli/src/main/groovy/com/muwire/cli/FileList.groovy
Normal file
23
cli/src/main/groovy/com/muwire/cli/FileList.groovy
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.muwire.cli
|
||||||
|
|
||||||
|
import com.muwire.core.util.DataUtil
|
||||||
|
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
import net.i2p.data.Base64
|
||||||
|
|
||||||
|
class FileList {
|
||||||
|
public static void main(String [] args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
println "pass files.json as argument"
|
||||||
|
System.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
def slurper = new JsonSlurper()
|
||||||
|
File filesJson = new File(args[0])
|
||||||
|
filesJson.eachLine {
|
||||||
|
def json = slurper.parseText(it)
|
||||||
|
String name = DataUtil.readi18nString(Base64.decode(json.file))
|
||||||
|
println "$name,$json.length,$json.pieceSize,$json.infoHash"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,6 +72,7 @@ public class Core {
|
|||||||
private final HasherService hasherService
|
private final HasherService hasherService
|
||||||
private final DownloadManager downloadManager
|
private final DownloadManager downloadManager
|
||||||
private final DirectoryWatcher directoryWatcher
|
private final DirectoryWatcher directoryWatcher
|
||||||
|
final FileManager fileManager
|
||||||
|
|
||||||
public Core(MuWireSettings props, File home, String myVersion) {
|
public Core(MuWireSettings props, File home, String myVersion) {
|
||||||
this.home = home
|
this.home = home
|
||||||
@@ -155,7 +156,7 @@ public class Core {
|
|||||||
|
|
||||||
|
|
||||||
log.info "initializing file manager"
|
log.info "initializing file manager"
|
||||||
FileManager fileManager = new FileManager(eventBus, props)
|
fileManager = new FileManager(eventBus, props)
|
||||||
eventBus.register(FileHashedEvent.class, fileManager)
|
eventBus.register(FileHashedEvent.class, fileManager)
|
||||||
eventBus.register(FileLoadedEvent.class, fileManager)
|
eventBus.register(FileLoadedEvent.class, fileManager)
|
||||||
eventBus.register(FileDownloadedEvent.class, fileManager)
|
eventBus.register(FileDownloadedEvent.class, fileManager)
|
||||||
@@ -276,7 +277,7 @@ public class Core {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core core = new Core(props, home, "0.2.6")
|
Core core = new Core(props, home, "0.2.9")
|
||||||
core.startServices()
|
core.startServices()
|
||||||
|
|
||||||
// ... at the end, sleep or execute script
|
// ... at the end, sleep or execute script
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class MuWireSettings {
|
|||||||
nickname = props.getProperty("nickname","MuWireUser")
|
nickname = props.getProperty("nickname","MuWireUser")
|
||||||
downloadLocation = new File((String)props.getProperty("downloadLocation",
|
downloadLocation = new File((String)props.getProperty("downloadLocation",
|
||||||
System.getProperty("user.home")))
|
System.getProperty("user.home")))
|
||||||
downloadRetryInterval = Integer.parseInt(props.getProperty("downloadRetryInterval","15"))
|
downloadRetryInterval = Integer.parseInt(props.getProperty("downloadRetryInterval","5"))
|
||||||
updateCheckInterval = Integer.parseInt(props.getProperty("updateCheckInterval","36"))
|
updateCheckInterval = Integer.parseInt(props.getProperty("updateCheckInterval","36"))
|
||||||
shareDownloadedFiles = Boolean.parseBoolean(props.getProperty("shareDownloadedFiles","true"))
|
shareDownloadedFiles = Boolean.parseBoolean(props.getProperty("shareDownloadedFiles","true"))
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import java.nio.file.FileSystems
|
|||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import static java.nio.file.StandardWatchEventKinds.*
|
import static java.nio.file.StandardWatchEventKinds.*
|
||||||
|
|
||||||
|
import java.nio.file.ClosedWatchServiceException
|
||||||
import java.nio.file.WatchEvent
|
import java.nio.file.WatchEvent
|
||||||
import java.nio.file.WatchKey
|
import java.nio.file.WatchKey
|
||||||
import java.nio.file.WatchService
|
import java.nio.file.WatchService
|
||||||
@@ -79,7 +81,7 @@ class DirectoryWatcher {
|
|||||||
}
|
}
|
||||||
key.reset()
|
key.reset()
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException|ClosedWatchServiceException e) {
|
||||||
if (!shutdown)
|
if (!shutdown)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
@@ -91,6 +93,8 @@ class DirectoryWatcher {
|
|||||||
log.fine("created entry $f")
|
log.fine("created entry $f")
|
||||||
if (f.isDirectory())
|
if (f.isDirectory())
|
||||||
f.toPath().register(watchService, kinds)
|
f.toPath().register(watchService, kinds)
|
||||||
|
else
|
||||||
|
waitingFiles.put(f, System.currentTimeMillis())
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processModified(Path parent, Path path) {
|
private void processModified(Path parent, Path path) {
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import net.i2p.data.Destination
|
|||||||
class Host {
|
class Host {
|
||||||
|
|
||||||
private static final int MAX_FAILURES = 3
|
private static final int MAX_FAILURES = 3
|
||||||
|
private static final int CLEAR_INTERVAL = 60 * 60 * 1000
|
||||||
|
|
||||||
final Destination destination
|
final Destination destination
|
||||||
int failures,successes
|
int failures,successes
|
||||||
|
long lastAttempt
|
||||||
|
|
||||||
public Host(Destination destination) {
|
public Host(Destination destination) {
|
||||||
this.destination = destination
|
this.destination = destination
|
||||||
@@ -16,11 +18,13 @@ class Host {
|
|||||||
synchronized void onConnect() {
|
synchronized void onConnect() {
|
||||||
failures = 0
|
failures = 0
|
||||||
successes++
|
successes++
|
||||||
|
lastAttempt = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void onFailure() {
|
synchronized void onFailure() {
|
||||||
failures++
|
failures++
|
||||||
successes = 0
|
successes = 0
|
||||||
|
lastAttempt = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized boolean isFailed() {
|
synchronized boolean isFailed() {
|
||||||
@@ -34,4 +38,8 @@ class Host {
|
|||||||
synchronized void clearFailures() {
|
synchronized void clearFailures() {
|
||||||
failures = 0
|
failures = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized void canTryAgain() {
|
||||||
|
System.currentTimeMillis() - lastAttempt > CLEAR_INTERVAL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ class HostCache extends Service {
|
|||||||
Host host = new Host(dest)
|
Host host = new Host(dest)
|
||||||
host.failures = Integer.valueOf(String.valueOf(entry.failures))
|
host.failures = Integer.valueOf(String.valueOf(entry.failures))
|
||||||
host.successes = Integer.valueOf(String.valueOf(entry.successes))
|
host.successes = Integer.valueOf(String.valueOf(entry.successes))
|
||||||
|
if (entry.lastAttempt != null)
|
||||||
|
host.lastAttempt = entry.lastAttempt
|
||||||
if (allowHost(host))
|
if (allowHost(host))
|
||||||
hosts.put(dest, host)
|
hosts.put(dest, host)
|
||||||
}
|
}
|
||||||
@@ -118,7 +120,7 @@ class HostCache extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean allowHost(Host host) {
|
private boolean allowHost(Host host) {
|
||||||
if (host.isFailed())
|
if (host.isFailed() && !host.canTryAgain())
|
||||||
return false
|
return false
|
||||||
if (host.destination == myself)
|
if (host.destination == myself)
|
||||||
return false
|
return false
|
||||||
@@ -143,6 +145,7 @@ class HostCache extends Service {
|
|||||||
map.destination = dest.toBase64()
|
map.destination = dest.toBase64()
|
||||||
map.failures = host.failures
|
map.failures = host.failures
|
||||||
map.successes = host.successes
|
map.successes = host.successes
|
||||||
|
map.lastAttempt = host.lastAttempt
|
||||||
def json = JsonOutput.toJson(map)
|
def json = JsonOutput.toJson(map)
|
||||||
writer.println json
|
writer.println json
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
group = com.muwire
|
group = com.muwire
|
||||||
version = 0.2.6
|
version = 0.2.9
|
||||||
groovyVersion = 2.4.15
|
groovyVersion = 2.4.15
|
||||||
slf4jVersion = 1.7.25
|
slf4jVersion = 1.7.25
|
||||||
spockVersion = 1.1-groovy-2.4
|
spockVersion = 1.1-groovy-2.4
|
||||||
|
|
||||||
|
sourceCompatibility=1.8
|
||||||
|
targetCompatibility=1.8
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class SearchTabModel {
|
|||||||
|
|
||||||
void handleResult(UIResultEvent e) {
|
void handleResult(UIResultEvent e) {
|
||||||
if (uiSettings.excludeLocalResult &&
|
if (uiSettings.excludeLocalResult &&
|
||||||
e.sender == core.me)
|
core.fileManager.rootToFiles.containsKey(e.infohash))
|
||||||
return
|
return
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
def bucket = hashBucket.get(e.infohash)
|
def bucket = hashBucket.get(e.infohash)
|
||||||
@@ -64,7 +64,8 @@ class SearchTabModel {
|
|||||||
void handleResultBatch(UIResultEvent[] batch) {
|
void handleResultBatch(UIResultEvent[] batch) {
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
batch.each {
|
batch.each {
|
||||||
if (uiSettings.excludeLocalResult && it.sender == core.me)
|
if (uiSettings.excludeLocalResult &&
|
||||||
|
core.fileManager.rootToFiles.containsKey(it.infohash))
|
||||||
return
|
return
|
||||||
def bucket = hashBucket.get(it.infohash)
|
def bucket = hashBucket.get(it.infohash)
|
||||||
if (bucket == null) {
|
if (bucket == null) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
import griffon.core.artifact.GriffonView
|
import griffon.core.artifact.GriffonView
|
||||||
|
import griffon.core.env.Metadata
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
import net.i2p.data.Base64
|
import net.i2p.data.Base64
|
||||||
@@ -37,6 +38,7 @@ import java.awt.event.MouseEvent
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonView)
|
@ArtifactProviderFor(GriffonView)
|
||||||
class MainFrameView {
|
class MainFrameView {
|
||||||
@@ -45,6 +47,8 @@ class MainFrameView {
|
|||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
MainFrameModel model
|
MainFrameModel model
|
||||||
|
|
||||||
|
@Inject Metadata metadata
|
||||||
|
|
||||||
def downloadsTable
|
def downloadsTable
|
||||||
def lastDownloadSortEvent
|
def lastDownloadSortEvent
|
||||||
def lastSharedSortEvent
|
def lastSharedSortEvent
|
||||||
@@ -54,7 +58,7 @@ class MainFrameView {
|
|||||||
builder.with {
|
builder.with {
|
||||||
application(size : [1024,768], id: 'main-frame',
|
application(size : [1024,768], id: 'main-frame',
|
||||||
locationRelativeTo : null,
|
locationRelativeTo : null,
|
||||||
title: application.configuration['application.title'],
|
title: application.configuration['application.title'] + " " + metadata["application.version"],
|
||||||
iconImage: imageIcon('/griffon-icon-48x48.png').image,
|
iconImage: imageIcon('/griffon-icon-48x48.png').image,
|
||||||
iconImages: [imageIcon('/griffon-icon-48x48.png').image,
|
iconImages: [imageIcon('/griffon-icon-48x48.png').image,
|
||||||
imageIcon('/griffon-icon-32x32.png').image,
|
imageIcon('/griffon-icon-32x32.png').image,
|
||||||
|
|||||||
Reference in New Issue
Block a user