forked from openrs2/openrs2
This will allow the RSA private key to be injected in the login packet codec.
parent
af3477776c
commit
73defefef4
@ -0,0 +1,81 @@ |
|||||||
|
package org.openrs2.protocol |
||||||
|
|
||||||
|
import com.google.inject.AbstractModule |
||||||
|
import com.google.inject.PrivateModule |
||||||
|
import com.google.inject.TypeLiteral |
||||||
|
import com.google.inject.multibindings.Multibinder |
||||||
|
import org.openrs2.buffer.BufferModule |
||||||
|
import org.openrs2.crypto.CryptoModule |
||||||
|
import org.openrs2.protocol.js5.Js5RemoteDownstream |
||||||
|
import org.openrs2.protocol.login.ClientOutOfDateCodec |
||||||
|
import org.openrs2.protocol.login.InitCrossDomainConnectionCodec |
||||||
|
import org.openrs2.protocol.login.InitGameConnectionCodec |
||||||
|
import org.openrs2.protocol.login.InitJaggrabConnectionCodec |
||||||
|
import org.openrs2.protocol.login.InitJs5RemoteConnectionCodec |
||||||
|
import org.openrs2.protocol.login.IpLimitCodec |
||||||
|
import org.openrs2.protocol.login.Js5OkCodec |
||||||
|
import org.openrs2.protocol.login.LoginDownstream |
||||||
|
import org.openrs2.protocol.login.LoginUpstream |
||||||
|
import org.openrs2.protocol.login.RequestWorldListCodec |
||||||
|
import org.openrs2.protocol.login.ServerFullCodec |
||||||
|
import org.openrs2.protocol.world.WorldListDownstream |
||||||
|
import org.openrs2.protocol.world.WorldListResponseCodec |
||||||
|
|
||||||
|
public object ProtocolModule : AbstractModule() { |
||||||
|
public override fun configure() { |
||||||
|
install(BufferModule) |
||||||
|
install(CryptoModule) |
||||||
|
|
||||||
|
bindProtocol( |
||||||
|
LoginUpstream::class.java, |
||||||
|
InitGameConnectionCodec::class.java, |
||||||
|
InitJs5RemoteConnectionCodec::class.java, |
||||||
|
InitJaggrabConnectionCodec::class.java, |
||||||
|
RequestWorldListCodec::class.java, |
||||||
|
InitCrossDomainConnectionCodec::class.java |
||||||
|
) |
||||||
|
|
||||||
|
bindProtocol( |
||||||
|
LoginDownstream::class.java, |
||||||
|
ClientOutOfDateCodec::class.java, |
||||||
|
ServerFullCodec::class.java, |
||||||
|
IpLimitCodec::class.java |
||||||
|
) |
||||||
|
|
||||||
|
bindProtocol( |
||||||
|
Js5RemoteDownstream::class.java, |
||||||
|
Js5OkCodec::class.java, |
||||||
|
ClientOutOfDateCodec::class.java, |
||||||
|
ServerFullCodec::class.java, |
||||||
|
IpLimitCodec::class.java |
||||||
|
) |
||||||
|
|
||||||
|
bindProtocol( |
||||||
|
WorldListDownstream::class.java, |
||||||
|
WorldListResponseCodec::class.java |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
private fun bindProtocol( |
||||||
|
annotation: Class<out Annotation>, |
||||||
|
vararg codecs: Class<out PacketCodec<*>> |
||||||
|
) { |
||||||
|
install(object : PrivateModule() { |
||||||
|
override fun configure() { |
||||||
|
val binder = Multibinder.newSetBinder(binder(), PACKET_CODEC_TYPE_LITERAL) |
||||||
|
for (codec in codecs) { |
||||||
|
binder.addBinding().to(codec) |
||||||
|
} |
||||||
|
|
||||||
|
bind(Protocol::class.java) |
||||||
|
.annotatedWith(annotation) |
||||||
|
.to(Protocol::class.java) |
||||||
|
|
||||||
|
expose(Protocol::class.java) |
||||||
|
.annotatedWith(annotation) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
private val PACKET_CODEC_TYPE_LITERAL = object : TypeLiteral<PacketCodec<*>>() {} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
package org.openrs2.protocol.js5 |
||||||
|
|
||||||
|
import javax.inject.Qualifier |
||||||
|
|
||||||
|
@Qualifier |
||||||
|
@Retention(AnnotationRetention.RUNTIME) |
||||||
|
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) |
||||||
|
public annotation class Js5RemoteDownstream |
@ -1,8 +1,10 @@ |
|||||||
package org.openrs2.protocol.login |
package org.openrs2.protocol.login |
||||||
|
|
||||||
import org.openrs2.protocol.EmptyPacketCodec |
import org.openrs2.protocol.EmptyPacketCodec |
||||||
|
import javax.inject.Singleton |
||||||
|
|
||||||
public object ClientOutOfDateCodec : EmptyPacketCodec<LoginResponse.ClientOutOfDate>( |
@Singleton |
||||||
|
public class ClientOutOfDateCodec : EmptyPacketCodec<LoginResponse.ClientOutOfDate>( |
||||||
packet = LoginResponse.ClientOutOfDate, |
packet = LoginResponse.ClientOutOfDate, |
||||||
opcode = 6 |
opcode = 6 |
||||||
) |
) |
||||||
|
@ -1,8 +1,10 @@ |
|||||||
package org.openrs2.protocol.login |
package org.openrs2.protocol.login |
||||||
|
|
||||||
import org.openrs2.protocol.EmptyPacketCodec |
import org.openrs2.protocol.EmptyPacketCodec |
||||||
|
import javax.inject.Singleton |
||||||
|
|
||||||
public object InitCrossDomainConnectionCodec : EmptyPacketCodec<LoginRequest.InitCrossDomainConnection>( |
@Singleton |
||||||
|
public class InitCrossDomainConnectionCodec : EmptyPacketCodec<LoginRequest.InitCrossDomainConnection>( |
||||||
opcode = 'G'.code, |
opcode = 'G'.code, |
||||||
packet = LoginRequest.InitCrossDomainConnection |
packet = LoginRequest.InitCrossDomainConnection |
||||||
) |
) |
||||||
|
@ -1,8 +1,10 @@ |
|||||||
package org.openrs2.protocol.login |
package org.openrs2.protocol.login |
||||||
|
|
||||||
import org.openrs2.protocol.EmptyPacketCodec |
import org.openrs2.protocol.EmptyPacketCodec |
||||||
|
import javax.inject.Singleton |
||||||
|
|
||||||
public object InitJaggrabConnectionCodec : EmptyPacketCodec<LoginRequest.InitJaggrabConnection>( |
@Singleton |
||||||
|
public class InitJaggrabConnectionCodec : EmptyPacketCodec<LoginRequest.InitJaggrabConnection>( |
||||||
packet = LoginRequest.InitJaggrabConnection, |
packet = LoginRequest.InitJaggrabConnection, |
||||||
opcode = 17 |
opcode = 17 |
||||||
) |
) |
||||||
|
@ -1,8 +1,10 @@ |
|||||||
package org.openrs2.protocol.login |
package org.openrs2.protocol.login |
||||||
|
|
||||||
import org.openrs2.protocol.EmptyPacketCodec |
import org.openrs2.protocol.EmptyPacketCodec |
||||||
|
import javax.inject.Singleton |
||||||
|
|
||||||
public object IpLimitCodec : EmptyPacketCodec<LoginResponse.IpLimit>( |
@Singleton |
||||||
|
public class IpLimitCodec : EmptyPacketCodec<LoginResponse.IpLimit>( |
||||||
packet = LoginResponse.IpLimit, |
packet = LoginResponse.IpLimit, |
||||||
opcode = 9 |
opcode = 9 |
||||||
) |
) |
||||||
|
@ -1,8 +1,10 @@ |
|||||||
package org.openrs2.protocol.login |
package org.openrs2.protocol.login |
||||||
|
|
||||||
import org.openrs2.protocol.EmptyPacketCodec |
import org.openrs2.protocol.EmptyPacketCodec |
||||||
|
import javax.inject.Singleton |
||||||
|
|
||||||
public object Js5OkCodec : EmptyPacketCodec<LoginResponse.Js5Ok>( |
@Singleton |
||||||
|
public class Js5OkCodec : EmptyPacketCodec<LoginResponse.Js5Ok>( |
||||||
packet = LoginResponse.Js5Ok, |
packet = LoginResponse.Js5Ok, |
||||||
opcode = 0 |
opcode = 0 |
||||||
) |
) |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
package org.openrs2.protocol.login |
||||||
|
|
||||||
|
import javax.inject.Qualifier |
||||||
|
|
||||||
|
@Qualifier |
||||||
|
@Retention(AnnotationRetention.RUNTIME) |
||||||
|
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) |
||||||
|
public annotation class LoginDownstream |
@ -0,0 +1,8 @@ |
|||||||
|
package org.openrs2.protocol.login |
||||||
|
|
||||||
|
import javax.inject.Qualifier |
||||||
|
|
||||||
|
@Qualifier |
||||||
|
@Retention(AnnotationRetention.RUNTIME) |
||||||
|
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) |
||||||
|
public annotation class LoginUpstream |
@ -1,8 +1,10 @@ |
|||||||
package org.openrs2.protocol.login |
package org.openrs2.protocol.login |
||||||
|
|
||||||
import org.openrs2.protocol.EmptyPacketCodec |
import org.openrs2.protocol.EmptyPacketCodec |
||||||
|
import javax.inject.Singleton |
||||||
|
|
||||||
public object ServerFullCodec : EmptyPacketCodec<LoginResponse.ServerFull>( |
@Singleton |
||||||
|
public class ServerFullCodec : EmptyPacketCodec<LoginResponse.ServerFull>( |
||||||
packet = LoginResponse.ServerFull, |
packet = LoginResponse.ServerFull, |
||||||
opcode = 7 |
opcode = 7 |
||||||
) |
) |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
package org.openrs2.protocol.world |
||||||
|
|
||||||
|
import javax.inject.Qualifier |
||||||
|
|
||||||
|
@Qualifier |
||||||
|
@Retention(AnnotationRetention.RUNTIME) |
||||||
|
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) |
||||||
|
public annotation class WorldListDownstream |
Loading…
Reference in new issue