mirror of https://github.com/zlatinb/muwire
wire some components together
parent
19a688037f
commit
46ddd65e03
|
@ -1,9 +1,18 @@
|
||||||
package com.muwire.core
|
package com.muwire.core
|
||||||
|
|
||||||
|
import com.muwire.core.connection.ConnectionEvent
|
||||||
|
import com.muwire.core.connection.ConnectionManager
|
||||||
|
import com.muwire.core.connection.LeafConnectionManager
|
||||||
|
import com.muwire.core.connection.UltrapeerConnectionManager
|
||||||
|
import com.muwire.core.hostcache.CacheClient
|
||||||
|
import com.muwire.core.hostcache.HostCache
|
||||||
|
import com.muwire.core.hostcache.HostDiscoveredEvent
|
||||||
import com.muwire.core.trust.TrustEvent
|
import com.muwire.core.trust.TrustEvent
|
||||||
import com.muwire.core.trust.TrustService
|
import com.muwire.core.trust.TrustService
|
||||||
|
|
||||||
import groovy.util.logging.Log
|
import groovy.util.logging.Log
|
||||||
|
import net.i2p.client.I2PClientFactory
|
||||||
|
import net.i2p.client.I2PSession
|
||||||
|
|
||||||
@Log
|
@Log
|
||||||
class Core {
|
class Core {
|
||||||
|
@ -39,6 +48,46 @@ class Core {
|
||||||
trustService.start()
|
trustService.start()
|
||||||
trustService.waitForLoad()
|
trustService.waitForLoad()
|
||||||
|
|
||||||
|
log.info("initializing host cache")
|
||||||
|
File hostStorage = new File(home, "hosts.json")
|
||||||
|
HostCache hostCache = new HostCache(trustService,hostStorage, 30000, props)
|
||||||
|
eventBus.register(HostDiscoveredEvent.class, hostCache)
|
||||||
|
eventBus.register(ConnectionEvent.class, hostCache)
|
||||||
|
hostCache.start()
|
||||||
|
hostCache.waitForLoad()
|
||||||
|
|
||||||
|
log.info("initializing connection manager")
|
||||||
|
ConnectionManager connectionManager = props.isLeaf() ?
|
||||||
|
new LeafConnectionManager(eventBus,3) : new UltrapeerConnectionManager(eventBus, 512, 512)
|
||||||
|
eventBus.register(TrustEvent.class, connectionManager)
|
||||||
|
|
||||||
|
log.info("initializing I2P session")
|
||||||
|
def i2pClient = new I2PClientFactory().createClient()
|
||||||
|
File keyDat = new File(home, "key.dat")
|
||||||
|
if (!keyDat.exists()) {
|
||||||
|
log.info("Creating new key.dat")
|
||||||
|
keyDat.withOutputStream {
|
||||||
|
i2pClient.createDestination(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def sysProps = System.getProperties().clone()
|
||||||
|
sysProps["inbound.nickname"] = "MuWire"
|
||||||
|
I2PSession i2pSession
|
||||||
|
keyDat.withInputStream {
|
||||||
|
i2pSession = i2pClient.createSession(it, sysProps)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("connecting i2p session")
|
||||||
|
i2pSession.connect()
|
||||||
|
|
||||||
|
log.info("initializing cache client")
|
||||||
|
CacheClient cacheClient = new CacheClient(eventBus,hostCache, connectionManager, i2pSession, props, 10000)
|
||||||
|
cacheClient.start()
|
||||||
|
|
||||||
|
// ... at the end, sleep
|
||||||
|
log.info("initialized everything, sleeping")
|
||||||
|
Thread.sleep(Integer.MAX_VALUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue