Esempio n. 1
0
func (this *Session) Serve() {
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", minecraft.HandshakePacketServerCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 30*time.Second)
	this.connCodec.ReadConn(this)
}
Esempio n. 2
0
func (this *Session) Serve() {
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", connect.PacketCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 10*time.Second)
	this.connCodec.ReadConn(this)
}
func (this *SessionOutBridge) Serve() {
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", minecraft.HandshakePacketClientCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 30*time.Second)

	inRemotePort, _ := strconv.ParseUint(this.session.remotePort, 10, 16)
	outRemotePort, _ := strconv.ParseUint(this.remotePort, 10, 16)
	loginPayload := LoginPayload{
		SecurityKey: this.server.SecurityKey,
		Host:        this.session.serverAddress,
		RealIp:      this.session.remoteIp,
		RealPort:    int(inRemotePort),
		Name:        this.session.name,
		UUID:        this.session.profile.Id,
		Properties:  make([]LoginPayloadProperty, 0),
	}
	for _, property := range this.session.profile.Properties {
		loginPayload.Properties = append(loginPayload.Properties, LoginPayloadProperty{property.Name, property.Value, property.Signature})
	}
	this.Write(minecraft.NewPacketServerHandshake(this.session.protocolVersion, EncodeLoginPayload(loginPayload), uint16(outRemotePort), 2))

	if this.session.protocol17 {
		this.pipeline.Replace("registry", minecraft.LoginPacketClientCodec17)
	} else {
		this.pipeline.Replace("registry", minecraft.LoginPacketClientCodec)
	}
	this.Write(minecraft.NewPacketServerLoginStart(this.session.name))

	this.state = STATE_LOGIN
	go this.connCodec.ReadConn(this)
}
Esempio n. 4
0
func (this *SessionOutBridge) Serve() {
	this.codec = packet.NewPacketCodecVariable(minecraft.HandshakePacketServerCodec, minecraft.HandshakePacketClientCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.codec, 10*time.Second)
	remotePort, _ := strconv.ParseUint(this.remotePort, 10, 8)
	this.Write(&minecraft.PacketServerHandshake{minecraft.VERSION, this.server.SecurityKey + ";" + this.session.remoteHost + ";" + this.session.remotePort + ";" + this.session.uuid, uint16(remotePort), 2})
	this.codec.SetEncodeCodec(minecraft.LoginPacketServerCodec)
	this.codec.SetDecodeCodec(minecraft.LoginPacketClientCodec)
	this.Write(&minecraft.PacketServerLoginStart{this.session.name})
	this.state = STATE_LOGIN
	go this.connCodec.ReadConn(this)
}
Esempio n. 5
0
func (this *ConnectImpl) Connect(addr string) (err error) {
	this.Disconnect()
	this.conn, err = net.Dial("tcp", addr)
	if err != nil {
		return
	}
	this.recordsMutex.Lock()
	defer this.recordsMutex.Unlock()
	this.records = make(map[int32]*RequestRecord)
	this.connCodec = packet.NewPacketConnCodec(this.conn, NewCodec(this), 10*time.Second)
	go this.connCodec.ReadConn(this)
	return
}
func (this *ConnectImpl) Connect(addr string) (err error) {
	this.Disconnect()
	this.conn, err = net.Dial("tcp", addr)
	if err != nil {
		return
	}
	this.recordsMutex.Lock()
	defer this.recordsMutex.Unlock()
	this.records = make(map[int32]*RequestRecord)
	this.pipeline = packet.NewPacketPipeline()
	this.pipeline.AddLast("varIntLength", packet.NewPacketCodecVarIntLength())
	this.pipeline.AddLast("registry", NewCodecRegistry(this))
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.pipeline, 10*time.Second)
	go this.connCodec.ReadConn(this)
	return
}
Esempio n. 7
0
func (this *Session) Serve() {
	this.connCodec = packet.NewPacketConnCodec(this.conn, connect.PacketCodec, 10*time.Second)
	go this.connCodec.ReadConn(this)
}
Esempio n. 8
0
func (this *Session) Serve() {
	this.codec = packet.NewPacketCodecVariable(minecraft.HandshakePacketClientCodec, minecraft.HandshakePacketServerCodec)
	this.connCodec = packet.NewPacketConnCodec(this.conn, this.codec, 10*time.Second)
	go this.connCodec.ReadConn(this)
}