Deleted patched TomP2P (unnecessary), some tweaks in ChannelClientConfig

This commit is contained in:
ChronosX88 2019-04-10 18:20:25 +04:00
parent 2e048e6642
commit 9326565280
17 changed files with 36 additions and 12 deletions

View File

@ -21,13 +21,16 @@ version '0.1'
repositories { repositories {
mavenCentral() mavenCentral()
maven {
url 'http://tomp2p.net/dev/mvn/'
}
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.jar'], dir: 'libs/tomp2p') implementation 'net.tomp2p:tomp2p-all:5.0-Beta8'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation 'org.slf4j:slf4j-log4j12:+' implementation 'org.slf4j:slf4j-log4j12:1.7.26'
} }
compileKotlin { compileKotlin {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,7 @@
import io.github.chronosx88.dhtBootstrap.StorageBerkeleyDB import io.github.chronosx88.dhtBootstrap.StorageBerkeleyDB
import net.tomp2p.connection.DSASignatureFactory import net.tomp2p.connection.Bindings
import net.tomp2p.connection.ChannelClientConfiguration
import net.tomp2p.connection.RSASignatureFactory
import net.tomp2p.dht.PeerBuilderDHT import net.tomp2p.dht.PeerBuilderDHT
import net.tomp2p.dht.PeerDHT import net.tomp2p.dht.PeerDHT
import net.tomp2p.nat.PeerBuilderNAT import net.tomp2p.nat.PeerBuilderNAT
@ -12,6 +14,7 @@ import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
import java.io.FileWriter import java.io.FileWriter
import java.io.IOException import java.io.IOException
import java.net.InetSocketAddress
import java.util.* import java.util.*
@ -46,16 +49,20 @@ fun main() {
peerID = Number160.createHash(props!!.getProperty("peerID")) peerID = Number160.createHash(props!!.getProperty("peerID"))
try { try {
peerDHT = PeerBuilderDHT(PeerBuilder(peerID).ports(7243).start()) peerDHT = PeerBuilderDHT(
.storage( PeerBuilder(peerID)
.ports(7243)
.channelClientConfiguration(createChannelClientConfig())
.start()
).storage(
StorageBerkeleyDB( StorageBerkeleyDB(
peerID!!, peerID!!,
File(DATA_DIR_PATH), File(DATA_DIR_PATH),
DSASignatureFactory() RSASignatureFactory()
) )
).start() ).start()
PeerBuilderNAT(peerDHT!!.peer()) PeerBuilderNAT(peerDHT!!.peer())
.addRelayServerConfiguration(RelayType.OPENTCP, TCPRelayServerConfig()) .addRelayServerConfiguration(RelayType.BUFFERED_OPENTCP, TCPRelayServerConfig())
.start() .start()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
@ -64,3 +71,17 @@ fun main() {
val replication = AutoReplication(peerDHT!!.peer()) val replication = AutoReplication(peerDHT!!.peer())
replication.start() replication.start()
} }
fun createChannelClientConfig() : ChannelClientConfiguration {
val channelClientConfiguration = ChannelClientConfiguration()
channelClientConfiguration.bindings(Bindings())
channelClientConfiguration.maxPermitsPermanentTCP(250)
channelClientConfiguration.maxPermitsTCP(250)
channelClientConfiguration.maxPermitsUDP(250)
channelClientConfiguration.pipelineFilter(PeerBuilder.DefaultPipelineFilter())
channelClientConfiguration.signatureFactory(RSASignatureFactory())
channelClientConfiguration.senderTCP(InetSocketAddress(0).address)
channelClientConfiguration.senderUDP(InetSocketAddress(0).address)
channelClientConfiguration.byteBufPool(false)
return channelClientConfiguration
}